diff --git a/Gopkg.lock b/Gopkg.lock index dcbb07b0a3..6849ce500c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,12 +2,12 @@ [[projects]] - digest = "1:8c680369096f2360f0655ba859290f0dd536b294daf69eaf614bc2aa4d2d6137" + digest = "1:5ef9a8852f524c7d515adf3262fa1b5d20a10c5c8f33305fdd075bce2c223912" name = "cloud.google.com/go" packages = ["compute/metadata"] pruneopts = "NT" - revision = "264def2dd949cdb8a803bb9f50fa29a67b798a6a" - version = "v0.46.3" + revision = "5d03b9fdabc3f75630183d940a54b0047106bf8a" + version = "v0.48.0" [[projects]] digest = "1:25870183293a3fb61cc9afd060a61d63a486f091db72af01a8ea3449f5ca530d" @@ -74,15 +74,15 @@ version = "v1.1.1" [[projects]] - digest = "1:f8657a34251b97c1b5fcfd6f460410ea7354439682602235fc0fa0af7b1b7a29" + digest = "1:4610a40c7f030095bdab7e4cfb3df09b0e00334c65ac5432047a0f0e13bdc32b" name = "github.com/emicklei/go-restful" packages = [ ".", "log", ] pruneopts = "NT" - revision = "f48aa74d360eda838561e6db9d36c6538398343f" - version = "v2.10.0" + revision = "99f05a26a0a1c71e664ebe6a76d29b2c80333056" + version = "v2.11.1" [[projects]] digest = "1:448bf60e9dce6d5fd9dfa8fd9eb9a23163424ff4e4f142456405781e942e3998" @@ -125,12 +125,12 @@ version = "v0.19.3" [[projects]] - digest = "1:7fc0908f885357d71c0fa50bb2333eb63ff6f9402584e7f8ac13f5cdf6e967d5" + digest = "1:97b95774863237dc7589e326d064713cc0372c9ecadbe2e4e7e560a949cbb45d" name = "github.com/go-openapi/spec" packages = ["."] pruneopts = "NT" - revision = "2223ab324566e4ace63ab69b9c8fff1b81a40eeb" - version = "v0.19.3" + revision = "8557d72e4f077c2dbe1e48df09e596b6fb9b7991" + version = "v0.19.4" [[projects]] digest = "1:b318f36b1725220c1580b27504b8ee9d33a2a8e2db58f28c176edf6f0d1b7fb2" @@ -141,23 +141,23 @@ version = "v0.19.5" [[projects]] - digest = "1:8ff9d7687cc3c94922b2d8ce01f84963cea63a77b87dfa1ae6b1d40f1252e9fa" + digest = "1:c3050a9f4b141fcc3ef805c8b3e8e8242676557755ffb9d2707c26530cd71c9d" name = "github.com/gogo/protobuf" packages = [ "proto", "sortkeys", ] pruneopts = "NT" - revision = "0ca988a254f991240804bf9821f3450d87ccbb1b" - version = "v1.3.0" + revision = "5628607bb4c51c3157aacc3a50f0ab707582b805" + version = "v1.3.1" [[projects]] branch = "master" - digest = "1:4a08feba32a9014d1b6e4abac6fe80c8f44b80f4204462010d585ed17d80b79c" + digest = "1:91f62b7cc037b5f5c68fc9d9ab3566226f287e9e2c043a81e9176b90e822218a" name = "github.com/golang/groupcache" packages = ["lru"] pruneopts = "NT" - revision = "404acd9df4cc9859d64fb9eed42e5c026187287a" + revision = "611e8accdfc92c4187d399e95ce826046d4c8d73" [[projects]] digest = "1:440a3032b9e2db5bbf14535c63caf0e886f13d4f1d128a4a4d9deb03f924aa0c" @@ -246,11 +246,14 @@ [[projects]] branch = "master" - digest = "1:47c006b86e06bdbce0ce7a5a0a9178d0b02e949e5506b08cf895ac4a9af3ff0b" + digest = "1:086588f1921061861ce7dc0977a374f4f7ef599ee09f367b1e3b718b7a27b9ce" name = "github.com/gophercloud/utils" - packages = ["openstack/clientconfig"] + packages = [ + "env", + "openstack/clientconfig", + ] pruneopts = "NT" - revision = "94e6842399e53620efe002c58b46ab18f6b160bc" + revision = "bd86af96d544288b19b1ca1eb2a3640a3a2d1fab" [[projects]] digest = "1:ed860d2b2c1d066d36a89c982eefc7d019badd534f60e87ab65d3d94f0797ef0" @@ -280,12 +283,12 @@ version = "v0.3.8" [[projects]] - digest = "1:13b7a2ab50dc8d2492844d1a82f5a798a5befcd337c1f5ec970922523306fcb0" + digest = "1:04395d3256130279b719634054b20f73fed0e7478b264544cb0f615f89d7bba9" name = "github.com/json-iterator/go" packages = ["."] pruneopts = "NT" - revision = "27518f6661eba504be5a7a9a9f6d9460d892ade3" - version = "v1.1.7" + revision = "03217c3e97663914aec3faafde50d081f197a0a2" + version = "v1.1.8" [[projects]] digest = "1:5181790e1f11c6b9cb42c70c5b902926c5e696b1e71bc24d4f82e6862ab3d078" @@ -340,7 +343,7 @@ version = "1.0.1" [[projects]] - digest = "1:2ea4049c70f105105777583d180b3ff3f27a970d07230882c45590793919ed3a" + digest = "1:1c76cf1c1ac89005595a3d74b02011462199b8de68ec618cd82e5534f50d4982" name = "github.com/onsi/gomega" packages = [ ".", @@ -357,12 +360,12 @@ "types", ] pruneopts = "NT" - revision = "bdebf9e0ece900259084cfa4121b97ce1a540939" - version = "v1.7.0" + revision = "f9a52764bd5a0fd2d201bcca584351d03b72f8da" + version = "v1.7.1" [[projects]] branch = "master" - digest = "1:13e4ee8678212f9cb10067673a6d948839f16bada539c1f000b0607ec0743a2b" + digest = "1:ded62c35ffdd78e16931c3da4926107bb3ebde10c5fd64917a57dcfb1e1e125a" name = "github.com/openshift/api" packages = [ ".", @@ -399,6 +402,8 @@ "quota/v1", "route", "route/v1", + "samples", + "samples/v1", "security", "security/v1", "servicecertsigner", @@ -408,12 +413,12 @@ "user", "user/v1", ] - pruneopts = "NT" - revision = "bac53ab1eb76f33fe58ad587f6894bd84cc6c5ef" + pruneopts = "UT" + revision = "4efd1a50a74e455e53d0f4478657e5c226fe9b24" [[projects]] branch = "master" - digest = "1:84d847a8d27e5a2b02d93242a4659e34b48ec919c38ef9a531021ec266641b69" + digest = "1:f2845eb7b8b0c42a36f610ce09869baf86cd2ad396e3c67b9c8960457b57f40f" name = "github.com/openshift/library-go" packages = [ "pkg/certs", @@ -427,10 +432,10 @@ "pkg/operator/v1helpers", ] pruneopts = "NT" - revision = "97c62d8a29013969b080844b90404fd37588b457" + revision = "0597a29991ca50513df1fdb76e7e2a267e3a3e3f" [[projects]] - digest = "1:663d2d751003fa80eb348ca665b8969fa0d8b92b4625bf060807aad7813a6edd" + digest = "1:d4af5115cb6f50fa43e18be17bacd0fb2288f63a08559be091f3150e65145425" name = "github.com/operator-framework/operator-sdk" packages = [ "pkg/k8sutil", @@ -438,8 +443,8 @@ "version", ] pruneopts = "NT" - revision = "39c65c36159a9c249e5f3c178205cc6e86c16f8d" - version = "v0.11.0" + revision = "2445fcda834ca4b7cf0d6c38fba6317fb219b469" + version = "v0.12.0" [[projects]] digest = "1:14715f705ff5dfe0ffd6571d7d201dd8e921030f8070321a79380d8ca4ec1a24" @@ -450,7 +455,7 @@ version = "v0.8.1" [[projects]] - digest = "1:e2fde2e6d46505f0d91d6d350410ca82f382870c90d6b05227302f45f78828a7" + digest = "1:ac48997e3abc92d938efd4bc22dd38762ddd2a639e99f57c9eee989f435014cc" name = "github.com/prometheus/client_golang" packages = [ "prometheus", @@ -458,8 +463,8 @@ "prometheus/promhttp", ] pruneopts = "NT" - revision = "2641b987480bca71fb39738eb8c8b0d577cb1d76" - version = "v0.9.4" + revision = "170205fb58decfd011f1550d4cfb737230d7ae4f" + version = "v1.1.0" [[projects]] branch = "master" @@ -482,7 +487,7 @@ version = "v0.7.0" [[projects]] - digest = "1:b211368aa39cabd94f594cdbe7330ce6f7df495e68b9c3d4fecb457772616240" + digest = "1:89b4547e3a4ba89ce68dea2e6e6bbf492b561aab450252550af208109a761eed" name = "github.com/prometheus/procfs" packages = [ ".", @@ -490,8 +495,8 @@ "internal/util", ] pruneopts = "NT" - revision = "499c85531f756d1129edd26485a5f73871eeb308" - version = "v0.0.5" + revision = "8a055596020d692cf491851e47ba3e302d9f90ce" + version = "v0.0.6" [[projects]] digest = "1:d115708a27806831d1babbc6f28a7478ddf8e32a7095507c816e2515fb03a810" @@ -518,11 +523,11 @@ name = "github.com/vishvananda/netns" packages = ["."] pruneopts = "NT" - revision = "7109fa855b0ff1ebef7fbd2f6aa613e8db7cfbc0" + revision = "0a2b9b5464df8343199164a0321edf3313202f7e" [[projects]] branch = "master" - digest = "1:da41e423b26b6e5fda3cebb57fb3a7f36e97e403ca48b9333a74d48510b9f5a6" + digest = "1:00f7cb110ec083a03baf86042414b205078e73bd8d0bb4b7c0e7cd738b880e6a" name = "golang.org/x/crypto" packages = [ "pbkdf2", @@ -530,11 +535,11 @@ "ssh/terminal", ] pruneopts = "NT" - revision = "34f69633bfdcf9db92f698f8487115767eebef81" + revision = "e1110fd1c708ef015366ea01799a23c459593c47" [[projects]] branch = "master" - digest = "1:4ffe1220be17902c98f6770c19b18df6b4c7e26fbc76aa10614789baa3edf73b" + digest = "1:024e423b75a02b8cf44579f54fb434b82ab68694969fa6828f4eada4ec7e731b" name = "golang.org/x/net" packages = [ "context", @@ -548,7 +553,7 @@ "idna", ] pruneopts = "NT" - revision = "d98b1b4438230571bd7fbc5aaa89843e92937bd3" + revision = "2180aed2234323691e9fd264fb1d32d20ff04b27" [[projects]] branch = "master" @@ -566,14 +571,14 @@ [[projects]] branch = "master" - digest = "1:bf60f69e87c01b751aa45ebbe702f14183a2088b4d1e108ef7cb653f59255c85" + digest = "1:9fb304babc294681696a73b55814456194c6cc799b29b5490808bba5795ae8a0" name = "golang.org/x/sys" packages = [ "unix", "windows", ] pruneopts = "NT" - revision = "5f54ce54270977bfbd7353a37e64c13d6bd6c9c9" + revision = "4c7a9d0fe056d9d1de37e1409ca8a5c17accb46a" [[projects]] digest = "1:348fa8283a7c60b5b71ce04d27b37f7c0fce552d4d0b463b5b3ebbd1840d3f1a" @@ -615,15 +620,15 @@ [[projects]] branch = "master" - digest = "1:cdd088b35bbf78713a6861a44a1bbe97e581861b6b8835c7f2211bbeca3671f6" + digest = "1:a2f668c709f9078828e99cb1768cb02e876cb81030545046a32b54b2ac2a9ea8" name = "golang.org/x/time" packages = ["rate"] pruneopts = "NT" - revision = "c4c64cad1fd0a1a8dab2523e04e61d35308e131e" + revision = "555d28b269f0569763d25dbe1a237ae74c6bcc82" [[projects]] branch = "master" - digest = "1:90bdc2b14871233d85c776e8d7eb4039dd93c08e496edfcd1a580a3b0812dfbc" + digest = "1:99888367de753f065aa11d8cb0e9e503a2ae0e78c0aaa5fc72f02e0a57b5c385" name = "golang.org/x/tools" packages = [ "go/ast/astutil", @@ -638,9 +643,10 @@ "internal/imports", "internal/module", "internal/semver", + "internal/span", ] pruneopts = "NT" - revision = "c9f9432ec4b21a28c4d47f172513698febb68e9c" + revision = "77e3bb0ad9e72123a382fe9c4870b269210dab83" [[projects]] branch = "master" @@ -662,7 +668,7 @@ version = "v2.0.1" [[projects]] - digest = "1:2c515a531ad63d08e6691da5ce0fb80bab7d1935091ec0002d538bbf2af5661a" + digest = "1:ef33a89dbeefa3d834fff6b9e0b342311d4bf1a90cbe9c646e79797940b61c88" name = "google.golang.org/appengine" packages = [ ".", @@ -677,8 +683,8 @@ "urlfetch", ] pruneopts = "NT" - revision = "bddb1f54ecfd64b1350fd2dd897fa11d426632bc" - version = "v1.6.4" + revision = "971852bfffca25b069c31162ae8f247a3dba083b" + version = "v1.6.5" [[projects]] digest = "1:1b91ae0dc69a41d4c2ed23ea5cffb721ea63f5037ca4b81e6d6771fbb8f45129" @@ -698,12 +704,12 @@ version = "v0.9.1" [[projects]] - digest = "1:accc3bfe4e404aa53ac3621470e7cf9fce1efe48f0fabcfe6d12a72579d9d91f" + digest = "1:5ad10df0893403ae9fdbd17c6f14814394a635339dd79595600bae52432befcf" name = "gopkg.in/yaml.v2" packages = ["."] pruneopts = "NT" - revision = "f221b8435cfb71e54062f6c6e99e9ade30b124d5" - version = "v2.2.4" + revision = "f90ceb4f409096b60e2e9076b38b304b8246e5fa" + version = "v2.2.5" [[projects]] digest = "1:e6dbaffcc5407ea1fa7633f6ccb7e53ff3952eed041e9cbe4f97c9af87913ef1" @@ -823,11 +829,11 @@ [[projects]] branch = "master" - digest = "1:f8bb099039820f3f3bab3cf068e46b6297b09b5fbc7632de165c36217422d105" + digest = "1:a7026fbf0ca0d5c8f8802336cb0e892146d6eba36c6c4e469e2b64d14dee1e9b" name = "k8s.io/apiserver" packages = ["pkg/authentication/user"] pruneopts = "NT" - revision = "c29386a6051d0cc905faa078747da7d109a36faa" + revision = "707298a79a53694b8666ffc5634d2bbac4341159" [[projects]] digest = "1:65f86d654fcfcc0ba794c99514724dd1f1b4ea870b0c8e53652ddfa63395dca0" @@ -1036,18 +1042,18 @@ [[projects]] branch = "master" - digest = "1:43bffc711fc81ebceae2ba8d158c89fdd0cc2cd8de253bf86e15d2abb6ef92e2" + digest = "1:a99bfe0be361188f12c383ffd3b7b5184b6333941a90ac94dfafa7356dfeceed" name = "k8s.io/component-base" packages = [ "config", "config/v1alpha1", ] pruneopts = "NT" - revision = "f5216b94ab440ce44beab80952b515928f95629a" + revision = "cca8f4f7ce4d55fa1dc4dd3ec01501284e5d3f98" [[projects]] branch = "master" - digest = "1:6052f05eb0fa1de1923ba3cb87c5c3f983e67333a7deb5b2cb0dc33c1d0f41e2" + digest = "1:2f41eab9596e66f604ae792e64f9ec2b7b3bfe52eb9f8d5bdab6718e5f0b692b" name = "k8s.io/gengo" packages = [ "args", @@ -1060,7 +1066,7 @@ "types", ] pruneopts = "NT" - revision = "ebc107f98eab922ef99d645781b87caca01f4f48" + revision = "e500ee069b5c8469a9e278b53cb41bd65404bfd9" [[projects]] digest = "1:2c76089e62b6a1c8a48e87f47f7ac3069962a520e553db28d458d3e75d5fed3f" @@ -1072,7 +1078,7 @@ [[projects]] branch = "master" - digest = "1:7295d3e34a8456ed7a6e52200a9a5c9d6d4832bfbff0eaf6606b3f62e818a578" + digest = "1:4c3e36dc108e0f1b73dc4d3d5419754b3e1a03e8e3d00c48e983cdf63ce4215e" name = "k8s.io/kube-aggregator" packages = [ "pkg/apis/apiregistration", @@ -1082,11 +1088,11 @@ "pkg/client/clientset_generated/clientset/typed/apiregistration/v1", ] pruneopts = "NT" - revision = "cd60da6daff6d142f0e06ceb88bde4ce66e7a1a8" + revision = "a1b02ed9435a7e5ef5af55f4268ce78fd02c1662" [[projects]] branch = "master" - digest = "1:6fd61bc5e7ce12285e3538275a4481e887e82eecc231c748a3890cc7682c9666" + digest = "1:275689e02c525bf910dcfff4627d525012ce40b6b7bc36c62f5f29df31ccda59" name = "k8s.io/kube-openapi" packages = [ "cmd/openapi-gen/args", @@ -1097,7 +1103,7 @@ "pkg/util/sets", ] pruneopts = "NT" - revision = "0270cf2f1c1d995d34b36019a6f65d58e6e33ad4" + revision = "30be4d16710ac61bce31eb28a01054596fe6a9f1" [[projects]] digest = "1:f01db735f95d55d682842f90b4c0eb4dec703cf71b2f4cf815a42081efbf5cae" @@ -1109,7 +1115,7 @@ [[projects]] branch = "master" - digest = "1:e038b0cf21ed590e282dcaccfdf83a75675bc95dfdfe60a40f6346792ef64712" + digest = "1:bec533dd65da84dcc73d2e67d99f892a004a262b6e29e939913d4f973ddaad42" name = "k8s.io/utils" packages = [ "buffer", @@ -1118,7 +1124,7 @@ "trace", ] pruneopts = "NT" - revision = "69764acb6e8e900b7c05296c5d3c9c19545475f9" + revision = "2b95a09bc58df43d4032504619706b6a38293a47" [[projects]] digest = "1:6a2dad4276ed181cb1990dc1dabad3bf0218bb98416ab4171142f2c0b9829bef" diff --git a/Gopkg.toml b/Gopkg.toml index 2959ad09db..8da23e2b64 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -43,6 +43,11 @@ required = [ name = "k8s.io/code-generator" non-go = false + [[prune.project]] + name = "github.com/openshift/api" + non-go = false + unused-packages = true + [[constraint]] name = "github.com/Masterminds/sprig" version = "^2" diff --git a/bindata/network/openshift-sdn/001-crd.yaml b/bindata/network/openshift-sdn/001-crd.yaml index 1ab49e8da9..59dccbd55a 100644 --- a/bindata/network/openshift-sdn/001-crd.yaml +++ b/bindata/network/openshift-sdn/001-crd.yaml @@ -1,15 +1,17 @@ +--- apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: + creationTimestamp: null name: clusternetworks.network.openshift.io spec: group: network.openshift.io - version: v1 - scope: Cluster names: kind: ClusterNetwork - singular: clusternetwork + listKind: ClusterNetworkList plural: clusternetworks + singular: clusternetwork + scope: Cluster validation: # As compared to ValidateClusterNetwork, this does not validate that: # - the hostSubnetLengths are valid for their CIDRs @@ -18,39 +20,95 @@ spec: # - .network and .hostsubnetlength are either unset, or equal to # .clusterNetworks[0].CIDR and .clusterNetworks[0].hostSubnetLength openAPIV3Schema: + description: ClusterNetwork describes the cluster network. There is normally + only one object of this type, named "default", which is created by the SDN + network plugin based on the master configuration when the cluster is brought + up for the first time. properties: - network: - type: string - pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' - hostsubnetlength: - type: integer - minimum: 2 - maximum: 30 - serviceNetwork: - type: string - pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' - pluginName: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string clusterNetworks: - type: array + description: ClusterNetworks is a list of ClusterNetwork objects that defines + the global overlay network's L3 space by specifying a set of CIDR and + netmasks that the SDN can allocate addresses from. items: - type: object + description: ClusterNetworkEntry defines an individual cluster network. + The CIDRs cannot overlap with other cluster network CIDRs, CIDRs reserved + for external ips, CIDRs reserved for service networks, and CIDRs reserved + for ingress ips. properties: CIDR: + description: CIDR defines the total range of a cluster networks address + space. type: string pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' hostSubnetLength: + description: HostSubnetLength is the number of bits of the accompanying + CIDR address to allocate to each node. eg, 8 would mean that each + node would have a /24 slice of the overlay network for its pods. + format: int32 type: integer minimum: 2 maximum: 30 - vxlanPort: + required: + - CIDR + - hostSubnetLength + type: object + type: array + hostsubnetlength: + description: HostSubnetLength is the number of bits of network to allocate + to each node. eg, 8 would mean that each node would have a /24 slice of + the overlay network for its pods + format: int32 type: integer - minimum: 1 - maximum: 65535 + minimum: 2 + maximum: 30 + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object mtu: + description: MTU is the MTU for the overlay network. This should be 50 less + than the MTU of the network connecting the nodes. It is normally autodetected + by the cluster network operator. + format: int32 type: integer minimum: 576 maximum: 65536 + network: + description: Network is a CIDR string specifying the global overlay network's + L3 space + type: string + pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' + pluginName: + description: PluginName is the name of the network plugin being used + type: string + serviceNetwork: + description: ServiceNetwork is the CIDR range that Service IP addresses + are allocated from + type: string + pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' + vxlanPort: + description: VXLANPort sets the VXLAN destination port used by the cluster. + It is set by the master configuration file on startup and cannot be edited + manually. Valid values for VXLANPort are integers 1-65535 inclusive and + if unset defaults to 4789. Changing VXLANPort allows users to resolve + issues between openshift SDN and other software trying to use the same + VXLAN destination port. + format: int32 + type: integer + minimum: 1 + maximum: 65535 + required: + - clusterNetworks + - serviceNetwork + type: object additionalPrinterColumns: - name: Cluster Network type: string @@ -64,19 +122,31 @@ spec: type: string description: The OpenShift SDN network plug-in in use JSONPath: .pluginName + version: v1 + versions: + - name: v1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] --- apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: + creationTimestamp: null name: hostsubnets.network.openshift.io spec: group: network.openshift.io - version: v1 - scope: Cluster names: kind: HostSubnet - singular: hostsubnet + listKind: HostSubnetList plural: hostsubnets + singular: hostsubnet + scope: Cluster validation: # As compared to ValidateHostSubnet, this does not validate that: # - .host == .name @@ -84,26 +154,58 @@ spec: # As compared to ValidateHostSubnetUpdate, this does not validate that: # - .subnet is not changed on an existing object openAPIV3Schema: + description: HostSubnet describes the container subnet network on a node. The + HostSubnet object must have the same name as the Node object it corresponds + to. properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + egressCIDRs: + description: EgressCIDRs is the list of CIDR ranges available for automatically + assigning egress IPs to this node from. If this field is set then EgressIPs + should be treated as read-only. + items: + type: string + pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' + type: array + egressIPs: + description: EgressIPs is the list of automatic egress IP addresses currently + hosted by this node. If EgressCIDRs is empty, this can be set by hand; + if EgressCIDRs is set then the master will overwrite the value here with + its own allocation of egress IPs. + items: + type: string + pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$' + type: array host: + description: Host is the name of the node. (This is the same as the object's + name, but both fields must be set.) type: string pattern: '^[a-z0-9.-]+$' hostIP: + description: HostIP is the IP address to be used as a VTEP by other nodes + in the overlay network type: string pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$' + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object subnet: + description: Subnet is the CIDR range of the overlay network assigned to + the node for its pods type: string pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' - egressIPs: - type: array - items: - type: string - pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$' - egressCIDRs: - type: array - items: - type: string - pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' + required: + - host + - hostIP + type: object additionalPrinterColumns: - name: Host type: string @@ -125,37 +227,78 @@ spec: type: string description: The network egress IP addresses JSONPath: .egressIPs + version: v1 + versions: + - name: v1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] --- apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: + creationTimestamp: null name: netnamespaces.network.openshift.io spec: group: network.openshift.io - version: v1 - scope: Cluster names: kind: NetNamespace - singular: netnamespace + listKind: NetNamespaceList plural: netnamespaces + singular: netnamespace + scope: Cluster validation: # As compared to ValidateNetNamespace, this does not validate that: # - .netname == .name # - .netid is not 1-9 openAPIV3Schema: + description: NetNamespace describes a single isolated network. When using the + redhat/openshift-ovs-multitenant plugin, every Namespace will have a corresponding + NetNamespace object with the same name. (When using redhat/openshift-ovs-subnet, + NetNamespaces are not used.) properties: - netname: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string - pattern: '^[a-z0-9.-]+$' - netid: - type: integer - minimum: 0 - maximum: 16777215 egressIPs: - type: array + description: EgressIPs is a list of reserved IPs that will be used as the + source for external traffic coming from pods in this namespace. (If empty, + external traffic will be masqueraded to Node IPs.) items: type: string pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$' + type: array + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + netid: + description: NetID is the network identifier of the network namespace assigned + to each overlay network packet. This can be manipulated with the "oc adm + pod-network" commands. + format: int32 + type: integer + minimum: 0 + maximum: 16777215 + netname: + description: NetName is the name of the network namespace. (This is the + same as the object's name, but both fields must be set.) + type: string + pattern: '^[a-z0-9.-]+$' + required: + - netid + - netname + type: object additionalPrinterColumns: - name: NetID type: integer @@ -165,43 +308,102 @@ spec: type: string description: The network egress IP addresses JSONPath: .egressIPs + version: v1 + versions: + - name: v1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] --- apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: + creationTimestamp: null name: egressnetworkpolicies.network.openshift.io spec: group: network.openshift.io - version: v1 - scope: Namespaced names: kind: EgressNetworkPolicy - singular: egressnetworkpolicy + listKind: EgressNetworkPolicyList plural: egressnetworkpolicies + singular: egressnetworkpolicy + scope: Namespaced validation: # This should be mostly equivalent to ValidateEgressNetworkPolicy openAPIV3Schema: + description: EgressNetworkPolicy describes the current egress network policy + for a Namespace. When using the 'redhat/openshift-ovs-multitenant' network + plugin, traffic from a pod to an IP address outside the cluster will be checked + against each EgressNetworkPolicyRule in the pod's namespace's EgressNetworkPolicy, + in order. If no rule matches (or no EgressNetworkPolicy is present) then the + traffic will be allowed by default. properties: - spec: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: type: object + spec: + description: spec is the specification of the current egress network policy properties: egress: - type: array - maxItems: 50 + description: egress contains the list of egress policy rules items: - type: object + description: EgressNetworkPolicyRule contains a single egress network + policy rule properties: - type: - type: string - pattern: '^Allow|Deny$' to: - type: object - minProperties: 1 - maxProperties: 1 + description: to is the target that traffic is allowed/denied to properties: cidrSelector: + description: cidrSelector is the CIDR range to allow/deny + traffic to. If this is set, dnsName must be unset type: string pattern: '^(([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/([0-9]|[12][0-9]|3[0-2])$' dnsName: + description: dnsName is the domain name to allow/deny traffic + to. If this is set, cidrSelector must be unset type: string pattern: '^([A-Za-z0-9-]+\.)*[A-Za-z0-9-]+\.?$' + type: object + minProperties: 1 + maxProperties: 1 + type: + description: type marks this as an "Allow" or "Deny" rule + type: string + pattern: '^Allow|Deny$' + required: + - to + - type + type: object + type: array + maxItems: 50 + required: + - egress + type: object + required: + - spec + type: object + version: v1 + versions: + - name: v1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/manifests/0000_70_cluster-network-operator_01_crd.yaml b/manifests/0000_70_cluster-network-operator_01_crd.yaml index 13607c337f..97dd62f382 100644 --- a/manifests/0000_70_cluster-network-operator_01_crd.yaml +++ b/manifests/0000_70_cluster-network-operator_01_crd.yaml @@ -10,150 +10,366 @@ spec: plural: networks singular: network scope: Cluster + preserveUnknownFields: false versions: - - name: v1 - served: true - storage: true + - name: v1 + served: true + storage: true validation: # Ensure we will be able to deserialize the object into the golang type openAPIV3Schema: + description: Network describes the cluster's desired network configuration. + It is consumed by the cluster-network-operator. + type: object properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object spec: + description: NetworkSpec is the top-level network configuration object. type: object required: ["defaultNetwork"] properties: - clusterNetwork: - type: array - items: - type: object - required: ["cidr", "hostPrefix"] - properties: - cidr: - type: string - hostPrefix: - type: integer - minimum: 0 - serviceNetwork: - type: array - items: - type: string - defaultNetwork: - type: object - required: ["type"] - properties: - type: - type: string - openshiftSDNConfig: - type: object - properties: - mode: - type: string - vxlanPort: - type: integer - minimum: 0 - mtu: - type: integer - minimum: 0 - useExternalOpenvswitch: - type: boolean - enableUnidling: - type: boolean - ovnKubernetesConfig: - type: object - properties: - mtu: - type: integer - minimum: 0 - kuryrConfig: - type: object - properties: - daemonProbesPort: - type: integer - minimum: 0 - controllerProbesPort: - type: integer - minimum: 0 - openStackServiceNetwork: - type: string additionalNetworks: + description: additionalNetworks is a list of extra networks to make + available to pods when multiple networks are enabled. type: array items: + description: AdditionalNetworkDefinition configures an extra network + that is available but not created by default. Instead, pods must + request them by name. type must be specified, along with exactly + one "Config" that matches the type. type: object required: ["type", "name"] properties: - type: - type: string name: + description: name is the name of the network. This will be populated + in the resulting CRD This must be unique. type: string namespace: + description: namespace is the namespace of the network. This will + be populated in the resulting CRD If not given the network will + be created in the default namespace. type: string rawCNIConfig: + description: rawCNIConfig is the raw CNI configuration json to + create in the NetworkAttachmentDefinition CRD type: string simpleMacvlanConfig: + description: SimpleMacvlanConfig configures the macvlan interface + in case of type:NetworkTypeSimpleMacvlan type: object properties: - master: - type: string ipamConfig: + description: IPAMConfig configures IPAM module will be used + for IP Address Management (IPAM). type: object properties: - type: - type: string staticIPAMConfig: + description: StaticIPAMConfig configures the static IP + address in case of type:IPAMTypeStatic type: object properties: addresses: + description: Addresses configures IP address for the + interface type: array items: + description: StaticIPAMAddresses provides IP address + and Gateway for static IPAM addresses type: object properties: address: + description: Address is the IP address in CIDR + format type: string gateway: - type: string - routes: - type: array - items: - type: object - properties: - destination: - type: string - gateway: + description: Gateway is IP inside of subnet + to designate as the gateway type: string dns: + description: DNS configures DNS for the interface type: object properties: + domain: + description: Domain configures the domainname + the local domain used for short hostname lookups + type: string nameservers: + description: Nameservers points DNS servers for + IP lookup type: array items: type: string - domain: - type: string search: + description: Search configures priority ordered + search domains for short hostname lookups type: array items: type: string + routes: + description: Routes configures IP routes for the interface + type: array + items: + description: StaticIPAMRoutes provides Destination/Gateway + pairs for static IPAM routes + type: object + properties: + destination: + description: Destination points the IP route + destination + type: string + gateway: + description: Gateway is the route's next-hop + IP address If unset, a default gateway is + assumed (as determined by the CNI plugin). + type: string + type: + description: Type is the type of IPAM module will be used + for IP Address Management(IPAM). The supported values + are IPAMTypeDHCP, IPAMTypeStatic + type: string + master: + description: master is the host interface to create the macvlan + interface from. If not specified, it will be default route + interface + type: string mode: + description: 'mode is the macvlan mode: bridge, private, vepa, + passthru. The default is bridge' type: string mtu: + description: mtu is the mtu to use for the macvlan interface. + if unset, host's kernel will select the value. type: integer - disableMultiNetwork: - type: boolean + format: int32 + minimum: 0 + type: + description: type is the type of network The supported values + are NetworkTypeRaw, NetworkTypeSimpleMacvlan + type: string + clusterNetwork: + description: clusterNetwork is the IP address pool to use for pod IPs. + Some network providers, e.g. OpenShift SDN, support multiple ClusterNetworks. + Others only support one. This is equivalent to the cluster-cidr. + type: array + items: + description: ClusterNetworkEntry is a subnet from which to allocate + PodIPs. A network of size HostPrefix (in CIDR notation) will be + allocated when nodes join the cluster. Not all network providers + support multiple ClusterNetworks + type: object + required: ["cidr", "hostPrefix"] + properties: + cidr: + type: string + hostPrefix: + type: integer + format: int32 + minimum: 0 + defaultNetwork: + description: defaultNetwork is the "default" network that all pods will + receive + type: object + required: ["type"] + properties: + kuryrConfig: + description: KuryrConfig configures the kuryr plugin + type: object + properties: + controllerProbesPort: + description: The port kuryr-controller will listen for readiness + and liveness requests. + type: integer + format: int32 + minimum: 0 + daemonProbesPort: + description: The port kuryr-daemon will listen for readiness + and liveness requests. + type: integer + format: int32 + minimum: 0 + enablePortPoolsPrepopulation: + description: enablePortPoolsPrepopulation when true will make + Kuryr prepopulate each newly created port pool with a minimum + number of ports. Kuryr uses Neutron port pooling to fight + the fact that it takes a significant amount of time to create + one. Instead of creating it when pod is being deployed, Kuryr + keeps a number of ports ready to be attached to pods. By default + port prepopulation is disabled. + type: boolean + openStackServiceNetwork: + description: openStackServiceNetwork contains the CIDR of network + from which to allocate IPs for OpenStack Octavia's Amphora + VMs. Please note that with Amphora driver Octavia uses two + IPs from that network for each loadbalancer - one given by + OpenShift and second for VRRP connections. As the first one + is managed by OpenShift's and second by Neutron's IPAMs, those + need to come from different pools. Therefore `openStackServiceNetwork` + needs to be at least twice the size of `serviceNetwork`, and + whole `serviceNetwork` must be overlapping with `openStackServiceNetwork`. + cluster-network-operator will then make sure VRRP IPs are + taken from the ranges inside `openStackServiceNetwork` that + are not overlapping with `serviceNetwork`, effectivly preventing + conflicts. If not set cluster-network-operator will use `serviceNetwork` + expanded by decrementing the prefix size by 1. + type: string + poolBatchPorts: + description: poolBatchPorts sets a number of ports that should + be created in a single batch request to extend the port pool. + The default is 3. For more information about port pools see + enablePortPoolsPrepopulation setting. + type: integer + minimum: 0 + poolMaxPorts: + description: poolMaxPorts sets a maximum number of free ports + that are being kept in a port pool. If the number of ports + exceeds this setting, free ports will get deleted. Setting + 0 will disable this upper bound, effectively preventing pools + from shrinking and this is the default value. For more information + about port pools see enablePortPoolsPrepopulation setting. + type: integer + minimum: 0 + poolMinPorts: + description: poolMinPorts sets a minimum number of free ports + that should be kept in a port pool. If the number of ports + is lower than this setting, new ports will get created and + added to pool. The default is 1. For more information about + port pools see enablePortPoolsPrepopulation setting. + type: integer + minimum: 1 + openshiftSDNConfig: + description: openShiftSDNConfig configures the openshift-sdn plugin + type: object + properties: + enableUnidling: + description: enableUnidling controls whether or not the service + proxy will support idling and unidling of services. By default, + unidling is enabled. + type: boolean + mode: + description: mode is one of "Multitenant", "Subnet", or "NetworkPolicy" + type: string + mtu: + description: mtu is the mtu to use for the tunnel interface. + Defaults to 1450 if unset. This must be 50 bytes smaller than + the machine's uplink. + type: integer + format: int32 + minimum: 0 + useExternalOpenvswitch: + description: useExternalOpenvswitch tells the operator not to + install openvswitch, because it will be provided separately. + If set, you must provide it yourself. + type: boolean + vxlanPort: + description: vxlanPort is the port to use for all vxlan packets. + The default is 4789. + type: integer + format: int32 + minimum: 0 + ovnKubernetesConfig: + description: oVNKubernetesConfig configures the ovn-kubernetes plugin. + This is currently not implemented. + type: object + properties: + genevePort: + description: geneve port is the UDP port to be used by geneve + encapulation. Default is 6081 + type: integer + format: int32 + minimum: 1 + hybridOverlayConfig: + description: HybridOverlayConfig configures an additional overlay + network for peers that are not using OVN. + type: object + properties: + hybridClusterNetwork: + description: HybridClusterNetwork defines a network space + given to nodes on an additional overlay network. + type: array + items: + description: ClusterNetworkEntry is a subnet from which + to allocate PodIPs. A network of size HostPrefix (in + CIDR notation) will be allocated when nodes join the + cluster. Not all network providers support multiple + ClusterNetworks + type: object + properties: + cidr: + type: string + hostPrefix: + type: integer + format: int32 + minimum: 0 + mtu: + description: mtu is the MTU to use for the tunnel interface. + This must be 100 bytes smaller than the uplink mtu. Default + is 1400 + type: integer + format: int32 + minimum: 0 + type: + description: type is the type of network All NetworkTypes are supported + except for NetworkTypeRaw + type: string deployKubeProxy: + description: deployKubeProxy specifies whether or not a standalone kube-proxy + should be deployed by the operator. Some network providers include + kube-proxy or similar functionality. If unset, the plugin will attempt + to select the correct value, which is false when OpenShift SDN and + ovn-kubernetes are used and true otherwise. + type: boolean + disableMultiNetwork: + description: disableMultiNetwork specifies whether or not multiple pod + network support should be disabled. If unset, this property defaults + to 'false' and multiple network support is enabled. type: boolean kubeProxyConfig: + description: kubeProxyConfig lets us configure desired proxy configuration. + If not specified, sensible defaults will be chosen by OpenShift directly. + Not consumed by all network providers - currently only openshift-sdn. type: object properties: - iptablesSyncPeriod: - type: string bindAddress: + description: The address to "bind" on Defaults to 0.0.0.0 + type: string + iptablesSyncPeriod: + description: 'The period that iptables rules are refreshed. Default: + 30s' type: string proxyArguments: + description: Any additional arguments to pass to the kubeproxy process type: object additionalProperties: + description: ProxyArgumentList is a list of arguments to pass + to the kubeproxy process type: array items: type: string + logLevel: + description: logLevel allows configuring the logging level of the components + deployed by the operator. Currently only Kuryr SDN is affected by + this setting. Please note that turning on extensive logging may affect + performance. The default value is "Normal". + type: string + serviceNetwork: + description: serviceNetwork is the ip address pool to use for Service + IPs Currently, all existing network providers only support a single + value here, but this is an array to allow for growth. + type: array + items: + type: string status: + description: NetworkStatus is currently unused. Instead, status is reported + in the Network.config.openshift.io object. type: object - diff --git a/vendor/cloud.google.com/go/asset/apiv1/asset_client.go b/vendor/cloud.google.com/go/asset/apiv1/asset_client.go index 87706cd7b8..4fac08e030 100644 --- a/vendor/cloud.google.com/go/asset/apiv1/asset_client.go +++ b/vendor/cloud.google.com/go/asset/apiv1/asset_client.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Code generated by gapic-generator. DO NOT EDIT. +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. package asset @@ -44,6 +44,7 @@ type CallOptions struct { func defaultClientOptions() []option.ClientOption { return []option.ClientOption{ option.WithEndpoint("cloudasset.googleapis.com:443"), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), option.WithScopes(DefaultAuthScopes()...), option.WithGRPCDialOption(grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(math.MaxInt32))), @@ -51,8 +52,9 @@ func defaultClientOptions() []option.ClientOption { } func defaultCallOptions() *CallOptions { - retry := map[[2]string][]gax.CallOption{ - {"default", "idempotent"}: { + return &CallOptions{ + ExportAssets: []gax.CallOption{}, + BatchGetAssetsHistory: []gax.CallOption{ gax.WithRetry(func() gax.Retryer { return gax.OnCodes([]codes.Code{ codes.DeadlineExceeded, @@ -60,15 +62,11 @@ func defaultCallOptions() *CallOptions { }, gax.Backoff{ Initial: 100 * time.Millisecond, Max: 60000 * time.Millisecond, - Multiplier: 1.3, + Multiplier: 1.30, }) }), }, } - return &CallOptions{ - ExportAssets: retry[[2]string{"default", "non_idempotent"}], - BatchGetAssetsHistory: retry[[2]string{"default", "idempotent"}], - } } // Client is a client for interacting with Cloud Asset API. @@ -205,7 +203,7 @@ func (c *Client) ExportAssetsOperation(name string) *ExportAssetsOperation { // See documentation of Poll for error-handling information. func (op *ExportAssetsOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*assetpb.ExportAssetsResponse, error) { var resp assetpb.ExportAssetsResponse - if err := op.lro.WaitWithInterval(ctx, &resp, 5000*time.Millisecond, opts...); err != nil { + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { return nil, err } return &resp, nil diff --git a/vendor/cloud.google.com/go/asset/apiv1/doc.go b/vendor/cloud.google.com/go/asset/apiv1/doc.go index 793cdec665..8af418668c 100644 --- a/vendor/cloud.google.com/go/asset/apiv1/doc.go +++ b/vendor/cloud.google.com/go/asset/apiv1/doc.go @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Code generated by gapic-generator. DO NOT EDIT. +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. // Package asset is an auto-generated package for the // Cloud Asset API. // -// NOTE: This package is in alpha. It is not stable, and is likely to change. -// // The cloud asset API manages the history and inventory of cloud resources. // +// NOTE: This package is in alpha. It is not stable, and is likely to change. +// // Use of Context // // The ctx passed to NewClient is used for authentication requests and @@ -31,6 +31,7 @@ // // For information about setting deadlines, reusing contexts, and more // please visit godoc.org/cloud.google.com/go. + package asset // import "cloud.google.com/go/asset/apiv1" import ( @@ -42,6 +43,8 @@ import ( "google.golang.org/grpc/metadata" ) +const versionClient = "20191108" + func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) out = out.Copy() @@ -75,7 +78,7 @@ func versionGo() string { } notSemverRune := func(r rune) bool { - return strings.IndexRune("0123456789.", r) < 0 + return !strings.ContainsRune("0123456789.", r) } if strings.HasPrefix(s, "go1") { @@ -96,5 +99,3 @@ func versionGo() string { } return "UNKNOWN" } - -const versionClient = "20190911" diff --git a/vendor/cloud.google.com/go/asset/apiv1beta1/doc.go b/vendor/cloud.google.com/go/asset/apiv1beta1/doc.go index 6b93aeae4e..7715015d73 100644 --- a/vendor/cloud.google.com/go/asset/apiv1beta1/doc.go +++ b/vendor/cloud.google.com/go/asset/apiv1beta1/doc.go @@ -97,4 +97,4 @@ func versionGo() string { return "UNKNOWN" } -const versionClient = "20190911" +const versionClient = "UNKNOWN" diff --git a/vendor/cloud.google.com/go/asset/apiv1p2beta1/doc.go b/vendor/cloud.google.com/go/asset/apiv1p2beta1/doc.go index 034c1c4d93..d46f0afaeb 100644 --- a/vendor/cloud.google.com/go/asset/apiv1p2beta1/doc.go +++ b/vendor/cloud.google.com/go/asset/apiv1p2beta1/doc.go @@ -97,4 +97,4 @@ func versionGo() string { return "UNKNOWN" } -const versionClient = "20190911" +const versionClient = "UNKNOWN" diff --git a/vendor/cloud.google.com/go/automl/apiv1/auto_ml_client.go b/vendor/cloud.google.com/go/automl/apiv1/auto_ml_client.go new file mode 100644 index 0000000000..edde45b40d --- /dev/null +++ b/vendor/cloud.google.com/go/automl/apiv1/auto_ml_client.go @@ -0,0 +1,1273 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by gapic-generator. DO NOT EDIT. + +package automl + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + "github.com/golang/protobuf/proto" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + "google.golang.org/api/transport" + automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +// CallOptions contains the retry settings for each method of Client. +type CallOptions struct { + CreateDataset []gax.CallOption + UpdateDataset []gax.CallOption + GetDataset []gax.CallOption + ListDatasets []gax.CallOption + DeleteDataset []gax.CallOption + ImportData []gax.CallOption + ExportData []gax.CallOption + GetAnnotationSpec []gax.CallOption + CreateModel []gax.CallOption + GetModel []gax.CallOption + UpdateModel []gax.CallOption + ListModels []gax.CallOption + DeleteModel []gax.CallOption + DeployModel []gax.CallOption + UndeployModel []gax.CallOption + ExportModel []gax.CallOption + GetModelEvaluation []gax.CallOption + ListModelEvaluations []gax.CallOption +} + +func defaultClientOptions() []option.ClientOption { + return []option.ClientOption{ + option.WithEndpoint("automl.googleapis.com:443"), + option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultCallOptions() *CallOptions { + retry := map[[2]string][]gax.CallOption{ + {"default", "idempotent"}: { + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.3, + }) + }), + }, + } + return &CallOptions{ + CreateDataset: retry[[2]string{"default", "non_idempotent"}], + UpdateDataset: retry[[2]string{"default", "non_idempotent"}], + GetDataset: retry[[2]string{"default", "idempotent"}], + ListDatasets: retry[[2]string{"default", "idempotent"}], + DeleteDataset: retry[[2]string{"default", "idempotent"}], + ImportData: retry[[2]string{"default", "non_idempotent"}], + ExportData: retry[[2]string{"default", "non_idempotent"}], + GetAnnotationSpec: retry[[2]string{"default", "idempotent"}], + CreateModel: retry[[2]string{"default", "non_idempotent"}], + GetModel: retry[[2]string{"default", "idempotent"}], + UpdateModel: retry[[2]string{"default", "non_idempotent"}], + ListModels: retry[[2]string{"default", "idempotent"}], + DeleteModel: retry[[2]string{"default", "idempotent"}], + DeployModel: retry[[2]string{"default", "non_idempotent"}], + UndeployModel: retry[[2]string{"default", "non_idempotent"}], + ExportModel: retry[[2]string{"default", "non_idempotent"}], + GetModelEvaluation: retry[[2]string{"default", "idempotent"}], + ListModelEvaluations: retry[[2]string{"default", "idempotent"}], + } +} + +// Client is a client for interacting with Cloud AutoML API. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type Client struct { + // The connection to the service. + conn *grpc.ClientConn + + // The gRPC API client. + client automlpb.AutoMlClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *CallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewClient creates a new auto ml client. +// +// AutoML Server API. +// +// The resource names are assigned by the server. +// The server never reuses names that it has created after the resources with +// those names are deleted. +// +// An ID of a resource is the last element of the item's resource name. For +// projects/{project_id}/locations/{location_id}/datasets/{dataset_id}, then +// the id for the item is {dataset_id}. +// +// Currently the only supported location_id is "us-central1". +// +// On any input that is documented to expect a string parameter in +// snake_case or kebab-case, either of those cases is accepted. +func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { + conn, err := transport.DialGRPC(ctx, append(defaultClientOptions(), opts...)...) + if err != nil { + return nil, err + } + c := &Client{ + conn: conn, + CallOptions: defaultCallOptions(), + + client: automlpb.NewAutoMlClient(conn), + } + c.setGoogleClientInfo() + + c.LROClient, err = lroauto.NewOperationsClient(ctx, option.WithGRPCConn(conn)) + if err != nil { + // This error "should not happen", since we are just reusing old connection + // and never actually need to dial. + // If this does happen, we could leak conn. However, we cannot close conn: + // If the user invoked the function with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO(pongad): investigate error conditions. + return nil, err + } + return c, nil +} + +// Connection returns the client's connection to the API service. +func (c *Client) Connection() *grpc.ClientConn { + return c.conn +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *Client) Close() error { + return c.conn.Close() +} + +// setGoogleClientInfo sets the name and version of the application in +// the `x-goog-api-client` header passed on each request. Intended for +// use by Google-written clients. +func (c *Client) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// CreateDataset creates a dataset. +func (c *Client) CreateDataset(ctx context.Context, req *automlpb.CreateDatasetRequest, opts ...gax.CallOption) (*CreateDatasetOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateDataset[0:len(c.CallOptions.CreateDataset):len(c.CallOptions.CreateDataset)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.CreateDataset(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateDatasetOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UpdateDataset updates a dataset. +func (c *Client) UpdateDataset(ctx context.Context, req *automlpb.UpdateDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "dataset.name", url.QueryEscape(req.GetDataset().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateDataset[0:len(c.CallOptions.UpdateDataset):len(c.CallOptions.UpdateDataset)], opts...) + var resp *automlpb.Dataset + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateDataset(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetDataset gets a dataset. +func (c *Client) GetDataset(ctx context.Context, req *automlpb.GetDatasetRequest, opts ...gax.CallOption) (*automlpb.Dataset, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetDataset[0:len(c.CallOptions.GetDataset):len(c.CallOptions.GetDataset)], opts...) + var resp *automlpb.Dataset + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetDataset(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListDatasets lists datasets in a project. +func (c *Client) ListDatasets(ctx context.Context, req *automlpb.ListDatasetsRequest, opts ...gax.CallOption) *DatasetIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListDatasets[0:len(c.CallOptions.ListDatasets):len(c.CallOptions.ListDatasets)], opts...) + it := &DatasetIterator{} + req = proto.Clone(req).(*automlpb.ListDatasetsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.Dataset, string, error) { + var resp *automlpb.ListDatasetsResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListDatasets(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + return resp.Datasets, resp.NextPageToken, nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.PageSize) + it.pageInfo.Token = req.PageToken + return it +} + +// DeleteDataset deletes a dataset and all of its contents. +// Returns empty response in the +// [response][google.longrunning.Operation.response] field when it completes, +// and delete_details in the +// [metadata][google.longrunning.Operation.metadata] field. +func (c *Client) DeleteDataset(ctx context.Context, req *automlpb.DeleteDatasetRequest, opts ...gax.CallOption) (*DeleteDatasetOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteDataset[0:len(c.CallOptions.DeleteDataset):len(c.CallOptions.DeleteDataset)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.DeleteDataset(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteDatasetOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// ImportData imports data into a dataset. +func (c *Client) ImportData(ctx context.Context, req *automlpb.ImportDataRequest, opts ...gax.CallOption) (*ImportDataOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ImportData[0:len(c.CallOptions.ImportData):len(c.CallOptions.ImportData)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ImportData(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &ImportDataOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// ExportData exports dataset's data to the provided output location. +// Returns an empty response in the +// [response][google.longrunning.Operation.response] field when it completes. +func (c *Client) ExportData(ctx context.Context, req *automlpb.ExportDataRequest, opts ...gax.CallOption) (*ExportDataOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ExportData[0:len(c.CallOptions.ExportData):len(c.CallOptions.ExportData)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ExportData(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &ExportDataOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// GetAnnotationSpec gets an annotation spec. +func (c *Client) GetAnnotationSpec(ctx context.Context, req *automlpb.GetAnnotationSpecRequest, opts ...gax.CallOption) (*automlpb.AnnotationSpec, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetAnnotationSpec[0:len(c.CallOptions.GetAnnotationSpec):len(c.CallOptions.GetAnnotationSpec)], opts...) + var resp *automlpb.AnnotationSpec + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetAnnotationSpec(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateModel creates a model. +// Returns a Model in the [response][google.longrunning.Operation.response] +// field when it completes. +// When you create a model, several model evaluations are created for it: +// a global evaluation, and one evaluation for each annotation spec. +func (c *Client) CreateModel(ctx context.Context, req *automlpb.CreateModelRequest, opts ...gax.CallOption) (*CreateModelOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateModel[0:len(c.CallOptions.CreateModel):len(c.CallOptions.CreateModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.CreateModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// GetModel gets a model. +func (c *Client) GetModel(ctx context.Context, req *automlpb.GetModelRequest, opts ...gax.CallOption) (*automlpb.Model, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetModel[0:len(c.CallOptions.GetModel):len(c.CallOptions.GetModel)], opts...) + var resp *automlpb.Model + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateModel updates a model. +func (c *Client) UpdateModel(ctx context.Context, req *automlpb.UpdateModelRequest, opts ...gax.CallOption) (*automlpb.Model, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "model.name", url.QueryEscape(req.GetModel().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateModel[0:len(c.CallOptions.UpdateModel):len(c.CallOptions.UpdateModel)], opts...) + var resp *automlpb.Model + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListModels lists models. +func (c *Client) ListModels(ctx context.Context, req *automlpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListModels[0:len(c.CallOptions.ListModels):len(c.CallOptions.ListModels)], opts...) + it := &ModelIterator{} + req = proto.Clone(req).(*automlpb.ListModelsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.Model, string, error) { + var resp *automlpb.ListModelsResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListModels(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + return resp.Model, resp.NextPageToken, nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.PageSize) + it.pageInfo.Token = req.PageToken + return it +} + +// DeleteModel deletes a model. +// Returns google.protobuf.Empty in the +// [response][google.longrunning.Operation.response] field when it completes, +// and delete_details in the +// [metadata][google.longrunning.Operation.metadata] field. +func (c *Client) DeleteModel(ctx context.Context, req *automlpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteModel[0:len(c.CallOptions.DeleteModel):len(c.CallOptions.DeleteModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.DeleteModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeployModel deploys a model. If a model is already deployed, deploying it with the +// same parameters has no effect. Deploying with different parametrs +// (as e.g. changing +// +// [node_number][google.cloud.automl.v1.ImageObjectDetectionModelDeploymentMetadata.node_number]) +// will reset the deployment state without pausing the model's availability. +// +// Only applicable for Text Classification, Image Object Detection; all other +// domains manage deployment automatically. +// +// Returns an empty response in the +// [response][google.longrunning.Operation.response] field when it completes. +func (c *Client) DeployModel(ctx context.Context, req *automlpb.DeployModelRequest, opts ...gax.CallOption) (*DeployModelOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeployModel[0:len(c.CallOptions.DeployModel):len(c.CallOptions.DeployModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.DeployModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeployModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UndeployModel undeploys a model. If the model is not deployed this method has no effect. +// +// Only applicable for Text Classification, Image Object Detection; +// all other domains manage deployment automatically. +// +// Returns an empty response in the +// [response][google.longrunning.Operation.response] field when it completes. +func (c *Client) UndeployModel(ctx context.Context, req *automlpb.UndeployModelRequest, opts ...gax.CallOption) (*UndeployModelOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UndeployModel[0:len(c.CallOptions.UndeployModel):len(c.CallOptions.UndeployModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UndeployModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UndeployModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// ExportModel exports a trained, "export-able", model to a user specified Google Cloud +// Storage location. A model is considered export-able if and only if it has +// an export format defined for it in +// [ModelExportOutputConfig][google.cloud.automl.v1.ModelExportOutputConfig]. +// +// Returns an empty response in the +// [response][google.longrunning.Operation.response] field when it completes. +func (c *Client) ExportModel(ctx context.Context, req *automlpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ExportModel[0:len(c.CallOptions.ExportModel):len(c.CallOptions.ExportModel)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ExportModel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &ExportModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// GetModelEvaluation gets a model evaluation. +func (c *Client) GetModelEvaluation(ctx context.Context, req *automlpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*automlpb.ModelEvaluation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetModelEvaluation[0:len(c.CallOptions.GetModelEvaluation):len(c.CallOptions.GetModelEvaluation)], opts...) + var resp *automlpb.ModelEvaluation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetModelEvaluation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListModelEvaluations lists model evaluations. +func (c *Client) ListModelEvaluations(ctx context.Context, req *automlpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListModelEvaluations[0:len(c.CallOptions.ListModelEvaluations):len(c.CallOptions.ListModelEvaluations)], opts...) + it := &ModelEvaluationIterator{} + req = proto.Clone(req).(*automlpb.ListModelEvaluationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*automlpb.ModelEvaluation, string, error) { + var resp *automlpb.ListModelEvaluationsResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListModelEvaluations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + return resp.ModelEvaluation, resp.NextPageToken, nil + } + fetch := func(pageSize int, pageToken string) (string, error) { + items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) + if err != nil { + return "", err + } + it.items = append(it.items, items...) + return nextPageToken, nil + } + it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) + it.pageInfo.MaxSize = int(req.PageSize) + it.pageInfo.Token = req.PageToken + return it +} + +// DatasetIterator manages a stream of *automlpb.Dataset. +type DatasetIterator struct { + items []*automlpb.Dataset + pageInfo *iterator.PageInfo + nextFunc func() error + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*automlpb.Dataset, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *DatasetIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *DatasetIterator) Next() (*automlpb.Dataset, error) { + var item *automlpb.Dataset + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *DatasetIterator) bufLen() int { + return len(it.items) +} + +func (it *DatasetIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// ModelEvaluationIterator manages a stream of *automlpb.ModelEvaluation. +type ModelEvaluationIterator struct { + items []*automlpb.ModelEvaluation + pageInfo *iterator.PageInfo + nextFunc func() error + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*automlpb.ModelEvaluation, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ModelEvaluationIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *ModelEvaluationIterator) Next() (*automlpb.ModelEvaluation, error) { + var item *automlpb.ModelEvaluation + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ModelEvaluationIterator) bufLen() int { + return len(it.items) +} + +func (it *ModelEvaluationIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// ModelIterator manages a stream of *automlpb.Model. +type ModelIterator struct { + items []*automlpb.Model + pageInfo *iterator.PageInfo + nextFunc func() error + + // InternalFetch is for use by the Google Cloud Libraries only. + // It is not part of the stable interface of this package. + // + // InternalFetch returns results from a single call to the underlying RPC. + // The number of results is no greater than pageSize. + // If there are no more results, nextPageToken is empty and err is nil. + InternalFetch func(pageSize int, pageToken string) (results []*automlpb.Model, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ModelIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// Next returns the next result. Its second return value is iterator.Done if there are no more +// results. Once Next returns Done, all subsequent calls will return Done. +func (it *ModelIterator) Next() (*automlpb.Model, error) { + var item *automlpb.Model + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ModelIterator) bufLen() int { + return len(it.items) +} + +func (it *ModelIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// CreateDatasetOperation manages a long-running operation from CreateDataset. +type CreateDatasetOperation struct { + lro *longrunning.Operation +} + +// CreateDatasetOperation returns a new CreateDatasetOperation from a given name. +// The name must be that of a previously created CreateDatasetOperation, possibly from a different process. +func (c *Client) CreateDatasetOperation(name string) *CreateDatasetOperation { + return &CreateDatasetOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*automlpb.Dataset, error) { + var resp automlpb.Dataset + if err := op.lro.WaitWithInterval(ctx, &resp, 5000*time.Millisecond, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*automlpb.Dataset, error) { + var resp automlpb.Dataset + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateDatasetOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateDatasetOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateDatasetOperation) Name() string { + return op.lro.Name() +} + +// CreateModelOperation manages a long-running operation from CreateModel. +type CreateModelOperation struct { + lro *longrunning.Operation +} + +// CreateModelOperation returns a new CreateModelOperation from a given name. +// The name must be that of a previously created CreateModelOperation, possibly from a different process. +func (c *Client) CreateModelOperation(name string) *CreateModelOperation { + return &CreateModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*automlpb.Model, error) { + var resp automlpb.Model + if err := op.lro.WaitWithInterval(ctx, &resp, 5000*time.Millisecond, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*automlpb.Model, error) { + var resp automlpb.Model + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateModelOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateModelOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateModelOperation) Name() string { + return op.lro.Name() +} + +// DeleteDatasetOperation manages a long-running operation from DeleteDataset. +type DeleteDatasetOperation struct { + lro *longrunning.Operation +} + +// DeleteDatasetOperation returns a new DeleteDatasetOperation from a given name. +// The name must be that of a previously created DeleteDatasetOperation, possibly from a different process. +func (c *Client) DeleteDatasetOperation(name string) *DeleteDatasetOperation { + return &DeleteDatasetOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning any error encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteDatasetOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, 5000*time.Millisecond, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, op.Done will return true. +func (op *DeleteDatasetOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteDatasetOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteDatasetOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteDatasetOperation) Name() string { + return op.lro.Name() +} + +// DeleteModelOperation manages a long-running operation from DeleteModel. +type DeleteModelOperation struct { + lro *longrunning.Operation +} + +// DeleteModelOperation returns a new DeleteModelOperation from a given name. +// The name must be that of a previously created DeleteModelOperation, possibly from a different process. +func (c *Client) DeleteModelOperation(name string) *DeleteModelOperation { + return &DeleteModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning any error encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, 5000*time.Millisecond, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, op.Done will return true. +func (op *DeleteModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteModelOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteModelOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteModelOperation) Name() string { + return op.lro.Name() +} + +// DeployModelOperation manages a long-running operation from DeployModel. +type DeployModelOperation struct { + lro *longrunning.Operation +} + +// DeployModelOperation returns a new DeployModelOperation from a given name. +// The name must be that of a previously created DeployModelOperation, possibly from a different process. +func (c *Client) DeployModelOperation(name string) *DeployModelOperation { + return &DeployModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning any error encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeployModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, 5000*time.Millisecond, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, op.Done will return true. +func (op *DeployModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeployModelOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeployModelOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeployModelOperation) Name() string { + return op.lro.Name() +} + +// ExportDataOperation manages a long-running operation from ExportData. +type ExportDataOperation struct { + lro *longrunning.Operation +} + +// ExportDataOperation returns a new ExportDataOperation from a given name. +// The name must be that of a previously created ExportDataOperation, possibly from a different process. +func (c *Client) ExportDataOperation(name string) *ExportDataOperation { + return &ExportDataOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning any error encountered. +// +// See documentation of Poll for error-handling information. +func (op *ExportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, 5000*time.Millisecond, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, op.Done will return true. +func (op *ExportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *ExportDataOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *ExportDataOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *ExportDataOperation) Name() string { + return op.lro.Name() +} + +// ExportModelOperation manages a long-running operation from ExportModel. +type ExportModelOperation struct { + lro *longrunning.Operation +} + +// ExportModelOperation returns a new ExportModelOperation from a given name. +// The name must be that of a previously created ExportModelOperation, possibly from a different process. +func (c *Client) ExportModelOperation(name string) *ExportModelOperation { + return &ExportModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning any error encountered. +// +// See documentation of Poll for error-handling information. +func (op *ExportModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, 5000*time.Millisecond, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, op.Done will return true. +func (op *ExportModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *ExportModelOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *ExportModelOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *ExportModelOperation) Name() string { + return op.lro.Name() +} + +// ImportDataOperation manages a long-running operation from ImportData. +type ImportDataOperation struct { + lro *longrunning.Operation +} + +// ImportDataOperation returns a new ImportDataOperation from a given name. +// The name must be that of a previously created ImportDataOperation, possibly from a different process. +func (c *Client) ImportDataOperation(name string) *ImportDataOperation { + return &ImportDataOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning any error encountered. +// +// See documentation of Poll for error-handling information. +func (op *ImportDataOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, 5000*time.Millisecond, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, op.Done will return true. +func (op *ImportDataOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *ImportDataOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *ImportDataOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *ImportDataOperation) Name() string { + return op.lro.Name() +} + +// UndeployModelOperation manages a long-running operation from UndeployModel. +type UndeployModelOperation struct { + lro *longrunning.Operation +} + +// UndeployModelOperation returns a new UndeployModelOperation from a given name. +// The name must be that of a previously created UndeployModelOperation, possibly from a different process. +func (c *Client) UndeployModelOperation(name string) *UndeployModelOperation { + return &UndeployModelOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning any error encountered. +// +// See documentation of Poll for error-handling information. +func (op *UndeployModelOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, 5000*time.Millisecond, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, op.Done will return true. +func (op *UndeployModelOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UndeployModelOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UndeployModelOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UndeployModelOperation) Name() string { + return op.lro.Name() +} diff --git a/vendor/cloud.google.com/go/automl/apiv1/doc.go b/vendor/cloud.google.com/go/automl/apiv1/doc.go new file mode 100644 index 0000000000..4f9017a987 --- /dev/null +++ b/vendor/cloud.google.com/go/automl/apiv1/doc.go @@ -0,0 +1,100 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by gapic-generator. DO NOT EDIT. + +// Package automl is an auto-generated package for the +// Cloud AutoML API. + +// +// Train high-quality custom machine learning models with minimum effort and +// machine learning expertise. +// +// Use of Context +// +// The ctx passed to NewClient is used for authentication requests and +// for creating the underlying connection, but is not used for subsequent calls. +// Individual methods on the client use the ctx given to them. +// +// To close the open connection, use the Close() method. +// +// For information about setting deadlines, reusing contexts, and more +// please visit godoc.org/cloud.google.com/go. +package automl // import "cloud.google.com/go/automl/apiv1" + +import ( + "context" + "runtime" + "strings" + "unicode" + + "google.golang.org/grpc/metadata" +) + +func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { + out, _ := metadata.FromOutgoingContext(ctx) + out = out.Copy() + for _, md := range mds { + for k, v := range md { + out[k] = append(out[k], v...) + } + } + return metadata.NewOutgoingContext(ctx, out) +} + +// DefaultAuthScopes reports the default set of authentication scopes to use with this package. +func DefaultAuthScopes() []string { + return []string{ + "https://www.googleapis.com/auth/cloud-platform", + } +} + +// versionGo returns the Go runtime version. The returned string +// has no whitespace, suitable for reporting in header. +func versionGo() string { + const develPrefix = "devel +" + + s := runtime.Version() + if strings.HasPrefix(s, develPrefix) { + s = s[len(develPrefix):] + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + return s + } + + notSemverRune := func(r rune) bool { + return strings.IndexRune("0123456789.", r) < 0 + } + + if strings.HasPrefix(s, "go1") { + s = s[2:] + var prerelease string + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { + s, prerelease = s[:p], s[p:] + } + if strings.HasSuffix(s, ".") { + s += "0" + } else if strings.Count(s, ".") < 2 { + s += ".0" + } + if prerelease != "" { + s += "-" + prerelease + } + return s + } + return "UNKNOWN" +} + +const versionClient = "20191108" diff --git a/vendor/cloud.google.com/go/automl/apiv1/prediction_client.go b/vendor/cloud.google.com/go/automl/apiv1/prediction_client.go new file mode 100644 index 0000000000..77bfe9f704 --- /dev/null +++ b/vendor/cloud.google.com/go/automl/apiv1/prediction_client.go @@ -0,0 +1,271 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by gapic-generator. DO NOT EDIT. + +package automl + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/option" + "google.golang.org/api/transport" + automlpb "google.golang.org/genproto/googleapis/cloud/automl/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +// PredictionCallOptions contains the retry settings for each method of PredictionClient. +type PredictionCallOptions struct { + Predict []gax.CallOption + BatchPredict []gax.CallOption +} + +func defaultPredictionClientOptions() []option.ClientOption { + return []option.ClientOption{ + option.WithEndpoint("automl.googleapis.com:443"), + option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultPredictionCallOptions() *PredictionCallOptions { + retry := map[[2]string][]gax.CallOption{} + return &PredictionCallOptions{ + Predict: retry[[2]string{"default", "non_idempotent"}], + BatchPredict: retry[[2]string{"default", "non_idempotent"}], + } +} + +// PredictionClient is a client for interacting with Cloud AutoML API. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type PredictionClient struct { + // The connection to the service. + conn *grpc.ClientConn + + // The gRPC API client. + predictionClient automlpb.PredictionServiceClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *PredictionCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewPredictionClient creates a new prediction service client. +// +// AutoML Prediction API. +// +// On any input that is documented to expect a string parameter in +// snake_case or kebab-case, either of those cases is accepted. +func NewPredictionClient(ctx context.Context, opts ...option.ClientOption) (*PredictionClient, error) { + conn, err := transport.DialGRPC(ctx, append(defaultPredictionClientOptions(), opts...)...) + if err != nil { + return nil, err + } + c := &PredictionClient{ + conn: conn, + CallOptions: defaultPredictionCallOptions(), + + predictionClient: automlpb.NewPredictionServiceClient(conn), + } + c.setGoogleClientInfo() + + c.LROClient, err = lroauto.NewOperationsClient(ctx, option.WithGRPCConn(conn)) + if err != nil { + // This error "should not happen", since we are just reusing old connection + // and never actually need to dial. + // If this does happen, we could leak conn. However, we cannot close conn: + // If the user invoked the function with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO(pongad): investigate error conditions. + return nil, err + } + return c, nil +} + +// Connection returns the client's connection to the API service. +func (c *PredictionClient) Connection() *grpc.ClientConn { + return c.conn +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *PredictionClient) Close() error { + return c.conn.Close() +} + +// setGoogleClientInfo sets the name and version of the application in +// the `x-goog-api-client` header passed on each request. Intended for +// use by Google-written clients. +func (c *PredictionClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Predict perform an online prediction. The prediction result will be directly +// returned in the response. +// Available for following ML problems, and their expected request payloads: +// +// Image Classification - Image in .JPEG, .GIF or .PNG format, image_bytes +// up to 30MB. +// +// Image Object Detection - Image in .JPEG, .GIF or .PNG format, image_bytes +// up to 30MB. +// +// Text Classification - TextSnippet, content up to 60,000 characters, +// UTF-8 encoded. +// +// Text Extraction - TextSnippet, content up to 30,000 characters, +// UTF-8 NFC encoded. +// +// Translation - TextSnippet, content up to 25,000 characters, UTF-8 +// encoded. +// +// Text Sentiment - TextSnippet, content up 500 characters, UTF-8 +// encoded. +func (c *PredictionClient) Predict(ctx context.Context, req *automlpb.PredictRequest, opts ...gax.CallOption) (*automlpb.PredictResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.Predict[0:len(c.CallOptions.Predict):len(c.CallOptions.Predict)], opts...) + var resp *automlpb.PredictResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.predictionClient.Predict(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// BatchPredict perform a batch prediction. Unlike the online +// [Predict][google.cloud.automl.v1.PredictionService.Predict], batch +// prediction result won't be immediately available in the response. Instead, +// a long running operation object is returned. User can poll the operation +// result via [GetOperation][google.longrunning.Operations.GetOperation] +// method. Once the operation is done, +// [BatchPredictResult][google.cloud.automl.v1.BatchPredictResult] is returned +// in the [response][google.longrunning.Operation.response] field. Available +// for following ML problems: +// +// Image Classification +// +// Image Object Detection +// +// Text Extraction +func (c *PredictionClient) BatchPredict(ctx context.Context, req *automlpb.BatchPredictRequest, opts ...gax.CallOption) (*BatchPredictOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.BatchPredict[0:len(c.CallOptions.BatchPredict):len(c.CallOptions.BatchPredict)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.predictionClient.BatchPredict(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &BatchPredictOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// BatchPredictOperation manages a long-running operation from BatchPredict. +type BatchPredictOperation struct { + lro *longrunning.Operation +} + +// BatchPredictOperation returns a new BatchPredictOperation from a given name. +// The name must be that of a previously created BatchPredictOperation, possibly from a different process. +func (c *PredictionClient) BatchPredictOperation(name string) *BatchPredictOperation { + return &BatchPredictOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *BatchPredictOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*automlpb.BatchPredictResult, error) { + var resp automlpb.BatchPredictResult + if err := op.lro.WaitWithInterval(ctx, &resp, 5000*time.Millisecond, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *BatchPredictOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*automlpb.BatchPredictResult, error) { + var resp automlpb.BatchPredictResult + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *BatchPredictOperation) Metadata() (*automlpb.OperationMetadata, error) { + var meta automlpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *BatchPredictOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *BatchPredictOperation) Name() string { + return op.lro.Name() +} diff --git a/vendor/cloud.google.com/go/automl/apiv1beta1/doc.go b/vendor/cloud.google.com/go/automl/apiv1beta1/doc.go index a50e60ab88..a38fdce0ea 100644 --- a/vendor/cloud.google.com/go/automl/apiv1beta1/doc.go +++ b/vendor/cloud.google.com/go/automl/apiv1beta1/doc.go @@ -98,4 +98,4 @@ func versionGo() string { return "UNKNOWN" } -const versionClient = "20190911" +const versionClient = "UNKNOWN" diff --git a/vendor/cloud.google.com/go/bigquery/bigquery.go b/vendor/cloud.google.com/go/bigquery/bigquery.go index 02ee0c77fb..e7afedc4a2 100644 --- a/vendor/cloud.google.com/go/bigquery/bigquery.go +++ b/vendor/cloud.google.com/go/bigquery/bigquery.go @@ -27,14 +27,14 @@ import ( bq "google.golang.org/api/bigquery/v2" "google.golang.org/api/googleapi" "google.golang.org/api/option" - htransport "google.golang.org/api/transport/http" ) const ( - prodAddr = "https://www.googleapis.com/bigquery/v2/" // Scope is the Oauth2 scope for the service. - Scope = "https://www.googleapis.com/auth/bigquery" - userAgent = "gcloud-golang-bigquery/20160429" + // For relevant BigQuery scopes, see: + // https://developers.google.com/identity/protocols/googlescopes#bigqueryv2 + Scope = "https://www.googleapis.com/auth/bigquery" + userAgentPrefix = "gcloud-golang-bigquery" ) var xGoogHeader = fmt.Sprintf("gl-go/%s gccl/%s", version.Go(), version.Repo) @@ -58,20 +58,14 @@ type Client struct { // Operations performed via the client are billed to the specified GCP project. func NewClient(ctx context.Context, projectID string, opts ...option.ClientOption) (*Client, error) { o := []option.ClientOption{ - option.WithEndpoint(prodAddr), option.WithScopes(Scope), - option.WithUserAgent(userAgent), + option.WithUserAgent(fmt.Sprintf("%s/%s", userAgentPrefix, version.Repo)), } o = append(o, opts...) - httpClient, endpoint, err := htransport.NewClient(ctx, o...) - if err != nil { - return nil, fmt.Errorf("bigquery: dialing: %v", err) - } - bqs, err := bq.New(httpClient) + bqs, err := bq.NewService(ctx, o...) if err != nil { return nil, fmt.Errorf("bigquery: constructing client: %v", err) } - bqs.BasePath = endpoint c := &Client{ projectID: projectID, bqs: bqs, diff --git a/vendor/cloud.google.com/go/bigquery/dataset.go b/vendor/cloud.google.com/go/bigquery/dataset.go index 5ee2277d84..13f6403963 100644 --- a/vendor/cloud.google.com/go/bigquery/dataset.go +++ b/vendor/cloud.google.com/go/bigquery/dataset.go @@ -36,12 +36,13 @@ type Dataset struct { // DatasetMetadata contains information about a BigQuery dataset. type DatasetMetadata struct { // These fields can be set when creating a dataset. - Name string // The user-friendly name for this dataset. - Description string // The user-friendly description of this dataset. - Location string // The geo location of the dataset. - DefaultTableExpiration time.Duration // The default expiration time for new tables. - Labels map[string]string // User-provided labels. - Access []*AccessEntry // Access permissions. + Name string // The user-friendly name for this dataset. + Description string // The user-friendly description of this dataset. + Location string // The geo location of the dataset. + DefaultTableExpiration time.Duration // The default expiration time for new tables. + Labels map[string]string // User-provided labels. + Access []*AccessEntry // Access permissions. + DefaultEncryptionConfig *EncryptionConfig // These fields are read-only. CreationTime time.Time @@ -63,6 +64,10 @@ type DatasetMetadataToUpdate struct { // If set to time.Duration(0), new tables never expire. DefaultTableExpiration optional.Duration + // DefaultEncryptionConfig defines CMEK settings for new resources created + // in the dataset. + DefaultEncryptionConfig *EncryptionConfig + // The entire access list. It is not possible to replace individual entries. Access []*AccessEntry @@ -131,6 +136,9 @@ func (dm *DatasetMetadata) toBQ() (*bq.Dataset, error) { if dm.ETag != "" { return nil, errors.New("bigquery: Dataset.ETag is not writable") } + if dm.DefaultEncryptionConfig != nil { + ds.DefaultEncryptionConfiguration = dm.DefaultEncryptionConfig.toBQ() + } return ds, nil } @@ -184,15 +192,16 @@ func (d *Dataset) Metadata(ctx context.Context) (md *DatasetMetadata, err error) func bqToDatasetMetadata(d *bq.Dataset) (*DatasetMetadata, error) { dm := &DatasetMetadata{ - CreationTime: unixMillisToTime(d.CreationTime), - LastModifiedTime: unixMillisToTime(d.LastModifiedTime), - DefaultTableExpiration: time.Duration(d.DefaultTableExpirationMs) * time.Millisecond, - Description: d.Description, - Name: d.FriendlyName, - FullID: d.Id, - Location: d.Location, - Labels: d.Labels, - ETag: d.Etag, + CreationTime: unixMillisToTime(d.CreationTime), + LastModifiedTime: unixMillisToTime(d.LastModifiedTime), + DefaultTableExpiration: time.Duration(d.DefaultTableExpirationMs) * time.Millisecond, + DefaultEncryptionConfig: bqToEncryptionConfig(d.DefaultEncryptionConfiguration), + Description: d.Description, + Name: d.FriendlyName, + FullID: d.Id, + Location: d.Location, + Labels: d.Labels, + ETag: d.Etag, } for _, a := range d.Access { e, err := bqToAccessEntry(a, nil) @@ -254,6 +263,10 @@ func (dm *DatasetMetadataToUpdate) toBQ() (*bq.Dataset, error) { ds.DefaultTableExpirationMs = int64(dur / time.Millisecond) } } + if dm.DefaultEncryptionConfig != nil { + ds.DefaultEncryptionConfiguration = dm.DefaultEncryptionConfig.toBQ() + ds.DefaultEncryptionConfiguration.ForceSendFields = []string{"KmsKeyName"} + } if dm.Access != nil { var err error ds.Access, err = accessListToBQ(dm.Access) diff --git a/vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/doc.go b/vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/doc.go index 99171d4553..42868f4202 100644 --- a/vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/doc.go +++ b/vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/doc.go @@ -19,8 +19,9 @@ // // NOTE: This package is in alpha. It is not stable, and is likely to change. // -// Transfers data from partner SaaS applications to Google BigQuery on a -// scheduled, managed basis. +// Schedule queries or transfer external data from SaaS applications to +// Google +// BigQuery on a regular basis. // // Use of Context // @@ -98,4 +99,4 @@ func versionGo() string { return "UNKNOWN" } -const versionClient = "20190911" +const versionClient = "UNKNOWN" diff --git a/vendor/cloud.google.com/go/bigquery/inserter.go b/vendor/cloud.google.com/go/bigquery/inserter.go index 2a12bb35ac..789cd00fcf 100644 --- a/vendor/cloud.google.com/go/bigquery/inserter.go +++ b/vendor/cloud.google.com/go/bigquery/inserter.go @@ -24,6 +24,11 @@ import ( bq "google.golang.org/api/bigquery/v2" ) +// NoDedupeID indicates a streaming insert row wants to opt out of best-effort +// deduplication. +// It is EXPERIMENTAL and subject to change or removal without notice. +const NoDedupeID = "NoDedupeID" + // An Inserter does streaming inserts into a BigQuery table. // It is safe for concurrent use. type Inserter struct { @@ -200,7 +205,9 @@ func (u *Inserter) newInsertRequest(savers []ValueSaver) (*bq.TableDataInsertAll if err != nil { return nil, err } - if insertID == "" { + if insertID == NoDedupeID { + insertID = "" + } else if insertID == "" { insertID = randomIDFn() } m := make(map[string]bq.JsonValue) diff --git a/vendor/cloud.google.com/go/bigquery/job.go b/vendor/cloud.google.com/go/bigquery/job.go index 4eb4fec6ef..6a519733ef 100644 --- a/vendor/cloud.google.com/go/bigquery/job.go +++ b/vendor/cloud.google.com/go/bigquery/job.go @@ -122,6 +122,15 @@ func (j *Job) Config() (JobConfig, error) { return bqToJobConfig(j.config, j.c) } +// Children returns a job iterator for enumerating child jobs +// of the current job. Currently only scripts, a form of query job, +// will create child jobs. +func (j *Job) Children(ctx context.Context) *JobIterator { + it := j.c.Jobs(ctx) + it.ParentJobID = j.ID() + return it +} + func bqToJobConfig(q *bq.JobConfiguration, c *Client) (JobConfig, error) { switch { case q == nil: @@ -289,9 +298,6 @@ func (j *Job) read(ctx context.Context, waitForQuery func(context.Context, strin return nil, errors.New("bigquery: query job missing destination table") } dt := bqToTable(destTable, j.c) - if totalRows == 0 { - pf = nil - } it := newRowIterator(ctx, dt, pf) it.Schema = schema it.TotalRows = totalRows @@ -334,6 +340,16 @@ type JobStatistics struct { TotalBytesProcessed int64 Details Statistics + + // NumChildJobs indicates the number of child jobs run as part of a script. + NumChildJobs int64 + + // ParentJobID indicates the origin job for jobs run as part of a script. + ParentJobID string + + // ScriptStatistics includes information run as part of a child job within + // a script. + ScriptStatistics *ScriptStatistics } // Statistics is one of ExtractStatistics, LoadStatistics or QueryStatistics. @@ -548,6 +564,66 @@ type QueryTimelineSample struct { SlotMillis int64 } +// ScriptStatistics report information about script-based query jobs. +type ScriptStatistics struct { + EvaluationKind string + StackFrames []*ScriptStackFrame +} + +func bqToScriptStatistics(bs *bq.ScriptStatistics) *ScriptStatistics { + if bs == nil { + return nil + } + ss := &ScriptStatistics{ + EvaluationKind: bs.EvaluationKind, + } + for _, f := range bs.StackFrames { + ss.StackFrames = append(ss.StackFrames, bqToScriptStackFrame(f)) + } + return ss +} + +// ScriptStackFrame represents the location of the statement/expression being evaluated. +// +// Line and column numbers are defined as follows: +// +// - Line and column numbers start with one. That is, line 1 column 1 denotes +// the start of the script. +// - When inside a stored procedure, all line/column numbers are relative +// to the procedure body, not the script in which the procedure was defined. +// - Start/end positions exclude leading/trailing comments and whitespace. +// The end position always ends with a ";", when present. +// - Multi-byte Unicode characters are treated as just one column. +// - If the original script (or procedure definition) contains TAB characters, +// a tab "snaps" the indentation forward to the nearest multiple of 8 +// characters, plus 1. For example, a TAB on column 1, 2, 3, 4, 5, 6 , or 8 +// will advance the next character to column 9. A TAB on column 9, 10, 11, +// 12, 13, 14, 15, or 16 will advance the next character to column 17. +type ScriptStackFrame struct { + StartLine int64 + StartColumn int64 + EndLine int64 + EndColumn int64 + // Name of the active procedure. Empty if in a top-level script. + ProcedureID string + // Text of the current statement/expression. + Text string +} + +func bqToScriptStackFrame(bsf *bq.ScriptStackFrame) *ScriptStackFrame { + if bsf == nil { + return nil + } + return &ScriptStackFrame{ + StartLine: bsf.StartLine, + StartColumn: bsf.StartColumn, + EndLine: bsf.EndLine, + EndColumn: bsf.EndColumn, + ProcedureID: bsf.ProcedureId, + Text: bsf.Text, + } +} + func (*ExtractStatistics) implementsStatistics() {} func (*LoadStatistics) implementsStatistics() {} func (*QueryStatistics) implementsStatistics() {} @@ -573,6 +649,7 @@ type JobIterator struct { State State // List only jobs in the given state. Defaults to all states. MinCreationTime time.Time // List only jobs created after this time. MaxCreationTime time.Time // List only jobs created before this time. + ParentJobID string // List only jobs that are children of a given scripting job. ctx context.Context c *Client @@ -629,6 +706,9 @@ func (it *JobIterator) fetch(pageSize int, pageToken string) (string, error) { if pageSize > 0 { req.MaxResults(int64(pageSize)) } + if it.ParentJobID != "" { + req.ParentJobId(it.ParentJobID) + } res, err := req.Do() if err != nil { return "", err @@ -730,6 +810,9 @@ func (j *Job) setStatistics(s *bq.JobStatistics, c *Client) { StartTime: unixMillisToTime(s.StartTime), EndTime: unixMillisToTime(s.EndTime), TotalBytesProcessed: s.TotalBytesProcessed, + NumChildJobs: s.NumChildJobs, + ParentJobID: s.ParentJobId, + ScriptStatistics: bqToScriptStatistics(s.ScriptStatistics), } switch { case s.Extract != nil: diff --git a/vendor/cloud.google.com/go/bigquery/load.go b/vendor/cloud.google.com/go/bigquery/load.go index b275707c35..26d49785a0 100644 --- a/vendor/cloud.google.com/go/bigquery/load.go +++ b/vendor/cloud.google.com/go/bigquery/load.go @@ -44,6 +44,9 @@ type LoadConfig struct { // If non-nil, the destination table is partitioned by time. TimePartitioning *TimePartitioning + // If non-nil, the destination table is partitioned by integer range. + RangePartitioning *RangePartitioning + // Clustering specifies the data clustering configuration for the destination table. Clustering *Clustering @@ -68,6 +71,7 @@ func (l *LoadConfig) toBQ() (*bq.JobConfiguration, io.Reader) { WriteDisposition: string(l.WriteDisposition), DestinationTable: l.Dst.toBQ(), TimePartitioning: l.TimePartitioning.toBQ(), + RangePartitioning: l.RangePartitioning.toBQ(), Clustering: l.Clustering.toBQ(), DestinationEncryptionConfiguration: l.DestinationEncryptionConfig.toBQ(), SchemaUpdateOptions: l.SchemaUpdateOptions, @@ -85,6 +89,7 @@ func bqToLoadConfig(q *bq.JobConfiguration, c *Client) *LoadConfig { WriteDisposition: TableWriteDisposition(q.Load.WriteDisposition), Dst: bqToTable(q.Load.DestinationTable, c), TimePartitioning: bqToTimePartitioning(q.Load.TimePartitioning), + RangePartitioning: bqToRangePartitioning(q.Load.RangePartitioning), Clustering: bqToClustering(q.Load.Clustering), DestinationEncryptionConfig: bqToEncryptionConfig(q.Load.DestinationEncryptionConfiguration), SchemaUpdateOptions: q.Load.SchemaUpdateOptions, diff --git a/vendor/cloud.google.com/go/bigquery/query.go b/vendor/cloud.google.com/go/bigquery/query.go index 735a54c453..39c1df0227 100644 --- a/vendor/cloud.google.com/go/bigquery/query.go +++ b/vendor/cloud.google.com/go/bigquery/query.go @@ -105,6 +105,10 @@ type QueryConfig struct { // for the destination table. TimePartitioning *TimePartitioning + // RangePartitioning specifies integer range-based partitioning + // for the destination table. + RangePartitioning *RangePartitioning + // Clustering specifies the data clustering configuration for the destination table. Clustering *Clustering @@ -137,6 +141,7 @@ func (qc *QueryConfig) toBQ() (*bq.JobConfiguration, error) { Priority: string(qc.Priority), MaximumBytesBilled: qc.MaxBytesBilled, TimePartitioning: qc.TimePartitioning.toBQ(), + RangePartitioning: qc.RangePartitioning.toBQ(), Clustering: qc.Clustering.toBQ(), DestinationEncryptionConfiguration: qc.DestinationEncryptionConfig.toBQ(), SchemaUpdateOptions: qc.SchemaUpdateOptions, @@ -208,6 +213,7 @@ func bqToQueryConfig(q *bq.JobConfiguration, c *Client) (*QueryConfig, error) { MaxBytesBilled: qq.MaximumBytesBilled, UseLegacySQL: qq.UseLegacySql == nil || *qq.UseLegacySql, TimePartitioning: bqToTimePartitioning(qq.TimePartitioning), + RangePartitioning: bqToRangePartitioning(qq.RangePartitioning), Clustering: bqToClustering(qq.Clustering), DestinationEncryptionConfig: bqToEncryptionConfig(qq.DestinationEncryptionConfiguration), SchemaUpdateOptions: qq.SchemaUpdateOptions, diff --git a/vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/doc.go b/vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/doc.go index 636c5af51e..20ce06b042 100644 --- a/vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/doc.go +++ b/vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/doc.go @@ -56,6 +56,7 @@ func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { func DefaultAuthScopes() []string { return []string{ "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/bigquery.readonly", "https://www.googleapis.com/auth/cloud-platform", } } @@ -97,4 +98,4 @@ func versionGo() string { return "UNKNOWN" } -const versionClient = "20190911" +const versionClient = "UNKNOWN" diff --git a/vendor/cloud.google.com/go/bigquery/table.go b/vendor/cloud.google.com/go/bigquery/table.go index 2eb5843e44..dcea1d3d88 100644 --- a/vendor/cloud.google.com/go/bigquery/table.go +++ b/vendor/cloud.google.com/go/bigquery/table.go @@ -63,9 +63,14 @@ type TableMetadata struct { // Deprecated: use UseLegacySQL. UseStandardSQL bool - // If non-nil, the table is partitioned by time. + // If non-nil, the table is partitioned by time. Only one of + // time partitioning or range partitioning can be specified. TimePartitioning *TimePartitioning + // It non-nil, the table is partitioned by integer range. Only one of + // time partitioning or range partitioning can be specified. + RangePartitioning *RangePartitioning + // If set to true, queries that reference this table must specify a // partition filter (e.g. a WHERE clause) that can be used to eliminate // partitions. Used to prevent unintentional full data scans on large @@ -208,6 +213,68 @@ func bqToTimePartitioning(q *bq.TimePartitioning) *TimePartitioning { } } +// RangePartitioning indicates an integer-range based storage organization strategy. +type RangePartitioning struct { + // The field by which the table is partitioned. + // This field must be a top-level field, and must be typed as an + // INTEGER/INT64. + Field string + // The details of how partitions are mapped onto the integer range. + Range *RangePartitioningRange +} + +// RangePartitioningRange defines the boundaries and width of partitioned values. +type RangePartitioningRange struct { + // The start value of defined range of values, inclusive of the specified value. + Start int64 + // The end of the defined range of values, exclusive of the defined value. + End int64 + // The width of each interval range. + Interval int64 +} + +func (rp *RangePartitioning) toBQ() *bq.RangePartitioning { + if rp == nil { + return nil + } + return &bq.RangePartitioning{ + Field: rp.Field, + Range: rp.Range.toBQ(), + } +} + +func bqToRangePartitioning(q *bq.RangePartitioning) *RangePartitioning { + if q == nil { + return nil + } + return &RangePartitioning{ + Field: q.Field, + Range: bqToRangePartitioningRange(q.Range), + } +} + +func bqToRangePartitioningRange(br *bq.RangePartitioningRange) *RangePartitioningRange { + if br == nil { + return nil + } + return &RangePartitioningRange{ + Start: br.Start, + End: br.End, + Interval: br.Interval, + } +} + +func (rpr *RangePartitioningRange) toBQ() *bq.RangePartitioningRange { + if rpr == nil { + return nil + } + return &bq.RangePartitioningRange{ + Start: rpr.Start, + End: rpr.End, + Interval: rpr.Interval, + } +} + // Clustering governs the organization of data within a partitioned table. // For more information, see https://cloud.google.com/bigquery/docs/clustered-tables type Clustering struct { @@ -344,6 +411,7 @@ func (tm *TableMetadata) toBQ() (*bq.Table, error) { return nil, errors.New("bigquery: UseLegacy/StandardSQL requires ViewQuery") } t.TimePartitioning = tm.TimePartitioning.toBQ() + t.RangePartitioning = tm.RangePartitioning.toBQ() t.Clustering = tm.Clustering.toBQ() t.RequirePartitionFilter = tm.RequirePartitionFilter @@ -432,6 +500,7 @@ func bqToTableMetadata(t *bq.Table) (*TableMetadata, error) { md.UseLegacySQL = t.View.UseLegacySql } md.TimePartitioning = bqToTimePartitioning(t.TimePartitioning) + md.RangePartitioning = bqToRangePartitioning(t.RangePartitioning) md.Clustering = bqToClustering(t.Clustering) if t.StreamingBuffer != nil { md.StreamingBuffer = &StreamingBuffer{ diff --git a/vendor/cloud.google.com/go/bigtable/admin.go b/vendor/cloud.google.com/go/bigtable/admin.go index 815a2e93f5..4101a85790 100644 --- a/vendor/cloud.google.com/go/bigtable/admin.go +++ b/vendor/cloud.google.com/go/bigtable/admin.go @@ -17,6 +17,7 @@ limitations under the License. package bigtable import ( + "container/list" "context" "errors" "fmt" @@ -65,6 +66,8 @@ func NewAdminClient(ctx context.Context, project, instance string, opts ...optio if err != nil { return nil, err } + // Add gRPC client interceptors to supply Google client information. No external interceptors are passed. + o = append(o, btopt.ClientInterceptorOptions(nil, nil)...) // Need to add scopes for long running operations (for create table & snapshots) o = append(o, option.WithScopes(cloudresourcemanager.CloudPlatformScope)) o = append(o, opts...) @@ -105,7 +108,7 @@ func (ac *AdminClient) instancePrefix() string { // Tables returns a list of the tables in the instance. func (ac *AdminClient) Tables(ctx context.Context) ([]string, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() req := &btapb.ListTablesRequest{ Parent: prefix, @@ -153,7 +156,7 @@ func (ac *AdminClient) CreatePresplitTable(ctx context.Context, table string, sp // CreateTableFromConf creates a new table in the instance from the given configuration. func (ac *AdminClient) CreateTableFromConf(ctx context.Context, conf *TableConf) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) var reqSplits []*btapb.CreateTableRequest_Split for _, split := range conf.SplitKeys { reqSplits = append(reqSplits, &btapb.CreateTableRequest_Split{Key: []byte(split)}) @@ -179,7 +182,7 @@ func (ac *AdminClient) CreateTableFromConf(ctx context.Context, conf *TableConf) // CreateColumnFamily creates a new column family in a table. func (ac *AdminClient) CreateColumnFamily(ctx context.Context, table, family string) error { // TODO(dsymonds): Permit specifying gcexpr and any other family settings. - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() req := &btapb.ModifyColumnFamiliesRequest{ Name: prefix + "/tables/" + table, @@ -194,7 +197,7 @@ func (ac *AdminClient) CreateColumnFamily(ctx context.Context, table, family str // DeleteTable deletes a table and all of its data. func (ac *AdminClient) DeleteTable(ctx context.Context, table string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() req := &btapb.DeleteTableRequest{ Name: prefix + "/tables/" + table, @@ -205,7 +208,7 @@ func (ac *AdminClient) DeleteTable(ctx context.Context, table string) error { // DeleteColumnFamily deletes a column family in a table and all of its data. func (ac *AdminClient) DeleteColumnFamily(ctx context.Context, table, family string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() req := &btapb.ModifyColumnFamiliesRequest{ Name: prefix + "/tables/" + table, @@ -233,7 +236,7 @@ type FamilyInfo struct { // TableInfo retrieves information about a table. func (ac *AdminClient) TableInfo(ctx context.Context, table string) (*TableInfo, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() req := &btapb.GetTableRequest{ Name: prefix + "/tables/" + table, @@ -262,7 +265,7 @@ func (ac *AdminClient) TableInfo(ctx context.Context, table string) (*TableInfo, // GC executes opportunistically in the background; table reads may return data // matching the GC policy. func (ac *AdminClient) SetGCPolicy(ctx context.Context, table, family string, policy GCPolicy) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() req := &btapb.ModifyColumnFamiliesRequest{ Name: prefix + "/tables/" + table, @@ -277,7 +280,7 @@ func (ac *AdminClient) SetGCPolicy(ctx context.Context, table, family string, po // DropRowRange permanently deletes a row range from the specified table. func (ac *AdminClient) DropRowRange(ctx context.Context, table, rowKeyPrefix string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() req := &btapb.DropRowRangeRequest{ Name: prefix + "/tables/" + table, @@ -287,6 +290,18 @@ func (ac *AdminClient) DropRowRange(ctx context.Context, table, rowKeyPrefix str return err } +// DropAllRows permanently deletes all rows from the specified table. +func (ac *AdminClient) DropAllRows(ctx context.Context, table string) error { + ctx = mergeOutgoingMetadata(ctx, ac.md) + prefix := ac.instancePrefix() + req := &btapb.DropRowRangeRequest{ + Name: prefix + "/tables/" + table, + Target: &btapb.DropRowRangeRequest_DeleteAllDataFromTable{DeleteAllDataFromTable: true}, + } + _, err := ac.tClient.DropRowRange(ctx, req) + return err +} + // CreateTableFromSnapshot creates a table from snapshot. // The table will be created in the same cluster as the snapshot. // @@ -295,7 +310,7 @@ func (ac *AdminClient) DropRowRange(ctx context.Context, table, rowKeyPrefix str // might be changed in backward-incompatible ways and is not recommended for // production use. It is not subject to any SLA or deprecation policy. func (ac *AdminClient) CreateTableFromSnapshot(ctx context.Context, table, cluster, snapshot string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() snapshotPath := prefix + "/clusters/" + cluster + "/snapshots/" + snapshot @@ -324,7 +339,7 @@ const DefaultSnapshotDuration time.Duration = 0 // might be changed in backward-incompatible ways and is not recommended for // production use. It is not subject to any SLA or deprecation policy. func (ac *AdminClient) SnapshotTable(ctx context.Context, table, cluster, snapshot string, ttl time.Duration) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() var ttlProto *durpb.Duration @@ -356,7 +371,7 @@ func (ac *AdminClient) SnapshotTable(ctx context.Context, table, cluster, snapsh // changed in backward-incompatible ways and is not recommended for production use. // It is not subject to any SLA or deprecation policy. func (ac *AdminClient) Snapshots(ctx context.Context, cluster string) *SnapshotIterator { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() clusterPath := prefix + "/clusters/" + cluster @@ -469,7 +484,7 @@ type SnapshotInfo struct { // might be changed in backward-incompatible ways and is not recommended for // production use. It is not subject to any SLA or deprecation policy. func (ac *AdminClient) SnapshotInfo(ctx context.Context, cluster, snapshot string) (*SnapshotInfo, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() clusterPath := prefix + "/clusters/" + cluster snapshotPath := clusterPath + "/snapshots/" + snapshot @@ -498,7 +513,7 @@ func (ac *AdminClient) SnapshotInfo(ctx context.Context, cluster, snapshot strin // might be changed in backward-incompatible ways and is not recommended for // production use. It is not subject to any SLA or deprecation policy. func (ac *AdminClient) DeleteSnapshot(ctx context.Context, cluster, snapshot string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) prefix := ac.instancePrefix() clusterPath := prefix + "/clusters/" + cluster snapshotPath := clusterPath + "/snapshots/" + snapshot @@ -544,7 +559,7 @@ func (ac *AdminClient) isConsistent(ctx context.Context, tableName, token string // WaitForReplication waits until all the writes committed before the call started have been propagated to all the clusters in the instance via replication. func (ac *AdminClient) WaitForReplication(ctx context.Context, table string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), ac.md) + ctx = mergeOutgoingMetadata(ctx, ac.md) // Get the token. prefix := ac.instancePrefix() tableName := prefix + "/tables/" + table @@ -573,6 +588,12 @@ func (ac *AdminClient) WaitForReplication(ctx context.Context, table string) err } } +// TableIAM creates an IAM client specific to a given Instance and Table within the configured project. +func (ac *AdminClient) TableIAM(tableID string) *iam.Handle { + return iam.InternalNewHandleGRPCClient(ac.tClient, + "projects/"+ac.project+"/instances/"+ac.instance+"/tables/"+tableID) +} + const instanceAdminAddr = "bigtableadmin.googleapis.com:443" // InstanceAdminClient is a client type for performing admin operations on instances. @@ -594,6 +615,8 @@ func NewInstanceAdminClient(ctx context.Context, project string, opts ...option. if err != nil { return nil, err } + // Add gRPC client interceptors to supply Google client information. No external interceptors are passed. + o = append(o, btopt.ClientInterceptorOptions(nil, nil)...) o = append(o, opts...) conn, err := gtransport.Dial(ctx, o...) if err != nil { @@ -641,6 +664,14 @@ func (st StorageType) proto() btapb.StorageType { return btapb.StorageType_SSD } +func storageTypeFromProto(st btapb.StorageType) StorageType { + if st == btapb.StorageType_HDD { + return HDD + } + + return SSD +} + // InstanceType is the type of the instance type InstanceType int32 @@ -679,7 +710,7 @@ var instanceNameRegexp = regexp.MustCompile(`^projects/([^/]+)/instances/([a-z][ // CreateInstance creates a new instance in the project. // This method will return when the instance has been created or when an error occurs. func (iac *InstanceAdminClient) CreateInstance(ctx context.Context, conf *InstanceConf) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) newConfig := InstanceWithClustersConfig{ InstanceID: conf.InstanceId, DisplayName: conf.DisplayName, @@ -700,7 +731,7 @@ func (iac *InstanceAdminClient) CreateInstance(ctx context.Context, conf *Instan // CreateInstanceWithClusters creates a new instance with configured clusters in the project. // This method will return when the instance has been created or when an error occurs. func (iac *InstanceAdminClient) CreateInstanceWithClusters(ctx context.Context, conf *InstanceWithClustersConfig) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) clusters := make(map[string]*btapb.Cluster) for _, cluster := range conf.Clusters { clusters[cluster.ClusterID] = cluster.proto(iac.project) @@ -721,26 +752,11 @@ func (iac *InstanceAdminClient) CreateInstanceWithClusters(ctx context.Context, return longrunning.InternalNewOperation(iac.lroClient, lro).Wait(ctx, &resp) } -// UpdateInstanceWithClusters updates an instance and its clusters. -// The provided InstanceWithClustersConfig is used as follows: -// - InstanceID is required -// - DisplayName and InstanceType are updated only if they are not empty -// - ClusterID is required for any provided cluster -// - All other cluster fields are ignored except for NumNodes, which if set will be updated -// -// This method may return an error after partially succeeding, for example if the instance is updated -// but a cluster update fails. If an error is returned, InstanceInfo and Clusters may be called to -// determine the current state. -func (iac *InstanceAdminClient) UpdateInstanceWithClusters(ctx context.Context, conf *InstanceWithClustersConfig) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) - +// updateInstance updates a single instance based on config fields that operate +// at an instance level: DisplayName and InstanceType. +func (iac *InstanceAdminClient) updateInstance(ctx context.Context, conf *InstanceWithClustersConfig) (updated bool, err error) { if conf.InstanceID == "" { - return errors.New("InstanceID is required") - } - for _, cluster := range conf.Clusters { - if cluster.ClusterID == "" { - return errors.New("ClusterID is required for every cluster") - } + return false, errors.New("InstanceID is required") } // Update the instance, if necessary @@ -759,17 +775,46 @@ func (iac *InstanceAdminClient) UpdateInstanceWithClusters(ctx context.Context, ireq.Instance.Type = btapb.Instance_Type(conf.InstanceType) mask.Paths = append(mask.Paths, "type") } - updatedInstance := false - if len(mask.Paths) > 0 { - lro, err := iac.iClient.PartialUpdateInstance(ctx, ireq) - if err != nil { - return err - } - err = longrunning.InternalNewOperation(iac.lroClient, lro).Wait(ctx, nil) - if err != nil { - return err + + if len(mask.Paths) == 0 { + return false, nil + } + + lro, err := iac.iClient.PartialUpdateInstance(ctx, ireq) + if err != nil { + return false, err + } + err = longrunning.InternalNewOperation(iac.lroClient, lro).Wait(ctx, nil) + if err != nil { + return false, err + } + + return true, nil +} + +// UpdateInstanceWithClusters updates an instance and its clusters. Updateable +// fields are instance display name, instance type and cluster size. +// The provided InstanceWithClustersConfig is used as follows: +// - InstanceID is required +// - DisplayName and InstanceType are updated only if they are not empty +// - ClusterID is required for any provided cluster +// - All other cluster fields are ignored except for NumNodes, which if set will be updated +// +// This method may return an error after partially succeeding, for example if the instance is updated +// but a cluster update fails. If an error is returned, InstanceInfo and Clusters may be called to +// determine the current state. +func (iac *InstanceAdminClient) UpdateInstanceWithClusters(ctx context.Context, conf *InstanceWithClustersConfig) error { + ctx = mergeOutgoingMetadata(ctx, iac.md) + + for _, cluster := range conf.Clusters { + if cluster.ClusterID == "" { + return errors.New("ClusterID is required for every cluster") } - updatedInstance = true + } + + updatedInstance, err := iac.updateInstance(ctx, conf) + if err != nil { + return err } // Update any clusters @@ -790,7 +835,7 @@ func (iac *InstanceAdminClient) UpdateInstanceWithClusters(ctx context.Context, // DeleteInstance deletes an instance from the project. func (iac *InstanceAdminClient) DeleteInstance(ctx context.Context, instanceID string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) req := &btapb.DeleteInstanceRequest{Name: "projects/" + iac.project + "/instances/" + instanceID} _, err := iac.iClient.DeleteInstance(ctx, req) return err @@ -798,7 +843,7 @@ func (iac *InstanceAdminClient) DeleteInstance(ctx context.Context, instanceID s // Instances returns a list of instances in the project. func (iac *InstanceAdminClient) Instances(ctx context.Context) ([]*InstanceInfo, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) req := &btapb.ListInstancesRequest{ Parent: "projects/" + iac.project, } @@ -834,7 +879,7 @@ func (iac *InstanceAdminClient) Instances(ctx context.Context) ([]*InstanceInfo, // InstanceInfo returns information about an instance. func (iac *InstanceAdminClient) InstanceInfo(ctx context.Context, instanceID string) (*InstanceInfo, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) req := &btapb.GetInstanceRequest{ Name: "projects/" + iac.project + "/instances/" + instanceID, } @@ -876,16 +921,17 @@ func (cc *ClusterConfig) proto(project string) *btapb.Cluster { // ClusterInfo represents information about a cluster. type ClusterInfo struct { - Name string // name of the cluster - Zone string // GCP zone of the cluster (e.g. "us-central1-a") - ServeNodes int // number of allocated serve nodes - State string // state of the cluster + Name string // name of the cluster + Zone string // GCP zone of the cluster (e.g. "us-central1-a") + ServeNodes int // number of allocated serve nodes + State string // state of the cluster + StorageType StorageType // the storage type of the cluster } // CreateCluster creates a new cluster in an instance. // This method will return when the cluster has been created or when an error occurs. func (iac *InstanceAdminClient) CreateCluster(ctx context.Context, conf *ClusterConfig) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) req := &btapb.CreateClusterRequest{ Parent: "projects/" + iac.project + "/instances/" + conf.InstanceID, @@ -903,7 +949,7 @@ func (iac *InstanceAdminClient) CreateCluster(ctx context.Context, conf *Cluster // DeleteCluster deletes a cluster from an instance. func (iac *InstanceAdminClient) DeleteCluster(ctx context.Context, instanceID, clusterID string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) req := &btapb.DeleteClusterRequest{Name: "projects/" + iac.project + "/instances/" + instanceID + "/clusters/" + clusterID} _, err := iac.iClient.DeleteCluster(ctx, req) return err @@ -911,7 +957,7 @@ func (iac *InstanceAdminClient) DeleteCluster(ctx context.Context, instanceID, c // UpdateCluster updates attributes of a cluster func (iac *InstanceAdminClient) UpdateCluster(ctx context.Context, instanceID, clusterID string, serveNodes int32) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) cluster := &btapb.Cluster{ Name: "projects/" + iac.project + "/instances/" + instanceID + "/clusters/" + clusterID, ServeNodes: serveNodes} @@ -924,7 +970,7 @@ func (iac *InstanceAdminClient) UpdateCluster(ctx context.Context, instanceID, c // Clusters lists the clusters in an instance. func (iac *InstanceAdminClient) Clusters(ctx context.Context, instanceID string) ([]*ClusterInfo, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) req := &btapb.ListClustersRequest{Parent: "projects/" + iac.project + "/instances/" + instanceID} var res *btapb.ListClustersResponse err := gax.Invoke(ctx, func(ctx context.Context, _ gax.CallSettings) error { @@ -941,10 +987,11 @@ func (iac *InstanceAdminClient) Clusters(ctx context.Context, instanceID string) nameParts := strings.Split(c.Name, "/") locParts := strings.Split(c.Location, "/") cis = append(cis, &ClusterInfo{ - Name: nameParts[len(nameParts)-1], - Zone: locParts[len(locParts)-1], - ServeNodes: int(c.ServeNodes), - State: c.State.String(), + Name: nameParts[len(nameParts)-1], + Zone: locParts[len(locParts)-1], + ServeNodes: int(c.ServeNodes), + State: c.State.String(), + StorageType: storageTypeFromProto(c.DefaultStorageType), }) } return cis, nil @@ -952,7 +999,7 @@ func (iac *InstanceAdminClient) Clusters(ctx context.Context, instanceID string) // GetCluster fetches a cluster in an instance func (iac *InstanceAdminClient) GetCluster(ctx context.Context, instanceID, clusterID string) (*ClusterInfo, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) req := &btapb.GetClusterRequest{Name: "projects/" + iac.project + "/instances/" + instanceID + "/clusters/" + clusterID} var c *btapb.Cluster err := gax.Invoke(ctx, func(ctx context.Context, _ gax.CallSettings) error { @@ -967,10 +1014,11 @@ func (iac *InstanceAdminClient) GetCluster(ctx context.Context, instanceID, clus nameParts := strings.Split(c.Name, "/") locParts := strings.Split(c.Location, "/") cis := &ClusterInfo{ - Name: nameParts[len(nameParts)-1], - Zone: locParts[len(locParts)-1], - ServeNodes: int(c.ServeNodes), - State: c.State.String(), + Name: nameParts[len(nameParts)-1], + Zone: locParts[len(locParts)-1], + ServeNodes: int(c.ServeNodes), + State: c.State.String(), + StorageType: storageTypeFromProto(c.DefaultStorageType), } return cis, nil } @@ -980,12 +1028,6 @@ func (iac *InstanceAdminClient) InstanceIAM(instanceID string) *iam.Handle { return iam.InternalNewHandleGRPCClient(iac.iClient, "projects/"+iac.project+"/instances/"+instanceID) } -// TableIAM creates an IAM client specific to a given Instance and Table within the configured project. -func (iac *InstanceAdminClient) TableIAM(instanceID, tableID string) *iam.Handle { - return iam.InternalNewHandleGRPCClient(iac.iClient, - "projects/"+iac.project+"/instances/"+instanceID+"/tables/"+tableID) -} - // Routing policies. const ( // MultiClusterRouting is a policy that allows read/write requests to be @@ -1070,7 +1112,7 @@ func (it *ProfileIterator) Next() (*btapb.AppProfile, error) { // CreateAppProfile creates an app profile within an instance. func (iac *InstanceAdminClient) CreateAppProfile(ctx context.Context, profile ProfileConf) (*btapb.AppProfile, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) parent := "projects/" + iac.project + "/instances/" + profile.InstanceID appProfile := &btapb.AppProfile{ Etag: profile.Etag, @@ -1107,7 +1149,7 @@ func (iac *InstanceAdminClient) CreateAppProfile(ctx context.Context, profile Pr // GetAppProfile gets information about an app profile. func (iac *InstanceAdminClient) GetAppProfile(ctx context.Context, instanceID, name string) (*btapb.AppProfile, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) profileRequest := &btapb.GetAppProfileRequest{ Name: "projects/" + iac.project + "/instances/" + instanceID + "/appProfiles/" + name, } @@ -1125,7 +1167,7 @@ func (iac *InstanceAdminClient) GetAppProfile(ctx context.Context, instanceID, n // ListAppProfiles lists information about app profiles in an instance. func (iac *InstanceAdminClient) ListAppProfiles(ctx context.Context, instanceID string) *ProfileIterator { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) listRequest := &btapb.ListAppProfilesRequest{ Parent: "projects/" + iac.project + "/instances/" + instanceID, } @@ -1157,7 +1199,7 @@ func (iac *InstanceAdminClient) ListAppProfiles(ctx context.Context, instanceID // UpdateAppProfile updates an app profile within an instance. // updateAttrs should be set. If unset, all fields will be replaced. func (iac *InstanceAdminClient) UpdateAppProfile(ctx context.Context, instanceID, profileID string, updateAttrs ProfileAttrsToUpdate) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) profile := &btapb.AppProfile{ Name: "projects/" + iac.project + "/instances/" + instanceID + "/appProfiles/" + profileID, @@ -1201,7 +1243,7 @@ func (iac *InstanceAdminClient) UpdateAppProfile(ctx context.Context, instanceID // DeleteAppProfile deletes an app profile from an instance. func (iac *InstanceAdminClient) DeleteAppProfile(ctx context.Context, instanceID, name string) error { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), iac.md) + ctx = mergeOutgoingMetadata(ctx, iac.md) deleteProfileRequest := &btapb.DeleteAppProfileRequest{ Name: "projects/" + iac.project + "/instances/" + instanceID + "/appProfiles/" + name, IgnoreWarnings: true, @@ -1210,3 +1252,147 @@ func (iac *InstanceAdminClient) DeleteAppProfile(ctx context.Context, instanceID return err } + +// UpdateInstanceResults contains information about the +// changes made after invoking UpdateInstanceAndSyncClusters. +type UpdateInstanceResults struct { + InstanceUpdated bool + CreatedClusters []string + DeletedClusters []string + UpdatedClusters []string +} + +func (r *UpdateInstanceResults) String() string { + return fmt.Sprintf("Instance updated? %v Clusters added:%v Clusters deleted:%v Clusters updated:%v", + r.InstanceUpdated, r.CreatedClusters, r.DeletedClusters, r.UpdatedClusters) +} + +func max(x, y int) int { + if x > y { + return x + } + return y +} + +// UpdateInstanceAndSyncClusters updates an instance and its clusters, and will synchronize the +// clusters in the instance with the provided clusters, creating and deleting them as necessary. +// The provided InstanceWithClustersConfig is used as follows: +// - InstanceID is required +// - DisplayName and InstanceType are updated only if they are not empty +// - ClusterID is required for any provided cluster +// - Any cluster present in conf.Clusters but not part of the instance will be created using CreateCluster +// and the given ClusterConfig. +// - Any cluster missing from conf.Clusters but present in the instance will be removed from the instance +// using DeleteCluster. +// - Any cluster in conf.Clusters that also exists in the instance will be updated to contain the +// provided number of nodes if set. +// +// This method may return an error after partially succeeding, for example if the instance is updated +// but a cluster update fails. If an error is returned, InstanceInfo and Clusters may be called to +// determine the current state. The return UpdateInstanceResults will describe the work done by the +// method, whether partial or complete. +func UpdateInstanceAndSyncClusters(ctx context.Context, iac *InstanceAdminClient, conf *InstanceWithClustersConfig) (*UpdateInstanceResults, error) { + ctx = mergeOutgoingMetadata(ctx, iac.md) + + // First fetch the existing clusters so we know what to remove, add or update. + existingClusters, err := iac.Clusters(ctx, conf.InstanceID) + if err != nil { + return nil, err + } + + updatedInstance, err := iac.updateInstance(ctx, conf) + if err != nil { + return nil, err + } + + results := &UpdateInstanceResults{InstanceUpdated: updatedInstance} + + existingClusterNames := make(map[string]bool) + for _, cluster := range existingClusters { + existingClusterNames[cluster.Name] = true + } + + // Synchronize clusters that were passed in with the existing clusters in the instance. + // First update any cluster we encounter that already exists in the instance. + // Collect the clusters that we will create and delete so that we can minimize disruption + // of the instance. + clustersToCreate := list.New() + clustersToDelete := list.New() + for _, cluster := range conf.Clusters { + _, clusterExists := existingClusterNames[cluster.ClusterID] + if !clusterExists { + // The cluster doesn't exist yet, so we must create it. + clustersToCreate.PushBack(cluster) + continue + } + delete(existingClusterNames, cluster.ClusterID) + + if cluster.NumNodes <= 0 { + // We only synchronize clusters with a valid number of nodes. + continue + } + + // We simply want to update this cluster + err = iac.UpdateCluster(ctx, conf.InstanceID, cluster.ClusterID, cluster.NumNodes) + if err != nil { + return results, fmt.Errorf("UpdateCluster %q failed %v; Progress: %v", + cluster.ClusterID, err, results) + } + results.UpdatedClusters = append(results.UpdatedClusters, cluster.ClusterID) + } + + // Any cluster left in existingClusterNames was NOT in the given config and should be deleted. + for clusterToDelete := range existingClusterNames { + clustersToDelete.PushBack(clusterToDelete) + } + + // Now that we have the clusters that we need to create and delete, we do so keeping the following + // in mind: + // - Don't delete the last cluster in the instance, as that will result in an error. + // - Attempt to offset each deletion with a creation before another deletion, so that instance + // capacity is never reduced more than necessary. + // Note that there is a limit on number of clusters in an instance which we are not aware of here, + // so delete a cluster before adding one (as long as there are > 1 clusters left) so that we are + // less likely to exceed the maximum number of clusters. + numExistingClusters := len(existingClusters) + nextCreation := clustersToCreate.Front() + nextDeletion := clustersToDelete.Front() + for { + // We are done when both lists are empty. + if nextCreation == nil && nextDeletion == nil { + break + } + + // If there is more than one existing cluster, we always want to delete first if possible. + // If there are no more creations left, always go ahead with the deletion. + if (numExistingClusters > 1 && nextDeletion != nil) || nextCreation == nil { + clusterToDelete := nextDeletion.Value.(string) + err = iac.DeleteCluster(ctx, conf.InstanceID, clusterToDelete) + if err != nil { + return results, fmt.Errorf("DeleteCluster %q failed %v; Progress: %v", + clusterToDelete, err, results) + } + results.DeletedClusters = append(results.DeletedClusters, clusterToDelete) + numExistingClusters-- + nextDeletion = nextDeletion.Next() + } + + // Now create a new cluster if required. + if nextCreation != nil { + clusterToCreate := nextCreation.Value.(ClusterConfig) + // Assume the cluster config is well formed and rely on the underlying call to error out. + // Make sure to set the InstanceID, though, since we know what it must be. + clusterToCreate.InstanceID = conf.InstanceID + err = iac.CreateCluster(ctx, &clusterToCreate) + if err != nil { + return results, fmt.Errorf("CreateCluster %v failed %v; Progress: %v", + clusterToCreate, err, results) + } + results.CreatedClusters = append(results.CreatedClusters, clusterToCreate.ClusterID) + numExistingClusters++ + nextCreation = nextCreation.Next() + } + } + + return results, nil +} diff --git a/vendor/cloud.google.com/go/bigtable/bigtable.go b/vendor/cloud.google.com/go/bigtable/bigtable.go index 7c8ea33fea..16ca3dfe57 100644 --- a/vendor/cloud.google.com/go/bigtable/bigtable.go +++ b/vendor/cloud.google.com/go/bigtable/bigtable.go @@ -26,7 +26,6 @@ import ( btopt "cloud.google.com/go/bigtable/internal/option" "cloud.google.com/go/internal/trace" - "cloud.google.com/go/internal/version" "github.com/golang/protobuf/proto" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/option" @@ -69,6 +68,9 @@ func NewClientWithConfig(ctx context.Context, project, instance string, config C if err != nil { return nil, err } + // Add gRPC client interceptors to supply Google client information. No external interceptors are passed. + o = append(o, btopt.ClientInterceptorOptions(nil, nil)...) + // Default to a small connection pool that can be overridden. o = append(o, option.WithGRPCConnectionPool(4), @@ -130,21 +132,6 @@ func mergeOutgoingMetadata(ctx context.Context, mds ...metadata.MD) context.Cont return metadata.NewOutgoingContext(ctx, metadata.Join(allMDs...)) } -// withGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func withGoogleClientInfo() metadata.MD { - kv := []string{ - "gl-go", - version.Go(), - "gax", - gax.Version, - "grpc", - grpc.Version, - } - return metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - // A Table refers to a table. // // A Table is safe to use concurrently. @@ -174,7 +161,7 @@ func (c *Client) Open(table string) *Table { // By default, the yielded rows will contain all values in all cells. // Use RowFilter to limit the cells returned. func (t *Table) ReadRows(ctx context.Context, arg RowSet, f func(Row) bool, opts ...ReadOption) (err error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), t.md) + ctx = mergeOutgoingMetadata(ctx, t.md) ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigtable.ReadRows") defer func() { trace.EndSpan(ctx, err) }() @@ -499,7 +486,7 @@ const maxMutations = 100000 // Apply mutates a row atomically. A mutation must contain at least one // operation and at most 100000 operations. func (t *Table) Apply(ctx context.Context, row string, m *Mutation, opts ...ApplyOption) (err error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), t.md) + ctx = mergeOutgoingMetadata(ctx, t.md) ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigtable/Apply") defer func() { trace.EndSpan(ctx, err) }() @@ -675,7 +662,7 @@ type entryErr struct { // // Conditional mutations cannot be applied in bulk and providing one will result in an error. func (t *Table) ApplyBulk(ctx context.Context, rowKeys []string, muts []*Mutation, opts ...ApplyOption) (errs []error, err error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), t.md) + ctx = mergeOutgoingMetadata(ctx, t.md) ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigtable/ApplyBulk") defer func() { trace.EndSpan(ctx, err) }() @@ -840,7 +827,7 @@ func (ts Timestamp) TruncateToMilliseconds() Timestamp { // ApplyReadModifyWrite applies a ReadModifyWrite to a specific row. // It returns the newly written cells. func (t *Table) ApplyReadModifyWrite(ctx context.Context, row string, m *ReadModifyWrite) (Row, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), t.md) + ctx = mergeOutgoingMetadata(ctx, t.md) req := &btpb.ReadModifyWriteRowRequest{ TableName: t.c.fullTableName(t.table), AppProfileId: t.c.appProfile, @@ -901,7 +888,7 @@ func (m *ReadModifyWrite) Increment(family, column string, delta int64) { // SampleRowKeys returns a sample of row keys in the table. The returned row keys will delimit contiguous sections of // the table of approximately equal size, which can be used to break up the data for distributed tasks like mapreduces. func (t *Table) SampleRowKeys(ctx context.Context) ([]string, error) { - ctx = mergeOutgoingMetadata(ctx, withGoogleClientInfo(), t.md) + ctx = mergeOutgoingMetadata(ctx, t.md) var sampledRowKeys []string err := gax.Invoke(ctx, func(ctx context.Context, _ gax.CallSettings) error { sampledRowKeys = nil diff --git a/vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt.go b/vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt.go index 458b9df8d6..ebfd441f4e 100644 --- a/vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt.go +++ b/vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt.go @@ -41,6 +41,7 @@ import ( "google.golang.org/api/iterator" "google.golang.org/api/option" "google.golang.org/grpc" + "google.golang.org/grpc/metadata" ) var ( @@ -150,6 +151,10 @@ func main() { } ctx := context.Background() + if config.AuthToken != "" { + ctx = metadata.AppendToOutgoingContext(ctx, "x-goog-iam-authorization-token", config.AuthToken) + } + for _, cmd := range commands { if cmd.Name == flag.Arg(0) { if err := config.CheckFlags(cmd.Required); err != nil { @@ -183,26 +188,56 @@ func init() { cmdSummary = buf.String() } -var configHelp = ` -Alpha features are not currently available to most Cloud Bigtable customers. The +const configHelp = ` +Alpha features are not currently available to most Cloud Bigtable customers. Alpha features might be changed in backward-incompatible ways and are not recommended for production use. They are not subject to any SLA or deprecation policy. -Note: cbt does not support specifying arbitrary bytes on the command line for -any value that Cloud Bigtable otherwise supports (for example, the row key and -column qualifier). +Syntax rules for the Bash shell apply to the ` + "`cbt`" + ` tool. This means, for example, +that you must put quotes around values that contain spaces or operators. It also means that +if a value is arbitrary bytes, you need to prefix it with a dollar sign and use single quotes. + +Example: + +cbt -project my-project -instance my-instance lookup my-table $'\224\257\312W\365:\205d\333\2471\315\' -For convenience, values of the -project, -instance, -creds, --admin-endpoint and -data-endpoint flags may be specified in -~/.cbtrc in this format: - project = my-project-123 - instance = my-instance - creds = path-to-account-key.json - admin-endpoint = hostname:port - data-endpoint = hostname:port +For convenience, you can add values for the -project, -instance, -creds, -admin-endpoint and -data-endpoint +options to your ~/.cbtrc file in the following format: -All values are optional, and all will be overridden by flags. + + project = my-project-123 + instance = my-instance + creds = path-to-account-key.json + admin-endpoint = hostname:port + data-endpoint = hostname:port + auth-token = AJAvW039NO1nDcijk_J6_rFXG_... + +All values are optional and can be overridden at the command prompt. +` + +const docIntroTemplate = `The ` + "`cbt`" + ` tool is a command-line tool that allows you to interact with Cloud Bigtable. +See the [cbt overview](https://cloud.google.com/bigtable/docs/cbt-overview) to learn how to install the ` + "`cbt`" + ` tool. + +Usage: + + cbt [-