Просмотр исходного кода

remove committed vendored stuff in favor of go modules.

AjayTripathy 7 лет назад
Родитель
Сommit
56ba586946
100 измененных файлов с 233 добавлено и 41144 удалено
  1. 14 17
      Dockerfile
  2. 3 2
      costmodel/costmodel.go
  3. 18 0
      go.mod
  4. 198 0
      go.sum
  5. 0 15
      vendor/cloud.google.com/go/AUTHORS
  6. 0 1068
      vendor/cloud.google.com/go/CHANGES.md
  7. 0 44
      vendor/cloud.google.com/go/CODE_OF_CONDUCT.md
  8. 0 234
      vendor/cloud.google.com/go/CONTRIBUTING.md
  9. 0 40
      vendor/cloud.google.com/go/CONTRIBUTORS
  10. 0 202
      vendor/cloud.google.com/go/LICENSE
  11. 0 505
      vendor/cloud.google.com/go/README.md
  12. 0 47
      vendor/cloud.google.com/go/RELEASING.md
  13. 0 248
      vendor/cloud.google.com/go/asset/apiv1beta1/asset_client.go
  14. 0 75
      vendor/cloud.google.com/go/asset/apiv1beta1/asset_client_example_test.go
  15. 0 89
      vendor/cloud.google.com/go/asset/apiv1beta1/doc.go
  16. 0 266
      vendor/cloud.google.com/go/asset/apiv1beta1/mock_test.go
  17. 0 248
      vendor/cloud.google.com/go/asset/v1beta1/asset_client.go
  18. 0 75
      vendor/cloud.google.com/go/asset/v1beta1/asset_client_example_test.go
  19. 0 89
      vendor/cloud.google.com/go/asset/v1beta1/doc.go
  20. 0 266
      vendor/cloud.google.com/go/asset/v1beta1/mock_test.go
  21. 0 73
      vendor/cloud.google.com/go/authexample_test.go
  22. 0 8
      vendor/cloud.google.com/go/bigquery/benchmarks/README.md
  23. 0 85
      vendor/cloud.google.com/go/bigquery/benchmarks/bench.go
  24. 0 10
      vendor/cloud.google.com/go/bigquery/benchmarks/queries.json
  25. 0 162
      vendor/cloud.google.com/go/bigquery/bigquery.go
  26. 0 8062
      vendor/cloud.google.com/go/bigquery/bigquery.replay
  27. 0 107
      vendor/cloud.google.com/go/bigquery/copy.go
  28. 0 163
      vendor/cloud.google.com/go/bigquery/copy_test.go
  29. 0 536
      vendor/cloud.google.com/go/bigquery/dataset.go
  30. 0 326
      vendor/cloud.google.com/go/bigquery/dataset_test.go
  31. 0 67
      vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/ListDataSources_smoke_test.go
  32. 0 625
      vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/data_transfer_client.go
  33. 0 289
      vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/data_transfer_client_example_test.go
  34. 0 90
      vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/doc.go
  35. 0 1146
      vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/mock_test.go
  36. 0 135
      vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/path_funcs.go
  37. 0 310
      vendor/cloud.google.com/go/bigquery/doc.go
  38. 0 83
      vendor/cloud.google.com/go/bigquery/error.go
  39. 0 109
      vendor/cloud.google.com/go/bigquery/error_test.go
  40. 0 829
      vendor/cloud.google.com/go/bigquery/examples_test.go
  41. 0 400
      vendor/cloud.google.com/go/bigquery/external.go
  42. 0 143
      vendor/cloud.google.com/go/bigquery/external_test.go
  43. 0 110
      vendor/cloud.google.com/go/bigquery/extract.go
  44. 0 116
      vendor/cloud.google.com/go/bigquery/extract_test.go
  45. 0 137
      vendor/cloud.google.com/go/bigquery/file.go
  46. 0 98
      vendor/cloud.google.com/go/bigquery/file_test.go
  47. 0 75
      vendor/cloud.google.com/go/bigquery/gcs.go
  48. 0 238
      vendor/cloud.google.com/go/bigquery/inserter.go
  49. 0 210
      vendor/cloud.google.com/go/bigquery/inserter_test.go
  50. 0 2186
      vendor/cloud.google.com/go/bigquery/integration_test.go
  51. 0 222
      vendor/cloud.google.com/go/bigquery/iterator.go
  52. 0 362
      vendor/cloud.google.com/go/bigquery/iterator_test.go
  53. 0 821
      vendor/cloud.google.com/go/bigquery/job.go
  54. 0 95
      vendor/cloud.google.com/go/bigquery/job_test.go
  55. 0 146
      vendor/cloud.google.com/go/bigquery/load.go
  56. 0 263
      vendor/cloud.google.com/go/bigquery/load_test.go
  57. 0 320
      vendor/cloud.google.com/go/bigquery/nulls.go
  58. 0 73
      vendor/cloud.google.com/go/bigquery/nulls_test.go
  59. 0 38
      vendor/cloud.google.com/go/bigquery/oc_test.go
  60. 0 360
      vendor/cloud.google.com/go/bigquery/params.go
  61. 0 385
      vendor/cloud.google.com/go/bigquery/params_test.go
  62. 0 328
      vendor/cloud.google.com/go/bigquery/query.go
  63. 0 408
      vendor/cloud.google.com/go/bigquery/query_test.go
  64. 0 56
      vendor/cloud.google.com/go/bigquery/random.go
  65. 0 233
      vendor/cloud.google.com/go/bigquery/read_test.go
  66. 0 488
      vendor/cloud.google.com/go/bigquery/schema.go
  67. 0 1052
      vendor/cloud.google.com/go/bigquery/schema_test.go
  68. 0 255
      vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/big_query_storage_client.go
  69. 0 132
      vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/big_query_storage_client_example_test.go
  70. 0 89
      vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/doc.go
  71. 0 452
      vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/mock_test.go
  72. 0 620
      vendor/cloud.google.com/go/bigquery/table.go
  73. 0 370
      vendor/cloud.google.com/go/bigquery/table_test.go
  74. 0 870
      vendor/cloud.google.com/go/bigquery/value.go
  75. 0 1214
      vendor/cloud.google.com/go/bigquery/value_test.go
  76. 0 1133
      vendor/cloud.google.com/go/bigtable/admin.go
  77. 0 578
      vendor/cloud.google.com/go/bigtable/admin_test.go
  78. 0 914
      vendor/cloud.google.com/go/bigtable/bigtable.go
  79. 0 1255
      vendor/cloud.google.com/go/bigtable/bigtable_test.go
  80. 0 83
      vendor/cloud.google.com/go/bigtable/bttest/example_test.go
  81. 0 1406
      vendor/cloud.google.com/go/bigtable/bttest/inmem.go
  82. 0 1193
      vendor/cloud.google.com/go/bigtable/bttest/inmem_test.go
  83. 0 1614
      vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt.go
  84. 0 173
      vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt_test.go
  85. 0 425
      vendor/cloud.google.com/go/bigtable/cmd/cbt/cbtdoc.go
  86. 0 215
      vendor/cloud.google.com/go/bigtable/cmd/cbt/gcpolicy.go
  87. 0 196
      vendor/cloud.google.com/go/bigtable/cmd/cbt/gcpolicy_test.go
  88. 0 52
      vendor/cloud.google.com/go/bigtable/cmd/emulator/cbtemulator.go
  89. 0 205
      vendor/cloud.google.com/go/bigtable/cmd/loadtest/loadtest.go
  90. 0 155
      vendor/cloud.google.com/go/bigtable/cmd/scantest/scantest.go
  91. 0 123
      vendor/cloud.google.com/go/bigtable/doc.go
  92. 0 215
      vendor/cloud.google.com/go/bigtable/export_test.go
  93. 0 330
      vendor/cloud.google.com/go/bigtable/filter.go
  94. 0 167
      vendor/cloud.google.com/go/bigtable/gc.go
  95. 0 46
      vendor/cloud.google.com/go/bigtable/gc_test.go
  96. 0 262
      vendor/cloud.google.com/go/bigtable/internal/cbtconfig/cbtconfig.go
  97. 0 110
      vendor/cloud.google.com/go/bigtable/internal/gax/call_option.go
  98. 0 87
      vendor/cloud.google.com/go/bigtable/internal/gax/invoke.go
  99. 0 49
      vendor/cloud.google.com/go/bigtable/internal/gax/invoke_test.go
  100. 0 48
      vendor/cloud.google.com/go/bigtable/internal/option/option.go

+ 14 - 17
Dockerfile

@@ -1,22 +1,19 @@
-FROM golang:latest
-EXPOSE 9001
+FROM golang:latest as build-env
 
-EXPOSE 8080
+RUN mkdir /app
+WORKDIR /app
+COPY go.mod .
+COPY go.sum .
 
-RUN  mkdir -p /go/src \
-  && mkdir -p /go/bin \
-  && mkdir -p /go/pkg
-ENV GOPATH=/go
-ENV PATH=$GOPATH/bin:$PATH   
+# Get dependancies - will also be cached if we won't change mod/sum
+RUN go mod download
+# COPY the source code as the last step
+COPY . .
 
-RUN mkdir -p $GOPATH/src/app 
-RUN mkdir -p /models
+# Build the binary
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /go/bin/app
+FROM scratch
+COPY --from=build-env /go/bin/app /go/bin/app
 ADD ./cloud/default.json /models/default.json
 ADD ./cloud/azure.json /models/azure.json
-ADD . $GOPATH/src/app
-ADD ./cloud/ /go/src/app/vendor/github.com/kubecost/cost-model/cloud/
-ADD ./costmodel/ /go/src/app/vendor/github.com/kubecost/cost-model/costmodel/
-
-WORKDIR $GOPATH/src/app 
-RUN go build -o myapp . 
-CMD ["/go/src/app/myapp"]
+ENTRYPOINT ["/go/bin/app"]

+ 3 - 2
costmodel/costmodel.go

@@ -13,7 +13,7 @@ import (
 
 	costAnalyzerCloud "github.com/kubecost/cost-model/cloud"
 	prometheusClient "github.com/prometheus/client_golang/api"
-	"k8s.io/api/core/v1"
+	v1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/labels"
 	"k8s.io/client-go/kubernetes"
@@ -289,7 +289,8 @@ func getNodeCost(clientset *kubernetes.Clientset, cloud costAnalyzerCloud.Provid
 }
 
 func getPodServices(clientset *kubernetes.Clientset, podList *v1.PodList) (map[string]map[string][]string, error) {
-	servicesList, err := clientset.Core().Services("").List(metav1.ListOptions{})
+	//servicesList, err := clientset.Core().Services("").List(metav1.ListOptions{})
+	servicesList, err := clientset.CoreV1().Services("").List(metav1.ListOptions{})
 	if err != nil {
 		return nil, err
 	}

+ 18 - 0
go.mod

@@ -0,0 +1,18 @@
+module github.com/kubecost/cost-model
+
+require (
+	cloud.google.com/go v0.34.0
+	github.com/aws/aws-sdk-go v1.19.10
+	github.com/golang/mock v1.2.0 // indirect
+	github.com/julienschmidt/httprouter v1.2.0
+	github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
+	golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
+	golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
+	google.golang.org/api v0.3.0
+	gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
+	gopkg.in/yaml.v2 v2.2.2 // indirect
+	k8s.io/api v0.0.0-20190404065945-709cf190c7b7
+	k8s.io/apimachinery v0.0.0-20190404065847-4a4abcd45006
+	k8s.io/client-go v0.0.0-20190404172613-2e1a3ed22ac5
+	k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 // indirect
+)

+ 198 - 0
go.sum

@@ -0,0 +1,198 @@
+cloud.google.com/go v0.0.0-20160913182117-3b1ae45394a2/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
+github.com/Azure/go-autorest v11.1.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
+github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
+github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
+github.com/aws/aws-sdk-go v1.19.10 h1:WHIaUrU98WsWIXxlxeMCmbuB5HowxuUnk8eBH4iGl/g=
+github.com/aws/aws-sdk-go v1.19.10/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
+github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
+github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
+github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
+github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
+github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI=
+github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/btree v0.0.0-20160524151835-7d79101e329e/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck=
+github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
+github.com/google/uuid v0.0.0-20171113160352-8c31c18f31ed/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k=
+github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
+github.com/gophercloud/gophercloud v0.0.0-20190126172459-c818fa66e4c8/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4=
+github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
+github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
+github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
+github.com/grpc-ecosystem/grpc-gateway v1.6.2/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
+github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
+github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
+github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
+github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE=
+github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v0.0.0-20190113212917-5533ce8a0da3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+github.com/openzipkin/zipkin-go v0.1.3/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
+github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
+github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
+github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740=
+github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
+github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829 h1:D+CiwcpGTW6pL6bv6KI3KbyEyCKyS+1JWS2h8PNDnGA=
+github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
+github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
+github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+go.opencensus.io v0.19.1/go.mod h1:gug0GbSHa8Pafr0d2urOSgoXHZ6x/RUlaiT0d9pqb4A=
+go.opencensus.io v0.19.2 h1:ZZpq6xI6kv/LuE/5s5UQvBU5vMjvRnPb8PvJrIntAnc=
+go.opencensus.io v0.19.2/go.mod h1:NO/8qkisMZLZ1FCsKNqtJPwc8/TaclWyY0B6wcYNg9M=
+golang.org/x/crypto v0.0.0-20180808211826-de0752318171/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190206173232-65e2d4e15006/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/oauth2 v0.0.0-20170412232759-a6bd8cefa181/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA=
+golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181218192612-074acd46bca6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/time v0.0.0-20161028155119-f51c12702a4d/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
+golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20181219222714-6e267b5cc78e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
+google.golang.org/api v0.2.0/go.mod h1:IfRCZScioGtypHNTlz3gFk67J8uePVW7uDTBzXuIkhU=
+google.golang.org/api v0.3.0 h1:UIJY20OEo3+tK5MBlcdx37kmdH6EnRjGkW78mc6+EeA=
+google.golang.org/api v0.3.0/go.mod h1:IuvZyQh8jgscv8qWfQ4ABd8m7hEudgBFM/EdhA3BnXw=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20181219182458-5a97ab628bfb/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 h1:Lj2SnHtxkRGJDqnGaSjo+CCdIieEnwVazbOXILwQemk=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
+google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
+google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o=
+gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+k8s.io/api v0.0.0-20190404065945-709cf190c7b7 h1:s6+su3184vqq9jlmBa1UHf/JXGlx6mR5/Wn1mgGgho0=
+k8s.io/api v0.0.0-20190404065945-709cf190c7b7/go.mod h1:qa6Gt7knwxwD/MXwV8iaEoTpniVksiix/r9hpLWYgTA=
+k8s.io/apimachinery v0.0.0-20190404065847-4a4abcd45006 h1:Jiue4qiNBoiq1GxPx33Kjw7KOyqYVEcZyl4y4rIXXLU=
+k8s.io/apimachinery v0.0.0-20190404065847-4a4abcd45006/go.mod h1:65NCMCFo27j/Cv2DAQSfKd70SAtu/hwoqasuXFCDNvY=
+k8s.io/client-go v0.0.0-20190404172613-2e1a3ed22ac5 h1:BwY2C//EoWktJi74O6R2REBonrhsfhRI0qfVwOjOPp8=
+k8s.io/client-go v0.0.0-20190404172613-2e1a3ed22ac5/go.mod h1:bIEHXHbykaOlj+pgLllzLJ2RPGdzkjtqdk0Il07KPEM=
+k8s.io/client-go v11.0.0+incompatible h1:LBbX2+lOwY9flffWlJM7f1Ct8V2SRNiMRDFeiwnJo9o=
+k8s.io/client-go v11.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
+k8s.io/klog v0.0.0-20190306015804-8e90cee79f82 h1:SHucoAy7lRb+w5oC/hbXyZg+zX+Wftn6hD4tGzHCVqA=
+k8s.io/klog v0.0.0-20190306015804-8e90cee79f82/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
+k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
+k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
+k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 h1:8r+l4bNWjRlsFYlQJnKJ2p7s1YQPj4XyXiJVqDHRx7c=
+k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
+sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
+sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=

+ 0 - 15
vendor/cloud.google.com/go/AUTHORS

@@ -1,15 +0,0 @@
-# This is the official list of cloud authors for copyright purposes.
-# This file is distinct from the CONTRIBUTORS files.
-# See the latter for an explanation.
-
-# Names should be added to this file as:
-# Name or Organization <email address>
-# The email address is not required for organizations.
-
-Filippo Valsorda <hi@filippo.io>
-Google Inc.
-Ingo Oeser <nightlyone@googlemail.com>
-Palm Stone Games, Inc.
-Paweł Knap <pawelknap88@gmail.com>
-Péter Szilágyi <peterke@gmail.com>
-Tyler Treat <ttreat31@gmail.com>

+ 0 - 1068
vendor/cloud.google.com/go/CHANGES.md

@@ -1,1068 +0,0 @@
-# Changes
-
-## 0.35.1
-
-- spanner:
-  - Adds OpenCensus views back to public API.
-
-## v0.35.0
-
-- all:
-  - Add go.mod and go.sum.
-  - Switch usage of gax-go to gax-go/v2.
-- bigquery:
-  - Fix bug where time partitioning could not be removed from a table.
-  - Fix panic that occurred with empty query parameters.
-- bttest:
-  - Fix bug where deleted rows were returned by ReadRows.
-- bigtable/emulator:
-  - Configure max message size to 256 MiB.
-- firestore:
-  - Allow non-transactional queries in transactions.
-  - Allow StartAt/EndBefore on direct children at any depth.
-  - QuerySnapshotIterator.Stop may be called in an error state.
-  - Fix bug the prevented reset of transaction write state in between retries.
-- functions/metadata:
-  - Make Metadata.Resource a pointer.
-- logging:
-  - Make SpanID available in logging.Entry.
-- metadata:
-  - Wrap !200 error code in a typed err.
-- profiler:
-  - Add function to check if function name is within a particular file in the
-    profile.
-  - Set parent field in create profile request.
-  - Return kubernetes client to start cluster, so client can be used to poll
-    cluster.
-  - Add function for checking if filename is in profile.
-- pubsub:
-  - Fix bug where messages expired without an initial modack in
-    synchronous=true mode.
-  - Receive does not retry ResourceExhausted errors.
-- spanner:
-  - client.Close now cancels existing requests and should be much faster for
-    large amounts of sessions.
-  - Correctly allow MinOpened sessions to be spun up.
-
-## v0.34.0
-
-- functions/metadata:
-  - Switch to using JSON in context.
-  - Make Resource a value.
-- vision: Fix ProductSearch return type.
-- datastore: Add an example for how to handle MultiError.
-
-## v0.33.1
-
-- compute: Removes an erroneously added go.mod.
-- logging: Populate source location in fromLogEntry.
-
-## v0.33.0
-
-- bttest:
-  - Add support for apply_label_transformer.
-- expr:
-  - Add expr library.
-- firestore:
-  - Support retrieval of missing documents.
-- kms:
-  - Add IAM methods.
-- pubsub:
-  - Clarify extension documentation.
-- scheduler:
-  - Add v1beta1 client.
-- vision:
-  - Add product search helper.
-  - Add new product search client.
-
-## v0.32.0
-
-Note: This release is the last to support Go 1.6 and 1.8.
-
-- bigquery:
-    - Add support for removing an expiration.
-    - Ignore NeverExpire in Table.Create.
-    - Validate table expiration time.
-- cbt:
-    - Add note about not supporting arbitrary bytes.
-- datastore:
-    - Align key checks.
-- firestore:
-    - Return an error when using Start/End without providing values.
-- pubsub:
-    - Add pstest Close method.
-    - Clarify MaxExtension documentation.
-- securitycenter:
-    - Add v1beta1 client.
-- spanner:
-    - Allow nil in mutations.
-    - Improve doc of SessionPoolConfig.MaxOpened.
-    - Increase session deletion timeout from 5s to 15s.
-
-## v0.31.0
-
-- bigtable:
-    - Group mutations across multiple requests.
-- bigquery:
-    - Link to bigquery troubleshooting errors page in bigquery.Error comment.
-- cbt:
-    - Fix go generate command.
-    - Document usage of both maxage + maxversions.
-- datastore:
-    - Passing nil keys results in ErrInvalidKey.
-- firestore:
-    - Clarify what Document.DataTo does with untouched struct fields.
-- profile:
-    - Validate service name in agent.
-- pubsub:
-    - Fix deadlock with pstest and ctx.Cancel.
-    - Fix a possible deadlock in pstest.
-- trace:
-    - Update doc URL with new fragment.
-
-Special thanks to @fastest963 for going above and beyond helping us to debug
-hard-to-reproduce Pub/Sub issues.
-
-## v0.30.0
-
-- spanner: DML support added. See https://godoc.org/cloud.google.com/go/spanner#hdr-DML_and_Partitioned_DML for more information.
-- bigtable: bttest supports row sample filter.
-- functions: metadata package added for accessing Cloud Functions resource metadata.
-
-## v0.29.0
-
-- bigtable:
-  - Add retry to all idempotent RPCs.
-  - cbt supports complex GC policies.
-  - Emulator supports arbitrary bytes in regex filters.
-- firestore: Add ArrayUnion and ArrayRemove.
-- logging: Add the ContextFunc option to supply the context used for
-  asynchronous RPCs.
-- profiler: Ignore NotDefinedError when fetching the instance name
-- pubsub:
-  - BEHAVIOR CHANGE: Receive doesn't retry if an RPC returns codes.Cancelled.
-  - BEHAVIOR CHANGE: Receive retries on Unavailable intead of returning.
-  - Fix deadlock.
-  - Restore Ack/Nack/Modacks metrics.
-  - Improve context handling in iterator.
-  - Implement synchronous mode for Receive.
-  - pstest: add Pull.
-- spanner: Add a metric for the number of sessions currently opened.
-- storage:
-  - Canceling the context releases all resources.
-  - Add additional RetentionPolicy attributes.
-- vision/apiv1: Add LocalizeObjects method.
-
-## v0.28.0
-
-- bigtable:
-  - Emulator returns Unimplemented for snapshot RPCs.
-- bigquery:
-  - Support zero-length repeated, nested fields.
-- cloud assets:
-  - Add v1beta client.
-- datastore:
-  - Don't nil out transaction ID on retry.
-- firestore:
-  - BREAKING CHANGE: When watching a query with Query.Snapshots, QuerySnapshotIterator.Next
-  returns a QuerySnapshot which contains read time, result size, change list and the DocumentIterator
-  (previously, QuerySnapshotIterator.Next returned just the DocumentIterator). See: https://godoc.org/cloud.google.com/go/firestore#Query.Snapshots.
-  - Add array-contains operator.
-- IAM:
-  - Add iam/credentials/apiv1 client.
-- pubsub:
-  - Canceling the context passed to Subscription.Receive causes Receive to return when
-  processing finishes on all messages currently in progress, even if new messages are arriving.
-- redis:
-  - Add redis/apiv1 client.
-- storage:
-  - Add Reader.Attrs.
-  - Deprecate several Reader getter methods: please use Reader.Attrs for these instead.
-  - Add ObjectHandle.Bucket and ObjectHandle.Object methods.
-
-## v0.27.0
-
-- bigquery:
-  - Allow modification of encryption configuration and partitioning options to a table via the Update call.
-  - Add a SchemaFromJSON function that converts a JSON table schema.
-- bigtable:
-  - Restore cbt count functionality.
-- containeranalysis:
-  - Add v1beta client.
-- spanner:
-  - Fix a case where an iterator might not be closed correctly.
-- storage:
-  - Add ServiceAccount method https://godoc.org/cloud.google.com/go/storage#Client.ServiceAccount.
-  - Add a method to Reader that returns the parsed value of the Last-Modified header.
-
-## v0.26.0
-
-- bigquery:
-  - Support filtering listed jobs  by min/max creation time.
-  - Support data clustering (https://godoc.org/cloud.google.com/go/bigquery#Clustering).
-  - Include job creator email in Job struct.
-- bigtable:
-  - Add `RowSampleFilter`.
-  - emulator: BREAKING BEHAVIOR CHANGE: Regexps in row, family, column and value filters
-    must match the entire target string to succeed. Previously, the emulator was
-    succeeding on  partial matches.
-    NOTE: As of this release, this change only affects the emulator when run
-    from this repo (bigtable/cmd/emulator/cbtemulator.go). The version launched
-    from `gcloud` will be updated in a subsequent `gcloud` release.
-- dataproc: Add apiv1beta2 client.
-- datastore: Save non-nil pointer fields on omitempty.
-- logging: populate Entry.Trace from the HTTP X-Cloud-Trace-Context header.
-- logging/logadmin:  Support writer_identity and include_children.
-- pubsub:
-  - Support labels on topics and subscriptions.
-  - Support message storage policy for topics.
-  - Use the distribution of ack times to determine when to extend ack deadlines.
-    The only user-visible effect of this change should be that programs that
-    call only `Subscription.Receive` need no IAM permissions other than `Pub/Sub
-    Subscriber`.
-- storage:
-  - Support predefined ACLs.
-  - Support additional ACL fields other than Entity and Role.
-  - Support bucket websites.
-  - Support bucket logging.
-
-
-## v0.25.0
-
-- Added [Code of Conduct](https://github.com/googleapis/google-cloud-go/blob/master/CODE_OF_CONDUCT.md)
-- bigtable:
-  - cbt: Support a GC policy of "never".
-- errorreporting:
-  - Support User.
-  - Close now calls Flush.
-  - Use OnError (previously ignored).
-  - Pass through the RPC error as-is to OnError.
-- httpreplay: A tool for recording and replaying HTTP requests
-  (for the bigquery and storage clients in this repo).
-- kms: v1 client added
-- logging: add SourceLocation to Entry.
-- storage: improve CRC checking on read.
-
-## v0.24.0
-
-- bigquery: Support for the NUMERIC type.
-- bigtable:
-  - cbt: Optionally specify columns for read/lookup
-  - Support instance-level administration.
-- oslogin: New client for the OS Login API.
-- pubsub:
-  - The package is now stable. There will be no further breaking changes.
-  - Internal changes to improve Subscription.Receive behavior.
-- storage: Support updating bucket lifecycle config.
-- spanner: Support struct-typed parameter bindings.
-- texttospeech: New client for the Text-to-Speech API.
-
-## v0.23.0
-
-- bigquery: Add DDL stats to query statistics.
-- bigtable:
-  - cbt: Add cells-per-column limit for row lookup.
-  - cbt: Make it possible to combine read filters.
-- dlp: v2beta2 client removed. Use the v2 client instead.
-- firestore, spanner: Fix compilation errors due to protobuf changes.
-
-## v0.22.0
-
-- bigtable:
-  - cbt: Support cells per column limit for row read.
-  - bttest: Correctly handle empty RowSet.
-  - Fix ReadModifyWrite operation in emulator.
-  - Fix API path in GetCluster.
-
-- bigquery:
-  - BEHAVIOR CHANGE: Retry on 503 status code.
-  - Add dataset.DeleteWithContents.
-  - Add SchemaUpdateOptions for query jobs.
-  - Add Timeline to QueryStatistics.
-  - Add more stats to ExplainQueryStage.
-  - Support Parquet data format.
-
-- datastore:
-  - Support omitempty for times.
-
-- dlp:
-  - **BREAKING CHANGE:** Remove v1beta1 client. Please migrate to the v2 client,
-  which is now out of beta.
-  - Add v2 client.
-
-- firestore:
-  - BEHAVIOR CHANGE: Treat set({}, MergeAll) as valid.
-
-- iam:
-  - Support JWT signing via SignJwt callopt.
-
-- profiler:
-  - BEHAVIOR CHANGE: PollForSerialOutput returns an error when context.Done.
-  - BEHAVIOR CHANGE: Increase the initial backoff to 1 minute.
-  - Avoid returning empty serial port output.
-
-- pubsub:
-  - BEHAVIOR CHANGE: Don't backoff during next retryable error once stream is healthy.
-  - BEHAVIOR CHANGE: Don't backoff on EOF.
-  - pstest: Support Acknowledge and ModifyAckDeadline RPCs.
-
-- redis:
-  - Add v1 beta Redis client.
-
-- spanner:
-  - Support SessionLabels.
-
-- speech:
-  - Add api v1 beta1 client.
-
-- storage:
-  - BEHAVIOR CHANGE: Retry reads when retryable error occurs.
-  - Fix delete of object in requester-pays bucket.
-  - Support KMS integration.
-
-## v0.21.0
-
-- bigquery:
-  - Add OpenCensus tracing.
-
-- firestore:
-  - **BREAKING CHANGE:** If a document does not exist, return a DocumentSnapshot
-    whose Exists method returns false. DocumentRef.Get and Transaction.Get
-    return the non-nil DocumentSnapshot in addition to a NotFound error.
-    **DocumentRef.GetAll and Transaction.GetAll return a non-nil
-    DocumentSnapshot instead of nil.**
-  - Add DocumentIterator.Stop. **Call Stop whenever you are done with a
-    DocumentIterator.**
-  - Added Query.Snapshots and DocumentRef.Snapshots, which provide realtime
-    notification of updates. See https://cloud.google.com/firestore/docs/query-data/listen.
-  - Canceling an RPC now always returns a grpc.Status with codes.Canceled.
-
-- spanner:
-  - Add `CommitTimestamp`, which supports inserting the commit timestamp of a
-    transaction into a column.
-
-## v0.20.0
-
-- bigquery: Support SchemaUpdateOptions for load jobs.
-
-- bigtable:
-  - Add SampleRowKeys.
-  - cbt: Support union, intersection GCPolicy.
-  - Retry admin RPCS.
-  - Add trace spans to retries.
-
-- datastore: Add OpenCensus tracing.
-
-- firestore:
-  - Fix queries involving Null and NaN.
-  - Allow Timestamp protobuffers for time values.
-
-- logging: Add a WriteTimeout option.
-
-- spanner: Support Batch API.
-
-- storage: Add OpenCensus tracing.
-
-## v0.19.0
-
-- bigquery:
-  - Support customer-managed encryption keys.
-
-- bigtable:
-  - Improved emulator support.
-  - Support GetCluster.
-
-- datastore:
-  - Add general mutations.
-  - Support pointer struct fields.
-  - Support transaction options.
-
-- firestore:
-  - Add Transaction.GetAll.
-  - Support document cursors.
-
-- logging:
-  - Support concurrent RPCs to the service.
-  - Support per-entry resources.
-
-- profiler:
-  - Add config options to disable heap and thread profiling.
-  - Read the project ID from $GOOGLE_CLOUD_PROJECT when it's set.
-
-- pubsub:
-  - BEHAVIOR CHANGE: Release flow control after ack/nack (instead of after the
-    callback returns).
-  - Add SubscriptionInProject.
-  - Add OpenCensus instrumentation for streaming pull.
-
-- storage:
-  - Support CORS.
-
-## v0.18.0
-
-- bigquery:
-  - Marked stable.
-  - Schema inference of nullable fields supported.
-  - Added TimePartitioning to QueryConfig.
-
-- firestore: Data provided to DocumentRef.Set with a Merge option can contain
-  Delete sentinels.
-
-- logging: Clients can accept parent resources other than projects.
-
-- pubsub:
-  - pubsub/pstest: A lighweight fake for pubsub. Experimental; feedback welcome.
-  - Support updating more subscription metadata: AckDeadline,
-    RetainAckedMessages and RetentionDuration.
-
-- oslogin/apiv1beta: New client for the Cloud OS Login API.
-
-- rpcreplay: A package for recording and replaying gRPC traffic.
-
-- spanner:
-  - Add a ReadWithOptions that supports a row limit, as well as an index.
-  - Support query plan and execution statistics.
-  - Added [OpenCensus](http://opencensus.io) support.
-
-- storage: Clarify checksum validation for gzipped files (it is not validated
-  when the file is served uncompressed).
-
-
-## v0.17.0
-
-- firestore BREAKING CHANGES:
-  - Remove UpdateMap and UpdateStruct; rename UpdatePaths to Update.
-    Change
-        `docref.UpdateMap(ctx, map[string]interface{}{"a.b", 1})`
-    to
-        `docref.Update(ctx, []firestore.Update{{Path: "a.b", Value: 1}})`
-
-    Change
-        `docref.UpdateStruct(ctx, []string{"Field"}, aStruct)`
-    to
-        `docref.Update(ctx, []firestore.Update{{Path: "Field", Value: aStruct.Field}})`
-  - Rename MergePaths to Merge; require args to be FieldPaths
-  - A value stored as an integer can be read into a floating-point field, and vice versa.
-- bigtable/cmd/cbt:
-  - Support deleting a column.
-  - Add regex option for row read.
-- spanner: Mark stable.
-- storage:
-  - Add Reader.ContentEncoding method.
-  - Fix handling of SignedURL headers.
-- bigquery:
-  - If Uploader.Put is called with no rows, it returns nil without making a
-    call.
-  - Schema inference supports the "nullable" option in struct tags for
-    non-required fields.
-  - TimePartitioning supports "Field".
-
-
-## v0.16.0
-
-- Other bigquery changes:
-  - `JobIterator.Next` returns `*Job`; removed `JobInfo` (BREAKING CHANGE).
-  - UseStandardSQL is deprecated; set UseLegacySQL to true if you need
-    Legacy SQL.
-  - Uploader.Put will generate a random insert ID if you do not provide one.
-  - Support time partitioning for load jobs.
-  - Support dry-run queries.
-  - A `Job` remembers its last retrieved status.
-  - Support retrieving job configuration.
-  - Support labels for jobs and tables.
-  - Support dataset access lists.
-  - Improve support for external data sources, including data from Bigtable and
-    Google Sheets, and tables with external data.
-  - Support updating a table's view configuration.
-  - Fix uploading civil times with nanoseconds.
-
-- storage:
-  - Support PubSub notifications.
-  - Support Requester Pays buckets.
-
-- profiler: Support goroutine and mutex profile types.
-
-## v0.15.0
-
-- firestore: beta release. See the
-  [announcement](https://firebase.googleblog.com/2017/10/introducing-cloud-firestore.html).
-
-- errorreporting: The existing package has been redesigned.
-
-- errors: This package has been removed. Use errorreporting.
-
-
-## v0.14.0
-
-- bigquery BREAKING CHANGES:
-  - Standard SQL is the default for queries and views.
-  - `Table.Create` takes `TableMetadata` as a second argument, instead of
-    options.
-  - `Dataset.Create` takes `DatasetMetadata` as a second argument.
-  - `DatasetMetadata` field `ID` renamed to `FullID`
-  - `TableMetadata` field `ID` renamed to `FullID`
-
-- Other bigquery changes:
-  - The client will append a random suffix to a provided job ID if you set
-    `AddJobIDSuffix` to true in a job config.
-  - Listing jobs is supported.
-  - Better retry logic.
-
-- vision, language, speech: clients are now stable
-
-- monitoring: client is now beta
-
-- profiler:
-  - Rename InstanceName to Instance, ZoneName to Zone
-  - Auto-detect service name and version on AppEngine.
-
-## v0.13.0
-
-- bigquery: UseLegacySQL options for CreateTable and QueryConfig. Use these
-  options to continue using Legacy SQL after the client switches its default
-  to Standard SQL.
-
-- bigquery: Support for updating dataset labels.
-
-- bigquery: Set DatasetIterator.ProjectID to list datasets in a project other
-  than the client's. DatasetsInProject is no longer needed and is deprecated.
-
-- bigtable: Fail ListInstances when any zones fail.
-
-- spanner: support decoding of slices of basic types (e.g. []string, []int64,
-  etc.)
-
-- logging/logadmin: UpdateSink no longer creates a sink if it is missing
-  (actually a change to the underlying service, not the client)
-
-- profiler: Service and ServiceVersion replace Target in Config.
-
-## v0.12.0
-
-- pubsub: Subscription.Receive now uses streaming pull.
-
-- pubsub: add Client.TopicInProject to access topics in a different project
-  than the client.
-
-- errors: renamed errorreporting. The errors package will be removed shortly.
-
-- datastore: improved retry behavior.
-
-- bigquery: support updates to dataset metadata, with etags.
-
-- bigquery: add etag support to Table.Update (BREAKING: etag argument added).
-
-- bigquery: generate all job IDs on the client.
-
-- storage: support bucket lifecycle configurations.
-
-
-## v0.11.0
-
-- Clients for spanner, pubsub and video are now in beta.
-
-- New client for DLP.
-
-- spanner: performance and testing improvements.
-
-- storage: requester-pays buckets are supported.
-
-- storage, profiler, bigtable, bigquery: bug fixes and other minor improvements.
-
-- pubsub: bug fixes and other minor improvements
-
-## v0.10.0
-
-- pubsub: Subscription.ModifyPushConfig replaced with Subscription.Update.
-
-- pubsub: Subscription.Receive now runs concurrently for higher throughput.
-
-- vision: cloud.google.com/go/vision is deprecated. Use
-cloud.google.com/go/vision/apiv1 instead.
-
-- translation: now stable.
-
-- trace: several changes to the surface. See the link below.
-
-### Code changes required from v0.9.0
-
-- pubsub: Replace
-
-    ```
-    sub.ModifyPushConfig(ctx, pubsub.PushConfig{Endpoint: "https://example.com/push"})
-    ```
-
-  with
-
-    ```
-    sub.Update(ctx, pubsub.SubscriptionConfigToUpdate{
-        PushConfig: &pubsub.PushConfig{Endpoint: "https://example.com/push"},
-    })
-    ```
-
-- trace: traceGRPCServerInterceptor will be provided from *trace.Client.
-Given an initialized `*trace.Client` named `tc`, instead of
-
-    ```
-    s := grpc.NewServer(grpc.UnaryInterceptor(trace.GRPCServerInterceptor(tc)))
-    ```
-
-  write
-
-    ```
-    s := grpc.NewServer(grpc.UnaryInterceptor(tc.GRPCServerInterceptor()))
-    ```
-
-- trace trace.GRPCClientInterceptor will also provided from *trace.Client.
-Instead of
-
-    ```
-    conn, err := grpc.Dial(srv.Addr, grpc.WithUnaryInterceptor(trace.GRPCClientInterceptor()))
-    ```
-
-  write
-
-    ```
-    conn, err := grpc.Dial(srv.Addr, grpc.WithUnaryInterceptor(tc.GRPCClientInterceptor()))
-    ```
-
-- trace: We removed the deprecated `trace.EnableGRPCTracing`. Use the gRPC
-interceptor as a dial option as shown below when initializing Cloud package
-clients:
-
-    ```
-    c, err := pubsub.NewClient(ctx, "project-id", option.WithGRPCDialOption(grpc.WithUnaryInterceptor(tc.GRPCClientInterceptor())))
-    if err != nil {
-        ...
-    }
-    ```
-
-
-## v0.9.0
-
-- Breaking changes to some autogenerated clients.
-- rpcreplay package added.
-
-## v0.8.0
-
-- profiler package added.
-- storage:
-  - Retry Objects.Insert call.
-  - Add ProgressFunc to WRiter.
-- pubsub: breaking changes:
-  - Publish is now asynchronous ([announcement](https://groups.google.com/d/topic/google-api-go-announce/aaqRDIQ3rvU/discussion)).
-  - Subscription.Pull replaced by Subscription.Receive, which takes a callback ([announcement](https://groups.google.com/d/topic/google-api-go-announce/8pt6oetAdKc/discussion)).
-  - Message.Done replaced with Message.Ack and Message.Nack.
-
-## v0.7.0
-
-- Release of a client library for Spanner. See
-the
-[blog
-post](https://cloudplatform.googleblog.com/2017/02/introducing-Cloud-Spanner-a-global-database-service-for-mission-critical-applications.html).
-Note that although the Spanner service is beta, the Go client library is alpha.
-
-## v0.6.0
-
-- Beta release of BigQuery, DataStore, Logging and Storage. See the
-[blog post](https://cloudplatform.googleblog.com/2016/12/announcing-new-google-cloud-client.html).
-
-- bigquery:
-  - struct support. Read a row directly into a struct with
-`RowIterator.Next`, and upload a row directly from a struct with `Uploader.Put`.
-You can also use field tags. See the [package documentation][cloud-bigquery-ref]
-for details.
-
-  - The `ValueList` type was removed. It is no longer necessary. Instead of
-   ```go
-   var v ValueList
-   ... it.Next(&v) ..
-   ```
-   use
-
-   ```go
-   var v []Value
-   ... it.Next(&v) ...
-   ```
-
-  - Previously, repeatedly calling `RowIterator.Next` on the same `[]Value` or
-  `ValueList` would append to the slice. Now each call resets the size to zero first.
-
-  - Schema inference will infer the SQL type BYTES for a struct field of
-  type []byte. Previously it inferred STRING.
-
-  - The types `uint`, `uint64` and `uintptr` are no longer supported in schema
-  inference. BigQuery's integer type is INT64, and those types may hold values
-  that are not correctly represented in a 64-bit signed integer.
-
-## v0.5.0
-
-- bigquery:
-  - The SQL types DATE, TIME and DATETIME are now supported. They correspond to
-    the `Date`, `Time` and `DateTime` types in the new `cloud.google.com/go/civil`
-    package.
-  - Support for query parameters.
-  - Support deleting a dataset.
-  - Values from INTEGER columns will now be returned as int64, not int. This
-    will avoid errors arising from large values on 32-bit systems.
-- datastore:
-  - Nested Go structs encoded as Entity values, instead of a
-flattened list of the embedded struct's fields. This means that you may now have twice-nested slices, eg.
-    ```go
-    type State struct {
-      Cities  []struct{
-        Populations []int
-      }
-    }
-    ```
-    See [the announcement](https://groups.google.com/forum/#!topic/google-api-go-announce/79jtrdeuJAg) for
-more details.
-  - Contexts no longer hold namespaces; instead you must set a key's namespace
-    explicitly. Also, key functions have been changed and renamed.
-  - The WithNamespace function has been removed. To specify a namespace in a Query, use the Query.Namespace method:
-     ```go
-     q := datastore.NewQuery("Kind").Namespace("ns")
-     ```
-  - All the fields of Key are exported. That means you can construct any Key with a struct literal:
-     ```go
-     k := &Key{Kind: "Kind",  ID: 37, Namespace: "ns"}
-     ```
-  - As a result of the above, the Key methods Kind, ID, d.Name, Parent, SetParent and Namespace have been removed.
-  - `NewIncompleteKey` has been removed, replaced by `IncompleteKey`. Replace
-      ```go
-      NewIncompleteKey(ctx, kind, parent)
-      ```
-      with
-      ```go
-      IncompleteKey(kind, parent)
-      ```
-      and if you do use namespaces, make sure you set the namespace on the returned key.
-  - `NewKey` has been removed, replaced by `NameKey` and `IDKey`. Replace
-      ```go
-      NewKey(ctx, kind, name, 0, parent)
-      NewKey(ctx, kind, "", id, parent)
-      ```
-      with
-      ```go
-      NameKey(kind, name, parent)
-      IDKey(kind, id, parent)
-      ```
-      and if you do use namespaces, make sure you set the namespace on the returned key.
-  - The `Done` variable has been removed. Replace `datastore.Done` with `iterator.Done`, from the package `google.golang.org/api/iterator`.
-  - The `Client.Close` method will have a return type of error. It will return the result of closing the underlying gRPC connection.
-  - See [the announcement](https://groups.google.com/forum/#!topic/google-api-go-announce/hqXtM_4Ix-0) for
-more details.
-
-## v0.4.0
-
-- bigquery:
-  -`NewGCSReference` is now a function, not a method on `Client`.
-  - `Table.LoaderFrom` now accepts a `ReaderSource`, enabling
-     loading data into a table from a file or any `io.Reader`.
-  * Client.Table and Client.OpenTable have been removed.
-      Replace
-      ```go
-      client.OpenTable("project", "dataset", "table")
-      ```
-      with
-      ```go
-      client.DatasetInProject("project", "dataset").Table("table")
-      ```
-
-  * Client.CreateTable has been removed.
-      Replace
-      ```go
-      client.CreateTable(ctx, "project", "dataset", "table")
-      ```
-      with
-      ```go
-      client.DatasetInProject("project", "dataset").Table("table").Create(ctx)
-      ```
-
-  * Dataset.ListTables have been replaced with Dataset.Tables.
-      Replace
-      ```go
-      tables, err := ds.ListTables(ctx)
-      ```
-      with
-      ```go
-      it := ds.Tables(ctx)
-      for {
-          table, err := it.Next()
-          if err == iterator.Done {
-              break
-          }
-          if err != nil {
-              // TODO: Handle error.
-          }
-          // TODO: use table.
-      }
-      ```
-
-  * Client.Read has been replaced with Job.Read, Table.Read and Query.Read.
-      Replace
-      ```go
-      it, err := client.Read(ctx, job)
-      ```
-      with
-      ```go
-      it, err := job.Read(ctx)
-      ```
-    and similarly for reading from tables or queries.
-
-  * The iterator returned from the Read methods is now named RowIterator. Its
-    behavior is closer to the other iterators in these libraries. It no longer
-    supports the Schema method; see the next item.
-      Replace
-      ```go
-      for it.Next(ctx) {
-          var vals ValueList
-          if err := it.Get(&vals); err != nil {
-              // TODO: Handle error.
-          }
-          // TODO: use vals.
-      }
-      if err := it.Err(); err != nil {
-          // TODO: Handle error.
-      }
-      ```
-      with
-      ```
-      for {
-          var vals ValueList
-          err := it.Next(&vals)
-          if err == iterator.Done {
-              break
-          }
-          if err != nil {
-              // TODO: Handle error.
-          }
-          // TODO: use vals.
-      }
-      ```
-      Instead of the `RecordsPerRequest(n)` option, write
-      ```go
-      it.PageInfo().MaxSize = n
-      ```
-      Instead of the `StartIndex(i)` option, write
-      ```go
-      it.StartIndex = i
-      ```
-
-  * ValueLoader.Load now takes a Schema in addition to a slice of Values.
-      Replace
-      ```go
-      func (vl *myValueLoader) Load(v []bigquery.Value)
-      ```
-      with
-      ```go
-      func (vl *myValueLoader) Load(v []bigquery.Value, s bigquery.Schema)
-      ```
-
-
-  * Table.Patch is replace by Table.Update.
-      Replace
-      ```go
-      p := table.Patch()
-      p.Description("new description")
-      metadata, err := p.Apply(ctx)
-      ```
-      with
-      ```go
-      metadata, err := table.Update(ctx, bigquery.TableMetadataToUpdate{
-          Description: "new description",
-      })
-      ```
-
-  * Client.Copy is replaced by separate methods for each of its four functions.
-    All options have been replaced by struct fields.
-
-    * To load data from Google Cloud Storage into a table, use Table.LoaderFrom.
-
-      Replace
-      ```go
-      client.Copy(ctx, table, gcsRef)
-      ```
-      with
-      ```go
-      table.LoaderFrom(gcsRef).Run(ctx)
-      ```
-      Instead of passing options to Copy, set fields on the Loader:
-      ```go
-      loader := table.LoaderFrom(gcsRef)
-      loader.WriteDisposition = bigquery.WriteTruncate
-      ```
-
-    * To extract data from a table into Google Cloud Storage, use
-      Table.ExtractorTo. Set fields on the returned Extractor instead of
-      passing options.
-
-      Replace
-      ```go
-      client.Copy(ctx, gcsRef, table)
-      ```
-      with
-      ```go
-      table.ExtractorTo(gcsRef).Run(ctx)
-      ```
-
-    * To copy data into a table from one or more other tables, use
-      Table.CopierFrom. Set fields on the returned Copier instead of passing options.
-
-      Replace
-      ```go
-      client.Copy(ctx, dstTable, srcTable)
-      ```
-      with
-      ```go
-      dst.Table.CopierFrom(srcTable).Run(ctx)
-      ```
-
-    * To start a query job, create a Query and call its Run method. Set fields
-    on the query instead of passing options.
-
-      Replace
-      ```go
-      client.Copy(ctx, table, query)
-      ```
-      with
-      ```go
-      query.Run(ctx)
-      ```
-
-  * Table.NewUploader has been renamed to Table.Uploader. Instead of options,
-    configure an Uploader by setting its fields.
-      Replace
-      ```go
-      u := table.NewUploader(bigquery.UploadIgnoreUnknownValues())
-      ```
-      with
-      ```go
-      u := table.NewUploader(bigquery.UploadIgnoreUnknownValues())
-      u.IgnoreUnknownValues = true
-      ```
-
-- pubsub: remove `pubsub.Done`. Use `iterator.Done` instead, where `iterator` is the package
-`google.golang.org/api/iterator`.
-
-## v0.3.0
-
-- storage:
-  * AdminClient replaced by methods on Client.
-      Replace
-      ```go
-      adminClient.CreateBucket(ctx, bucketName, attrs)
-      ```
-      with
-      ```go
-      client.Bucket(bucketName).Create(ctx, projectID, attrs)
-      ```
-
-  * BucketHandle.List replaced by BucketHandle.Objects.
-      Replace
-      ```go
-      for query != nil {
-          objs, err := bucket.List(d.ctx, query)
-          if err != nil { ... }
-          query = objs.Next
-          for _, obj := range objs.Results {
-              fmt.Println(obj)
-          }
-      }
-      ```
-      with
-      ```go
-      iter := bucket.Objects(d.ctx, query)
-      for {
-          obj, err := iter.Next()
-          if err == iterator.Done {
-              break
-          }
-          if err != nil { ... }
-          fmt.Println(obj)
-      }
-      ```
-      (The `iterator` package is at `google.golang.org/api/iterator`.)
-
-      Replace `Query.Cursor` with `ObjectIterator.PageInfo().Token`.
-
-      Replace `Query.MaxResults` with `ObjectIterator.PageInfo().MaxSize`.
-
-
-  * ObjectHandle.CopyTo replaced by ObjectHandle.CopierFrom.
-      Replace
-      ```go
-      attrs, err := src.CopyTo(ctx, dst, nil)
-      ```
-      with
-      ```go
-      attrs, err := dst.CopierFrom(src).Run(ctx)
-      ```
-
-      Replace
-      ```go
-      attrs, err := src.CopyTo(ctx, dst, &storage.ObjectAttrs{ContextType: "text/html"})
-      ```
-      with
-      ```go
-      c := dst.CopierFrom(src)
-      c.ContextType = "text/html"
-      attrs, err := c.Run(ctx)
-      ```
-
-  * ObjectHandle.ComposeFrom replaced by ObjectHandle.ComposerFrom.
-      Replace
-      ```go
-      attrs, err := dst.ComposeFrom(ctx, []*storage.ObjectHandle{src1, src2}, nil)
-      ```
-      with
-      ```go
-      attrs, err := dst.ComposerFrom(src1, src2).Run(ctx)
-      ```
-
-  * ObjectHandle.Update's ObjectAttrs argument replaced by ObjectAttrsToUpdate.
-      Replace
-      ```go
-      attrs, err := obj.Update(ctx, &storage.ObjectAttrs{ContextType: "text/html"})
-      ```
-      with
-      ```go
-      attrs, err := obj.Update(ctx, storage.ObjectAttrsToUpdate{ContextType: "text/html"})
-      ```
-
-  * ObjectHandle.WithConditions replaced by ObjectHandle.If.
-      Replace
-      ```go
-      obj.WithConditions(storage.Generation(gen), storage.IfMetaGenerationMatch(mgen))
-      ```
-      with
-      ```go
-      obj.Generation(gen).If(storage.Conditions{MetagenerationMatch: mgen})
-      ```
-
-      Replace
-      ```go
-      obj.WithConditions(storage.IfGenerationMatch(0))
-      ```
-      with
-      ```go
-      obj.If(storage.Conditions{DoesNotExist: true})
-      ```
-
-  * `storage.Done` replaced by `iterator.Done` (from package `google.golang.org/api/iterator`).
-
-- Package preview/logging deleted. Use logging instead.
-
-## v0.2.0
-
-- Logging client replaced with preview version (see below).
-
-- New clients for some of Google's Machine Learning APIs: Vision, Speech, and
-Natural Language.
-
-- Preview version of a new [Stackdriver Logging][cloud-logging] client in
-[`cloud.google.com/go/preview/logging`](https://godoc.org/cloud.google.com/go/preview/logging).
-This client uses gRPC as its transport layer, and supports log reading, sinks
-and metrics. It will replace the current client at `cloud.google.com/go/logging` shortly.
-
-

+ 0 - 44
vendor/cloud.google.com/go/CODE_OF_CONDUCT.md

@@ -1,44 +0,0 @@
-# Contributor Code of Conduct
-
-As contributors and maintainers of this project,
-and in the interest of fostering an open and welcoming community,
-we pledge to respect all people who contribute through reporting issues,
-posting feature requests, updating documentation,
-submitting pull requests or patches, and other activities.
-
-We are committed to making participation in this project
-a harassment-free experience for everyone,
-regardless of level of experience, gender, gender identity and expression,
-sexual orientation, disability, personal appearance,
-body size, race, ethnicity, age, religion, or nationality.
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery
-* Personal attacks
-* Trolling or insulting/derogatory comments
-* Public or private harassment
-* Publishing other's private information,
-such as physical or electronic
-addresses, without explicit permission
-* Other unethical or unprofessional conduct.
-
-Project maintainers have the right and responsibility to remove, edit, or reject
-comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct.
-By adopting this Code of Conduct,
-project maintainers commit themselves to fairly and consistently
-applying these principles to every aspect of managing this project.
-Project maintainers who do not follow or enforce the Code of Conduct
-may be permanently removed from the project team.
-
-This code of conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community.
-
-Instances of abusive, harassing, or otherwise unacceptable behavior
-may be reported by opening an issue
-or contacting one or more of the project maintainers.
-
-This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
-available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
-

+ 0 - 234
vendor/cloud.google.com/go/CONTRIBUTING.md

@@ -1,234 +0,0 @@
-# Contributing
-
-1. Sign one of the contributor license agreements below.
-1. `go get golang.org/x/review/git-codereview` to install the code reviewing
-tool.
-    1. You will need to ensure that your `GOBIN` directory (by default
-    `$GOPATH/bin`) is in your `PATH` so that git can find the command.
-    1. If you would like, you may want to set up aliases for git-codereview,
-    such that `git codereview change` becomes `git change`. See the
-    [godoc](https://godoc.org/golang.org/x/review/git-codereview) for details.
-    1. Should you run into issues with the git-codereview tool, please note
-    that all error messages will assume that you have set up these aliases.
-1. Get the cloud package by running `go get -d cloud.google.com/go`.
-    1. If you have already checked out the source, make sure that the remote
-    git origin is https://code.googlesource.com/gocloud:
-
-        ```
-        git remote set-url origin https://code.googlesource.com/gocloud
-        ```
-
-1. Make sure your auth is configured correctly by visiting
-https://code.googlesource.com, clicking "Generate Password", and following the
-directions.
-1. Make changes and create a change by running `git codereview change <name>`,
-provide a commit message, and use `git codereview mail` to create a Gerrit CL.
-1. Keep amending to the change with `git codereview change` and mail as your
-receive feedback. Each new mailed amendment will create a new patch set for
-your change in Gerrit.
-
-## Integration Tests
-
-In addition to the unit tests, you may run the integration test suite. These
-directions describe setting up your environment to run integration tests for
-_all_ packages: note that many of these instructions may be redundant if you
-intend only to run integration tests on a single package.
-
-#### GCP Setup
-
-To run the integrations tests, creation and configuration of two projects in
-the Google Developers Console is required: one specifically for Firestore
-integration tests, and another for all other integration tests. We'll refer to
-these projects as "general project" and "Firestore project".
-
-After creating each project, you must [create a service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount)
-for each project. Ensure the project-level **Owner**
-[IAM role](console.cloud.google.com/iam-admin/iam/project) role is added to
-each service account. During the creation of the service account, you should
-download the JSON credential file for use later.
-
-Next, ensure the following APIs are enabled in the general project:
-
-- BigQuery API
-- BigQuery Data Transfer API
-- Cloud Dataproc API
-- Cloud Dataproc Control API Private
-- Cloud Datastore API
-- Cloud Firestore API
-- Cloud Key Management Service (KMS) API
-- Cloud Natural Language API
-- Cloud OS Login API
-- Cloud Pub/Sub API
-- Cloud Resource Manager API
-- Cloud Spanner API
-- Cloud Speech API
-- Cloud Translation API
-- Cloud Video Intelligence API
-- Cloud Vision API
-- Compute Engine API
-- Compute Engine Instance Group Manager API
-- Container Registry API
-- Firebase Rules API
-- Google Cloud APIs
-- Google Cloud Deployment Manager V2 API
-- Google Cloud SQL
-- Google Cloud Storage
-- Google Cloud Storage JSON API
-- Google Compute Engine Instance Group Updater API
-- Google Compute Engine Instance Groups API
-- Kubernetes Engine API
-- Stackdriver Error Reporting API
-
-Next, create a Datastore database in the general project, and a Firestore
-database in the Firestore project.
-
-Finally, in the general project, create an API key for the translate API:
-
-- Go to GCP Developer Console.
-- Navigate to APIs & Services > Credentials.
-- Click Create Credentials > API Key.
-- Save this key for use in `GCLOUD_TESTS_API_KEY` as described below.
-
-#### Local Setup
-
-Once the two projects are created and configured, set the following environment
-variables:
-
-- `GCLOUD_TESTS_GOLANG_PROJECT_ID`: Developers Console project's ID (e.g.
-bamboo-shift-455) for the general project.
-- `GCLOUD_TESTS_GOLANG_KEY`: The path to the JSON key file of the general
-project's service account.
-- `GCLOUD_TESTS_GOLANG_FIRESTORE_PROJECT_ID`: Developers Console project's ID
-(e.g. doorway-cliff-677) for the Firestore project.
-- `GCLOUD_TESTS_GOLANG_FIRESTORE_KEY`: The path to the JSON key file of the
-Firestore project's service account.
-- `GCLOUD_TESTS_GOLANG_KEYRING`: The full name of the keyring for the tests,
-in the form
-"projects/P/locations/L/keyRings/R". The creation of this is described below.
-- `GCLOUD_TESTS_API_KEY`: API key for using the Translate API.
-- `GCLOUD_TESTS_GOLANG_ZONE`: Compute Engine zone.
-
-Install the [gcloud command-line tool][gcloudcli] to your machine and use it to
-create some resources used in integration tests.
-
-From the project's root directory:
-
-``` sh
-# Sets the default project in your env.
-$ gcloud config set project $GCLOUD_TESTS_GOLANG_PROJECT_ID
-
-# Authenticates the gcloud tool with your account.
-$ gcloud auth login
-
-# Create the indexes used in the datastore integration tests.
-$ gcloud datastore create-indexes datastore/testdata/index.yaml
-
-# Creates a Google Cloud storage bucket with the same name as your test project,
-# and with the Stackdriver Logging service account as owner, for the sink
-# integration tests in logging.
-$ gsutil mb gs://$GCLOUD_TESTS_GOLANG_PROJECT_ID
-$ gsutil acl ch -g cloud-logs@google.com:O gs://$GCLOUD_TESTS_GOLANG_PROJECT_ID
-
-# Creates a PubSub topic for integration tests of storage notifications.
-$ gcloud beta pubsub topics create go-storage-notification-test
-# Next, go to the Pub/Sub dashboard in GCP console. Authorize the user
-# "service-<numberic project id>@gs-project-accounts.iam.gserviceaccount.com"
-# as a publisher to that topic.
-
-# Creates a Spanner instance for the spanner integration tests.
-$ gcloud beta spanner instances create go-integration-test --config regional-us-central1 --nodes 10 --description 'Instance for go client test'
-# NOTE: Spanner instances are priced by the node-hour, so you may want to
-# delete the instance after testing with 'gcloud beta spanner instances delete'.
-
-$ export MY_KEYRING=some-keyring-name
-$ export MY_LOCATION=global
-# Creates a KMS keyring, in the same location as the default location for your
-# project's buckets.
-$ gcloud kms keyrings create $MY_KEYRING --location $MY_LOCATION
-# Creates two keys in the keyring, named key1 and key2.
-$ gcloud kms keys create key1 --keyring $MY_KEYRING --location $MY_LOCATION --purpose encryption
-$ gcloud kms keys create key2 --keyring $MY_KEYRING --location $MY_LOCATION --purpose encryption
-# Sets the GCLOUD_TESTS_GOLANG_KEYRING environment variable.
-$ export GCLOUD_TESTS_GOLANG_KEYRING=projects/$GCLOUD_TESTS_GOLANG_PROJECT_ID/locations/$MY_LOCATION/keyRings/$MY_KEYRING
-# Authorizes Google Cloud Storage to encrypt and decrypt using key1.
-gsutil kms authorize -p $GCLOUD_TESTS_GOLANG_PROJECT_ID -k $GCLOUD_TESTS_GOLANG_KEYRING/cryptoKeys/key1
-```
-
-#### Running
-
-Once you've done the necessary setup, you can run the integration tests by
-running:
-
-``` sh
-$ go test -v cloud.google.com/go/...
-```
-
-#### Replay
-
-Some packages can record the RPCs during integration tests to a file for
-subsequent replay. To record, pass the `-record` flag to `go test`. The
-recording will be saved to the _package_`.replay` file. To replay integration
-tests from a saved recording, the replay file must be present, the `-short`
-flag must be passed to `go test`, and the `GCLOUD_TESTS_GOLANG_ENABLE_REPLAY`
-environment variable must have a non-empty value.
-
-## Contributor License Agreements
-
-Before we can accept your pull requests you'll need to sign a Contributor
-License Agreement (CLA):
-
-- **If you are an individual writing original source code** and **you own the
-intellectual property**, then you'll need to sign an [individual CLA][indvcla].
-- **If you work for a company that wants to allow you to contribute your
-work**, then you'll need to sign a [corporate CLA][corpcla].
-
-You can sign these electronically (just scroll to the bottom). After that,
-we'll be able to accept your pull requests.
-
-## Contributor Code of Conduct
-
-As contributors and maintainers of this project,
-and in the interest of fostering an open and welcoming community,
-we pledge to respect all people who contribute through reporting issues,
-posting feature requests, updating documentation,
-submitting pull requests or patches, and other activities.
-
-We are committed to making participation in this project
-a harassment-free experience for everyone,
-regardless of level of experience, gender, gender identity and expression,
-sexual orientation, disability, personal appearance,
-body size, race, ethnicity, age, religion, or nationality.
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery
-* Personal attacks
-* Trolling or insulting/derogatory comments
-* Public or private harassment
-* Publishing other's private information,
-such as physical or electronic
-addresses, without explicit permission
-* Other unethical or unprofessional conduct.
-
-Project maintainers have the right and responsibility to remove, edit, or reject
-comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct.
-By adopting this Code of Conduct,
-project maintainers commit themselves to fairly and consistently
-applying these principles to every aspect of managing this project.
-Project maintainers who do not follow or enforce the Code of Conduct
-may be permanently removed from the project team.
-
-This code of conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community.
-
-Instances of abusive, harassing, or otherwise unacceptable behavior
-may be reported by opening an issue
-or contacting one or more of the project maintainers.
-
-This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
-available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
-
-[gcloudcli]: https://developers.google.com/cloud/sdk/gcloud/
-[indvcla]: https://developers.google.com/open-source/cla/individual
-[corpcla]: https://developers.google.com/open-source/cla/corporate

+ 0 - 40
vendor/cloud.google.com/go/CONTRIBUTORS

@@ -1,40 +0,0 @@
-# People who have agreed to one of the CLAs and can contribute patches.
-# The AUTHORS file lists the copyright holders; this file
-# lists people.  For example, Google employees are listed here
-# but not in AUTHORS, because Google holds the copyright.
-#
-# https://developers.google.com/open-source/cla/individual
-# https://developers.google.com/open-source/cla/corporate
-#
-# Names should be added to this file as:
-#     Name <email address>
-
-# Keep the list alphabetically sorted.
-
-Alexis Hunt <lexer@google.com>
-Andreas Litt <andreas.litt@gmail.com>
-Andrew Gerrand <adg@golang.org>
-Brad Fitzpatrick <bradfitz@golang.org>
-Burcu Dogan <jbd@google.com>
-Dave Day <djd@golang.org>
-David Sansome <me@davidsansome.com>
-David Symonds <dsymonds@golang.org>
-Filippo Valsorda <hi@filippo.io>
-Glenn Lewis <gmlewis@google.com>
-Ingo Oeser <nightlyone@googlemail.com>
-James Hall <james.hall@shopify.com>
-Johan Euphrosine <proppy@google.com>
-Jonathan Amsterdam <jba@google.com>
-Kunpei Sakai <namusyaka@gmail.com>
-Luna Duclos <luna.duclos@palmstonegames.com>
-Magnus Hiie <magnus.hiie@gmail.com>
-Mario Castro <mariocaster@gmail.com>
-Michael McGreevy <mcgreevy@golang.org>
-Omar Jarjur <ojarjur@google.com>
-Paweł Knap <pawelknap88@gmail.com>
-Péter Szilágyi <peterke@gmail.com>
-Sarah Adams <shadams@google.com>
-Thanatat Tamtan <acoshift@gmail.com>
-Toby Burress <kurin@google.com>
-Tuo Shan <shantuo@google.com>
-Tyler Treat <ttreat31@gmail.com>

+ 0 - 202
vendor/cloud.google.com/go/LICENSE

@@ -1,202 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   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
-
-       http://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.

+ 0 - 505
vendor/cloud.google.com/go/README.md

@@ -1,505 +0,0 @@
-# Google Cloud Client Libraries for Go
-
-[![GoDoc](https://godoc.org/cloud.google.com/go?status.svg)](https://godoc.org/cloud.google.com/go)
-
-Go packages for [Google Cloud Platform](https://cloud.google.com) services.
-
-``` go
-import "cloud.google.com/go"
-```
-
-To install the packages on your system, *do not clone the repo*. Instead use
-
-```
-$ go get -u cloud.google.com/go/...
-```
-
-**NOTE:** Some of these packages are under development, and may occasionally
-make backwards-incompatible changes.
-
-**NOTE:** Github repo is a mirror of [https://code.googlesource.com/gocloud](https://code.googlesource.com/gocloud).
-
-  * [News](#news)
-  * [Supported APIs](#supported-apis)
-  * [Go Versions Supported](#go-versions-supported)
-  * [Authorization](#authorization)
-  * [Cloud Datastore](#cloud-datastore-)
-  * [Cloud Storage](#cloud-storage-)
-  * [Cloud Pub/Sub](#cloud-pub-sub-)
-  * [BigQuery](#cloud-bigquery-)
-  * [Stackdriver Logging](#stackdriver-logging-)
-  * [Cloud Spanner](#cloud-spanner-)
-
-
-## News
-
-_7 August 2018_
-
-As of November 1, the code in the repo will no longer support Go versions 1.8
-and earlier. No one other than AppEngine users should be on those old versions,
-and AppEngine
-[Standard](https://groups.google.com/forum/#!topic/google-appengine-go/e7oPNomd7ak)
-and
-[Flex](https://groups.google.com/forum/#!topic/google-appengine-go/wHsYtxvEbXI)
-will stop supporting new deployments with those versions on that date.
-
-
-Changes have been moved to [CHANGES](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/CHANGES.md).
-
-
-## Supported APIs
-
-Google API                                   | Status       | Package
----------------------------------------------|--------------|-----------------------------------------------------------
-[Asset][cloud-asset]                         | alpha        | [`cloud.google.com/go/asset/v1beta`][cloud-asset-ref]
-[BigQuery][cloud-bigquery]                   | stable       | [`cloud.google.com/go/bigquery`][cloud-bigquery-ref]
-[Bigtable][cloud-bigtable]                   | stable       | [`cloud.google.com/go/bigtable`][cloud-bigtable-ref]
-[Cloudtasks][cloud-tasks]                    | beta         | [`cloud.google.com/go/cloudtasks/apiv2beta3`][cloud-tasks-ref]
-[Container][cloud-container]                 | stable       | [`cloud.google.com/go/container/apiv1`][cloud-container-ref]
-[ContainerAnalysis][cloud-containeranalysis] | beta         | [`cloud.google.com/go/containeranalysis/apiv1beta1`][cloud-containeranalysis-ref]
-[Dataproc][cloud-dataproc]                   | stable       | [`cloud.google.com/go/dataproc/apiv1`][cloud-dataproc-ref]
-[Datastore][cloud-datastore]                 | stable       | [`cloud.google.com/go/datastore`][cloud-datastore-ref]
-[Debugger][cloud-debugger]                   | alpha        | [`cloud.google.com/go/debugger/apiv2`][cloud-debugger-ref]
-[Dialogflow][cloud-dialogflow]               | alpha        | [`cloud.google.com/go/dialogflow/apiv2`][cloud-dialogflow-ref]
-[Data Loss Prevention][cloud-dlp]            | alpha        | [`cloud.google.com/go/dlp/apiv2`][cloud-dlp-ref]
-[ErrorReporting][cloud-errors]               | alpha        | [`cloud.google.com/go/errorreporting`][cloud-errors-ref]
-[Firestore][cloud-firestore]                 | beta         | [`cloud.google.com/go/firestore`][cloud-firestore-ref]
-[IAM][cloud-iam]                             | stable       | [`cloud.google.com/go/iam`][cloud-iam-ref]
-[KMS][cloud-kms]                             | stable       | [`cloud.google.com/go/kms`][cloud-kms-ref]
-[Natural Language][cloud-natural-language]   | stable       | [`cloud.google.com/go/language/apiv1`][cloud-natural-language-ref]
-[Logging][cloud-logging]                     | stable       | [`cloud.google.com/go/logging`][cloud-logging-ref]
-[Monitoring][cloud-monitoring]               | alpha        | [`cloud.google.com/go/monitoring/apiv3`][cloud-monitoring-ref]
-[OS Login][cloud-oslogin]                    | alpha        | [`cloud.google.com/compute/docs/oslogin/rest`][cloud-oslogin-ref]
-[Pub/Sub][cloud-pubsub]                      | stable       | [`cloud.google.com/go/pubsub`][cloud-pubsub-ref]
-[Memorystore][cloud-memorystore]             | stable       | [`cloud.google.com/go/redis/apiv1beta1`][cloud-memorystore-ref]
-[Spanner][cloud-spanner]                     | stable       | [`cloud.google.com/go/spanner`][cloud-spanner-ref]
-[Speech][cloud-speech]                       | stable       | [`cloud.google.com/go/speech/apiv1`][cloud-speech-ref]
-[Storage][cloud-storage]                     | stable       | [`cloud.google.com/go/storage`][cloud-storage-ref]
-[Text To Speech][cloud-texttospeech]         | alpha        | [`cloud.google.com/go/texttospeech/apiv1`][cloud-storage-ref]
-[Trace][cloud-trace]                         | alpha        | [`cloud.google.com/go/trace/apiv2`][cloud-translation-ref]
-[Translation][cloud-translation]             | stable       | [`cloud.google.com/go/translate`][cloud-translation-ref]
-[Video Intelligence][cloud-video]            | alpha        | [`cloud.google.com/go/videointelligence/apiv1beta1`][cloud-video-ref]
-[Vision][cloud-vision]                       | stable       | [`cloud.google.com/go/vision/apiv1`][cloud-vision-ref]
-
-> **Alpha status**: the API is still being actively developed. As a
-> result, it might change in backward-incompatible ways and is not recommended
-> for production use.
->
-> **Beta status**: the API is largely complete, but still has outstanding
-> features and bugs to be addressed. There may be minor backwards-incompatible
-> changes where necessary.
->
-> **Stable status**: the API is mature and ready for production use. We will
-> continue addressing bugs and feature requests.
-
-Documentation and examples are available at
-https://godoc.org/cloud.google.com/go
-
-Visit or join the
-[google-api-go-announce group](https://groups.google.com/forum/#!forum/google-api-go-announce)
-for updates on these packages.
-
-## Go Versions Supported
-
-We support the two most recent major versions of Go. If Google App Engine uses
-an older version, we support that as well.
-
-## Authorization
-
-By default, each API will use [Google Application Default Credentials][default-creds]
-for authorization credentials used in calling the API endpoints. This will allow your
-application to run in many environments without requiring explicit configuration.
-
-[snip]:# (auth)
-```go
-client, err := storage.NewClient(ctx)
-```
-
-To authorize using a
-[JSON key file](https://cloud.google.com/iam/docs/managing-service-account-keys),
-pass
-[`option.WithCredentialsFile`](https://godoc.org/google.golang.org/api/option#WithCredentialsFile)
-to the `NewClient` function of the desired package. For example:
-
-[snip]:# (auth-JSON)
-```go
-client, err := storage.NewClient(ctx, option.WithCredentialsFile("path/to/keyfile.json"))
-```
-
-You can exert more control over authorization by using the
-[`golang.org/x/oauth2`](https://godoc.org/golang.org/x/oauth2) package to
-create an `oauth2.TokenSource`. Then pass
-[`option.WithTokenSource`](https://godoc.org/google.golang.org/api/option#WithTokenSource)
-to the `NewClient` function:
-[snip]:# (auth-ts)
-```go
-tokenSource := ...
-client, err := storage.NewClient(ctx, option.WithTokenSource(tokenSource))
-```
-
-## Cloud Datastore [![GoDoc](https://godoc.org/cloud.google.com/go/datastore?status.svg)](https://godoc.org/cloud.google.com/go/datastore)
-
-- [About Cloud Datastore][cloud-datastore]
-- [Activating the API for your project][cloud-datastore-activation]
-- [API documentation][cloud-datastore-docs]
-- [Go client documentation](https://godoc.org/cloud.google.com/go/datastore)
-- [Complete sample program](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/datastore/tasks)
-
-### Example Usage
-
-First create a `datastore.Client` to use throughout your application:
-
-[snip]:# (datastore-1)
-```go
-client, err := datastore.NewClient(ctx, "my-project-id")
-if err != nil {
-	log.Fatal(err)
-}
-```
-
-Then use that client to interact with the API:
-
-[snip]:# (datastore-2)
-```go
-type Post struct {
-	Title       string
-	Body        string `datastore:",noindex"`
-	PublishedAt time.Time
-}
-keys := []*datastore.Key{
-	datastore.NameKey("Post", "post1", nil),
-	datastore.NameKey("Post", "post2", nil),
-}
-posts := []*Post{
-	{Title: "Post 1", Body: "...", PublishedAt: time.Now()},
-	{Title: "Post 2", Body: "...", PublishedAt: time.Now()},
-}
-if _, err := client.PutMulti(ctx, keys, posts); err != nil {
-	log.Fatal(err)
-}
-```
-
-## Cloud Storage [![GoDoc](https://godoc.org/cloud.google.com/go/storage?status.svg)](https://godoc.org/cloud.google.com/go/storage)
-
-- [About Cloud Storage][cloud-storage]
-- [API documentation][cloud-storage-docs]
-- [Go client documentation](https://godoc.org/cloud.google.com/go/storage)
-- [Complete sample programs](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/storage)
-
-### Example Usage
-
-First create a `storage.Client` to use throughout your application:
-
-[snip]:# (storage-1)
-```go
-client, err := storage.NewClient(ctx)
-if err != nil {
-	log.Fatal(err)
-}
-```
-
-[snip]:# (storage-2)
-```go
-// Read the object1 from bucket.
-rc, err := client.Bucket("bucket").Object("object1").NewReader(ctx)
-if err != nil {
-	log.Fatal(err)
-}
-defer rc.Close()
-body, err := ioutil.ReadAll(rc)
-if err != nil {
-	log.Fatal(err)
-}
-```
-
-## Cloud Pub/Sub [![GoDoc](https://godoc.org/cloud.google.com/go/pubsub?status.svg)](https://godoc.org/cloud.google.com/go/pubsub)
-
-- [About Cloud Pubsub][cloud-pubsub]
-- [API documentation][cloud-pubsub-docs]
-- [Go client documentation](https://godoc.org/cloud.google.com/go/pubsub)
-- [Complete sample programs](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/pubsub)
-
-### Example Usage
-
-First create a `pubsub.Client` to use throughout your application:
-
-[snip]:# (pubsub-1)
-```go
-client, err := pubsub.NewClient(ctx, "project-id")
-if err != nil {
-	log.Fatal(err)
-}
-```
-
-Then use the client to publish and subscribe:
-
-[snip]:# (pubsub-2)
-```go
-// Publish "hello world" on topic1.
-topic := client.Topic("topic1")
-res := topic.Publish(ctx, &pubsub.Message{
-	Data: []byte("hello world"),
-})
-// The publish happens asynchronously.
-// Later, you can get the result from res:
-...
-msgID, err := res.Get(ctx)
-if err != nil {
-	log.Fatal(err)
-}
-
-// Use a callback to receive messages via subscription1.
-sub := client.Subscription("subscription1")
-err = sub.Receive(ctx, func(ctx context.Context, m *pubsub.Message) {
-	fmt.Println(m.Data)
-	m.Ack() // Acknowledge that we've consumed the message.
-})
-if err != nil {
-	log.Println(err)
-}
-```
-
-## BigQuery [![GoDoc](https://godoc.org/cloud.google.com/go/bigquery?status.svg)](https://godoc.org/cloud.google.com/go/bigquery)
-
-- [About BigQuery][cloud-bigquery]
-- [API documentation][cloud-bigquery-docs]
-- [Go client documentation][cloud-bigquery-ref]
-- [Complete sample programs](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/bigquery)
-
-### Example Usage
-
-First create a `bigquery.Client` to use throughout your application:
-[snip]:# (bq-1)
-```go
-c, err := bigquery.NewClient(ctx, "my-project-ID")
-if err != nil {
-	// TODO: Handle error.
-}
-```
-
-Then use that client to interact with the API:
-[snip]:# (bq-2)
-```go
-// Construct a query.
-q := c.Query(`
-    SELECT year, SUM(number)
-    FROM [bigquery-public-data:usa_names.usa_1910_2013]
-    WHERE name = "William"
-    GROUP BY year
-    ORDER BY year
-`)
-// Execute the query.
-it, err := q.Read(ctx)
-if err != nil {
-	// TODO: Handle error.
-}
-// Iterate through the results.
-for {
-	var values []bigquery.Value
-	err := it.Next(&values)
-	if err == iterator.Done {
-		break
-	}
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(values)
-}
-```
-
-
-## Stackdriver Logging [![GoDoc](https://godoc.org/cloud.google.com/go/logging?status.svg)](https://godoc.org/cloud.google.com/go/logging)
-
-- [About Stackdriver Logging][cloud-logging]
-- [API documentation][cloud-logging-docs]
-- [Go client documentation][cloud-logging-ref]
-- [Complete sample programs](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/logging)
-
-### Example Usage
-
-First create a `logging.Client` to use throughout your application:
-[snip]:# (logging-1)
-```go
-ctx := context.Background()
-client, err := logging.NewClient(ctx, "my-project")
-if err != nil {
-	// TODO: Handle error.
-}
-```
-
-Usually, you'll want to add log entries to a buffer to be periodically flushed
-(automatically and asynchronously) to the Stackdriver Logging service.
-[snip]:# (logging-2)
-```go
-logger := client.Logger("my-log")
-logger.Log(logging.Entry{Payload: "something happened!"})
-```
-
-Close your client before your program exits, to flush any buffered log entries.
-[snip]:# (logging-3)
-```go
-err = client.Close()
-if err != nil {
-	// TODO: Handle error.
-}
-```
-
-## Cloud Spanner [![GoDoc](https://godoc.org/cloud.google.com/go/spanner?status.svg)](https://godoc.org/cloud.google.com/go/spanner)
-
-- [About Cloud Spanner][cloud-spanner]
-- [API documentation][cloud-spanner-docs]
-- [Go client documentation](https://godoc.org/cloud.google.com/go/spanner)
-
-### Example Usage
-
-First create a `spanner.Client` to use throughout your application:
-
-[snip]:# (spanner-1)
-```go
-client, err := spanner.NewClient(ctx, "projects/P/instances/I/databases/D")
-if err != nil {
-	log.Fatal(err)
-}
-```
-
-[snip]:# (spanner-2)
-```go
-// Simple Reads And Writes
-_, err = client.Apply(ctx, []*spanner.Mutation{
-	spanner.Insert("Users",
-		[]string{"name", "email"},
-		[]interface{}{"alice", "a@example.com"})})
-if err != nil {
-	log.Fatal(err)
-}
-row, err := client.Single().ReadRow(ctx, "Users",
-	spanner.Key{"alice"}, []string{"email"})
-if err != nil {
-	log.Fatal(err)
-}
-```
-
-
-## Contributing
-
-Contributions are welcome. Please, see the
-[CONTRIBUTING](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/CONTRIBUTING.md)
-document for details. We're using Gerrit for our code reviews. Please don't open pull
-requests against this repo, new pull requests will be automatically closed.
-
-Please note that this project is released with a Contributor Code of Conduct.
-By participating in this project you agree to abide by its terms.
-See [Contributor Code of Conduct](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/CONTRIBUTING.md#contributor-code-of-conduct)
-for more information.
-
-[cloud-datastore]: https://cloud.google.com/datastore/
-[cloud-datastore-ref]: https://godoc.org/cloud.google.com/go/datastore
-[cloud-datastore-docs]: https://cloud.google.com/datastore/docs
-[cloud-datastore-activation]: https://cloud.google.com/datastore/docs/activate
-
-[cloud-firestore]: https://cloud.google.com/firestore/
-[cloud-firestore-ref]: https://godoc.org/cloud.google.com/go/firestore
-[cloud-firestore-docs]: https://cloud.google.com/firestore/docs
-[cloud-firestore-activation]: https://cloud.google.com/firestore/docs/activate
-
-[cloud-pubsub]: https://cloud.google.com/pubsub/
-[cloud-pubsub-ref]: https://godoc.org/cloud.google.com/go/pubsub
-[cloud-pubsub-docs]: https://cloud.google.com/pubsub/docs
-
-[cloud-storage]: https://cloud.google.com/storage/
-[cloud-storage-ref]: https://godoc.org/cloud.google.com/go/storage
-[cloud-storage-docs]: https://cloud.google.com/storage/docs
-[cloud-storage-create-bucket]: https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets
-
-[cloud-bigtable]: https://cloud.google.com/bigtable/
-[cloud-bigtable-ref]: https://godoc.org/cloud.google.com/go/bigtable
-
-[cloud-bigquery]: https://cloud.google.com/bigquery/
-[cloud-bigquery-docs]: https://cloud.google.com/bigquery/docs
-[cloud-bigquery-ref]: https://godoc.org/cloud.google.com/go/bigquery
-
-[cloud-logging]: https://cloud.google.com/logging/
-[cloud-logging-docs]: https://cloud.google.com/logging/docs
-[cloud-logging-ref]: https://godoc.org/cloud.google.com/go/logging
-
-[cloud-monitoring]: https://cloud.google.com/monitoring/
-[cloud-monitoring-ref]: https://godoc.org/cloud.google.com/go/monitoring/apiv3
-
-[cloud-vision]: https://cloud.google.com/vision
-[cloud-vision-ref]: https://godoc.org/cloud.google.com/go/vision/apiv1
-
-[cloud-language]: https://cloud.google.com/natural-language
-[cloud-language-ref]: https://godoc.org/cloud.google.com/go/language/apiv1
-
-[cloud-oslogin]: https://cloud.google.com/compute/docs/oslogin/rest
-[cloud-oslogin-ref]: https://cloud.google.com/compute/docs/oslogin/rest
-
-[cloud-speech]: https://cloud.google.com/speech
-[cloud-speech-ref]: https://godoc.org/cloud.google.com/go/speech/apiv1
-
-[cloud-spanner]: https://cloud.google.com/spanner/
-[cloud-spanner-ref]: https://godoc.org/cloud.google.com/go/spanner
-[cloud-spanner-docs]: https://cloud.google.com/spanner/docs
-
-[cloud-translation]: https://cloud.google.com/translation
-[cloud-translation-ref]: https://godoc.org/cloud.google.com/go/translation
-
-[cloud-video]: https://cloud.google.com/video-intelligence/
-[cloud-video-ref]: https://godoc.org/cloud.google.com/go/videointelligence/apiv1beta1
-
-[cloud-errors]: https://cloud.google.com/error-reporting/
-[cloud-errors-ref]: https://godoc.org/cloud.google.com/go/errorreporting
-
-[cloud-container]: https://cloud.google.com/containers/
-[cloud-container-ref]: https://godoc.org/cloud.google.com/go/container/apiv1
-
-[cloud-debugger]: https://cloud.google.com/debugger/
-[cloud-debugger-ref]: https://godoc.org/cloud.google.com/go/debugger/apiv2
-
-[cloud-dlp]: https://cloud.google.com/dlp/
-[cloud-dlp-ref]: https://godoc.org/cloud.google.com/go/dlp/apiv2beta1
-
-[default-creds]: https://developers.google.com/identity/protocols/application-default-credentials
-
-[cloud-dataproc]: https://cloud.google.com/dataproc/
-[cloud-dataproc-docs]: https://cloud.google.com/dataproc/docs
-[cloud-dataproc-ref]: https://godoc.org/cloud.google.com/go/dataproc/apiv1
-
-[cloud-iam]: https://cloud.google.com/iam/
-[cloud-iam-docs]: https://cloud.google.com/iam/docs
-[cloud-iam-ref]: https://godoc.org/cloud.google.com/go/iam
-
-[cloud-kms]: https://cloud.google.com/kms/
-[cloud-kms-docs]: https://cloud.google.com/kms/docs
-[cloud-kms-ref]: https://godoc.org/cloud.google.com/go/kms/apiv1
-
-[cloud-natural-language]: https://cloud.google.com/natural-language/
-[cloud-natural-language-docs]: https://cloud.google.com/natural-language/docs
-[cloud-natural-language-ref]: https://godoc.org/cloud.google.com/go/language/apiv1
-
-[cloud-memorystore]: https://cloud.google.com/memorystore/
-[cloud-memorystore-docs]: https://cloud.google.com/memorystore/docs
-[cloud-memorystore-ref]: https://godoc.org/cloud.google.com/go/redis/apiv1beta1
-
-[cloud-texttospeech]: https://cloud.google.com/texttospeech/
-[cloud-texttospeech-docs]: https://cloud.google.com/texttospeech/docs
-[cloud-texttospeech-ref]: https://godoc.org/cloud.google.com/go/texttospeech/apiv1
-
-[cloud-trace]: https://cloud.google.com/trace/
-[cloud-trace-docs]: https://cloud.google.com/trace/docs
-[cloud-trace-ref]: https://godoc.org/cloud.google.com/go/trace/apiv1
-
-[cloud-dialogflow]: https://cloud.google.com/dialogflow-enterprise/
-[cloud-dialogflow-docs]: https://cloud.google.com/dialogflow-enterprise/docs/
-[cloud-dialogflow-ref]: https://godoc.org/cloud.google.com/go/dialogflow/apiv2
-
-[cloud-containeranalysis]: https://cloud.google.com/container-registry/docs/container-analysis
-[cloud-containeranalysis-docs]: https://cloud.google.com/container-analysis/api/reference/rest/
-[cloud-containeranalysis-ref]: https://godoc.org/cloud.google.com/go/devtools/containeranalysis/apiv1beta1
-
-[cloud-asset]: https://cloud.google.com/security-command-center/docs/how-to-asset-inventory
-[cloud-asset-docs]: https://cloud.google.com/security-command-center/docs/how-to-asset-inventory
-[cloud-asset-ref]: https://godoc.org/cloud.google.com/go/asset/apiv1
-
-[cloud-tasks]: https://cloud.google.com/tasks/
-[cloud-tasks-ref]: https://godoc.org/cloud.google.com/go/cloudtasks/apiv2beta3

+ 0 - 47
vendor/cloud.google.com/go/RELEASING.md

@@ -1,47 +0,0 @@
-# How to Create a New Release
-
-## Prerequisites
-
-Install [releasetool](https://github.com/googleapis/releasetool).
-
-## Create a release
-
-1. `cd` into the root directory, e.g., `~/go/src/cloud.google.com/go`
-1. Checkout the master branch and ensure a clean and up-to-date state.
-    ```
-    git checkout master
-    git pull --tags origin master
-    ```
-1. Run releasetool to generate a changelog from the last version. Note,
-   releasetool will prompt if the new version is a major, minor, or patch
-   version.
-    ```
-    releasetool start --language go
-    ```
-1. Format the output to match CHANGES.md.
-1. Submit a CL with the changes in CHANGES.md. The commit message should look
-   like this (where `v0.31.0` is instead the correct version number):
-    ```
-    all: Release v0.31.0
-    ```
-1. Wait for approval from all reviewers and then submit the CL.
-1. Return to the master branch and pull the release commit.
-    ```
-    git checkout master
-    git pull origin master
-    ```
-1. Tag the current commit with the new version (e.g., `v0.31.0`)
-    ```
-    releasetool tag --language go
-    ```
-1. Publish the tag to GoogleSource (i.e., origin):
-    ```
-    git push origin $NEW_VERSION
-    ```
-1. Visit the [releases page][releases] on GitHub and click the "Draft a new
-   release" button. For tag version, enter the tag published in the previous
-   step. For the release title, use the version (e.g., `v0.31.0`). For the
-   description, copy the changes added to CHANGES.md.
-
-
-[releases]: https://github.com/googleapis/google-cloud-go/releases

+ 0 - 248
vendor/cloud.google.com/go/asset/apiv1beta1/asset_client.go

@@ -1,248 +0,0 @@
-// 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 asset
-
-import (
-	"context"
-	"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"
-	assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1beta1"
-	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 {
-	ExportAssets          []gax.CallOption
-	BatchGetAssetsHistory []gax.CallOption
-}
-
-func defaultClientOptions() []option.ClientOption {
-	return []option.ClientOption{
-		option.WithEndpoint("cloudasset.googleapis.com:443"),
-		option.WithScopes(DefaultAuthScopes()...),
-	}
-}
-
-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{
-		ExportAssets:          retry[[2]string{"default", "non_idempotent"}],
-		BatchGetAssetsHistory: retry[[2]string{"default", "idempotent"}],
-	}
-}
-
-// Client is a client for interacting with Cloud Asset 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 assetpb.AssetServiceClient
-
-	// 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 asset service client.
-//
-// Asset service definition.
-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: assetpb.NewAssetServiceClient(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...))
-}
-
-// ExportAssets exports assets with time and resource types to a given Cloud Storage
-// location. The output format is newline-delimited JSON.
-// This API implements the [google.longrunning.Operation][google.longrunning.Operation] API allowing you
-// to keep track of the export.
-func (c *Client) ExportAssets(ctx context.Context, req *assetpb.ExportAssetsRequest, opts ...gax.CallOption) (*ExportAssetsOperation, error) {
-	ctx = insertMetadata(ctx, c.xGoogMetadata)
-	opts = append(c.CallOptions.ExportAssets[0:len(c.CallOptions.ExportAssets):len(c.CallOptions.ExportAssets)], opts...)
-	var resp *longrunningpb.Operation
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.ExportAssets(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return &ExportAssetsOperation{
-		lro: longrunning.InternalNewOperation(c.LROClient, resp),
-	}, nil
-}
-
-// BatchGetAssetsHistory batch gets the update history of assets that overlap a time window.
-// For RESOURCE content, this API outputs history with asset in both
-// non-delete or deleted status.
-// For IAM_POLICY content, this API outputs history when the asset and its
-// attached IAM POLICY both exist. This can create gaps in the output history.
-func (c *Client) BatchGetAssetsHistory(ctx context.Context, req *assetpb.BatchGetAssetsHistoryRequest, opts ...gax.CallOption) (*assetpb.BatchGetAssetsHistoryResponse, error) {
-	ctx = insertMetadata(ctx, c.xGoogMetadata)
-	opts = append(c.CallOptions.BatchGetAssetsHistory[0:len(c.CallOptions.BatchGetAssetsHistory):len(c.CallOptions.BatchGetAssetsHistory)], opts...)
-	var resp *assetpb.BatchGetAssetsHistoryResponse
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.BatchGetAssetsHistory(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// ExportAssetsOperation manages a long-running operation from ExportAssets.
-type ExportAssetsOperation struct {
-	lro *longrunning.Operation
-}
-
-// ExportAssetsOperation returns a new ExportAssetsOperation from a given name.
-// The name must be that of a previously created ExportAssetsOperation, possibly from a different process.
-func (c *Client) ExportAssetsOperation(name string) *ExportAssetsOperation {
-	return &ExportAssetsOperation{
-		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 *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 {
-		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 *ExportAssetsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*assetpb.ExportAssetsResponse, error) {
-	var resp assetpb.ExportAssetsResponse
-	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 *ExportAssetsOperation) Metadata() (*assetpb.ExportAssetsRequest, error) {
-	var meta assetpb.ExportAssetsRequest
-	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 *ExportAssetsOperation) 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 *ExportAssetsOperation) Name() string {
-	return op.lro.Name()
-}

+ 0 - 75
vendor/cloud.google.com/go/asset/apiv1beta1/asset_client_example_test.go

@@ -1,75 +0,0 @@
-// 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 asset_test
-
-import (
-	"context"
-
-	asset "cloud.google.com/go/asset/apiv1beta1"
-	assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1beta1"
-)
-
-func ExampleNewClient() {
-	ctx := context.Background()
-	c, err := asset.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use client.
-	_ = c
-}
-
-func ExampleClient_ExportAssets() {
-	ctx := context.Background()
-	c, err := asset.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &assetpb.ExportAssetsRequest{
-		// TODO: Fill request struct fields.
-	}
-	op, err := c.ExportAssets(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	resp, err := op.Wait(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_BatchGetAssetsHistory() {
-	ctx := context.Background()
-	c, err := asset.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &assetpb.BatchGetAssetsHistoryRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.BatchGetAssetsHistory(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}

+ 0 - 89
vendor/cloud.google.com/go/asset/apiv1beta1/doc.go

@@ -1,89 +0,0 @@
-// 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 asset is an auto-generated package for the
-// Cloud Asset API.
-//
-//   NOTE: This package is in beta. It is not stable, and may be subject to changes.
-//
-// The cloud asset API manages the history and inventory of cloud resources.
-package asset // import "cloud.google.com/go/asset/apiv1beta1"
-
-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 = "20190121"

+ 0 - 266
vendor/cloud.google.com/go/asset/apiv1beta1/mock_test.go

@@ -1,266 +0,0 @@
-// 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 asset
-
-import (
-	assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1beta1"
-	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
-)
-
-import (
-	"context"
-	"flag"
-	"fmt"
-	"io"
-	"log"
-	"net"
-	"os"
-	"strings"
-	"testing"
-
-	"github.com/golang/protobuf/proto"
-	"github.com/golang/protobuf/ptypes"
-	"google.golang.org/api/option"
-	status "google.golang.org/genproto/googleapis/rpc/status"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/metadata"
-	gstatus "google.golang.org/grpc/status"
-)
-
-var _ = io.EOF
-var _ = ptypes.MarshalAny
-var _ status.Status
-
-type mockAssetServer struct {
-	// Embed for forward compatibility.
-	// Tests will keep working if more methods are added
-	// in the future.
-	assetpb.AssetServiceServer
-
-	reqs []proto.Message
-
-	// If set, all calls return this error.
-	err error
-
-	// responses to return if err == nil
-	resps []proto.Message
-}
-
-func (s *mockAssetServer) ExportAssets(ctx context.Context, req *assetpb.ExportAssetsRequest) (*longrunningpb.Operation, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*longrunningpb.Operation), nil
-}
-
-func (s *mockAssetServer) BatchGetAssetsHistory(ctx context.Context, req *assetpb.BatchGetAssetsHistoryRequest) (*assetpb.BatchGetAssetsHistoryResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*assetpb.BatchGetAssetsHistoryResponse), nil
-}
-
-// clientOpt is the option tests should use to connect to the test server.
-// It is initialized by TestMain.
-var clientOpt option.ClientOption
-
-var (
-	mockAsset mockAssetServer
-)
-
-func TestMain(m *testing.M) {
-	flag.Parse()
-
-	serv := grpc.NewServer()
-	assetpb.RegisterAssetServiceServer(serv, &mockAsset)
-
-	lis, err := net.Listen("tcp", "localhost:0")
-	if err != nil {
-		log.Fatal(err)
-	}
-	go serv.Serve(lis)
-
-	conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
-	if err != nil {
-		log.Fatal(err)
-	}
-	clientOpt = option.WithGRPCConn(conn)
-
-	os.Exit(m.Run())
-}
-
-func TestAssetServiceExportAssets(t *testing.T) {
-	var expectedResponse *assetpb.ExportAssetsResponse = &assetpb.ExportAssetsResponse{}
-
-	mockAsset.err = nil
-	mockAsset.reqs = nil
-
-	any, err := ptypes.MarshalAny(expectedResponse)
-	if err != nil {
-		t.Fatal(err)
-	}
-	mockAsset.resps = append(mockAsset.resps[:0], &longrunningpb.Operation{
-		Name:   "longrunning-test",
-		Done:   true,
-		Result: &longrunningpb.Operation_Response{Response: any},
-	})
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var outputConfig *assetpb.OutputConfig = &assetpb.OutputConfig{}
-	var request = &assetpb.ExportAssetsRequest{
-		Parent:       formattedParent,
-		OutputConfig: outputConfig,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	respLRO, err := c.ExportAssets(context.Background(), request)
-	if err != nil {
-		t.Fatal(err)
-	}
-	resp, err := respLRO.Wait(context.Background())
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockAsset.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestAssetServiceExportAssetsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockAsset.err = nil
-	mockAsset.resps = append(mockAsset.resps[:0], &longrunningpb.Operation{
-		Name: "longrunning-test",
-		Done: true,
-		Result: &longrunningpb.Operation_Error{
-			Error: &status.Status{
-				Code:    int32(errCode),
-				Message: "test error",
-			},
-		},
-	})
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var outputConfig *assetpb.OutputConfig = &assetpb.OutputConfig{}
-	var request = &assetpb.ExportAssetsRequest{
-		Parent:       formattedParent,
-		OutputConfig: outputConfig,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	respLRO, err := c.ExportAssets(context.Background(), request)
-	if err != nil {
-		t.Fatal(err)
-	}
-	resp, err := respLRO.Wait(context.Background())
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestAssetServiceBatchGetAssetsHistory(t *testing.T) {
-	var expectedResponse *assetpb.BatchGetAssetsHistoryResponse = &assetpb.BatchGetAssetsHistoryResponse{}
-
-	mockAsset.err = nil
-	mockAsset.reqs = nil
-
-	mockAsset.resps = append(mockAsset.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var contentType assetpb.ContentType = assetpb.ContentType_CONTENT_TYPE_UNSPECIFIED
-	var readTimeWindow *assetpb.TimeWindow = &assetpb.TimeWindow{}
-	var request = &assetpb.BatchGetAssetsHistoryRequest{
-		Parent:         formattedParent,
-		ContentType:    contentType,
-		ReadTimeWindow: readTimeWindow,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.BatchGetAssetsHistory(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockAsset.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestAssetServiceBatchGetAssetsHistoryError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockAsset.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var contentType assetpb.ContentType = assetpb.ContentType_CONTENT_TYPE_UNSPECIFIED
-	var readTimeWindow *assetpb.TimeWindow = &assetpb.TimeWindow{}
-	var request = &assetpb.BatchGetAssetsHistoryRequest{
-		Parent:         formattedParent,
-		ContentType:    contentType,
-		ReadTimeWindow: readTimeWindow,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.BatchGetAssetsHistory(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}

+ 0 - 248
vendor/cloud.google.com/go/asset/v1beta1/asset_client.go

@@ -1,248 +0,0 @@
-// Copyright 2018 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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package asset
-
-import (
-	"context"
-	"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"
-	assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1beta1"
-	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 {
-	ExportAssets          []gax.CallOption
-	BatchGetAssetsHistory []gax.CallOption
-}
-
-func defaultClientOptions() []option.ClientOption {
-	return []option.ClientOption{
-		option.WithEndpoint("cloudasset.googleapis.com:443"),
-		option.WithScopes(DefaultAuthScopes()...),
-	}
-}
-
-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{
-		ExportAssets:          retry[[2]string{"default", "non_idempotent"}],
-		BatchGetAssetsHistory: retry[[2]string{"default", "idempotent"}],
-	}
-}
-
-// Client is a client for interacting with Cloud Asset 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 assetpb.AssetServiceClient
-
-	// 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 asset service client.
-//
-// Asset service definition.
-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: assetpb.NewAssetServiceClient(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...))
-}
-
-// ExportAssets exports assets with time and resource types to a given Cloud Storage
-// location. The output format is newline-delimited JSON.
-// This API implements the [google.longrunning.Operation][google.longrunning.Operation] API allowing you
-// to keep track of the export.
-func (c *Client) ExportAssets(ctx context.Context, req *assetpb.ExportAssetsRequest, opts ...gax.CallOption) (*ExportAssetsOperation, error) {
-	ctx = insertMetadata(ctx, c.xGoogMetadata)
-	opts = append(c.CallOptions.ExportAssets[0:len(c.CallOptions.ExportAssets):len(c.CallOptions.ExportAssets)], opts...)
-	var resp *longrunningpb.Operation
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.ExportAssets(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return &ExportAssetsOperation{
-		lro: longrunning.InternalNewOperation(c.LROClient, resp),
-	}, nil
-}
-
-// BatchGetAssetsHistory batch gets the update history of assets that overlap a time window.
-// For RESOURCE content, this API outputs history with asset in both
-// non-delete or deleted status.
-// For IAM_POLICY content, this API outputs history when the asset and its
-// attached IAM POLICY both exist. This can create gaps in the output history.
-func (c *Client) BatchGetAssetsHistory(ctx context.Context, req *assetpb.BatchGetAssetsHistoryRequest, opts ...gax.CallOption) (*assetpb.BatchGetAssetsHistoryResponse, error) {
-	ctx = insertMetadata(ctx, c.xGoogMetadata)
-	opts = append(c.CallOptions.BatchGetAssetsHistory[0:len(c.CallOptions.BatchGetAssetsHistory):len(c.CallOptions.BatchGetAssetsHistory)], opts...)
-	var resp *assetpb.BatchGetAssetsHistoryResponse
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.BatchGetAssetsHistory(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// ExportAssetsOperation manages a long-running operation from ExportAssets.
-type ExportAssetsOperation struct {
-	lro *longrunning.Operation
-}
-
-// ExportAssetsOperation returns a new ExportAssetsOperation from a given name.
-// The name must be that of a previously created ExportAssetsOperation, possibly from a different process.
-func (c *Client) ExportAssetsOperation(name string) *ExportAssetsOperation {
-	return &ExportAssetsOperation{
-		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 *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 {
-		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 *ExportAssetsOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*assetpb.ExportAssetsResponse, error) {
-	var resp assetpb.ExportAssetsResponse
-	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 *ExportAssetsOperation) Metadata() (*assetpb.ExportAssetsRequest, error) {
-	var meta assetpb.ExportAssetsRequest
-	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 *ExportAssetsOperation) 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 *ExportAssetsOperation) Name() string {
-	return op.lro.Name()
-}

+ 0 - 75
vendor/cloud.google.com/go/asset/v1beta1/asset_client_example_test.go

@@ -1,75 +0,0 @@
-// Copyright 2018 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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package asset_test
-
-import (
-	"context"
-
-	asset "cloud.google.com/go/asset/v1beta1"
-	assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1beta1"
-)
-
-func ExampleNewClient() {
-	ctx := context.Background()
-	c, err := asset.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use client.
-	_ = c
-}
-
-func ExampleClient_ExportAssets() {
-	ctx := context.Background()
-	c, err := asset.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &assetpb.ExportAssetsRequest{
-		// TODO: Fill request struct fields.
-	}
-	op, err := c.ExportAssets(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	resp, err := op.Wait(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_BatchGetAssetsHistory() {
-	ctx := context.Background()
-	c, err := asset.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &assetpb.BatchGetAssetsHistoryRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.BatchGetAssetsHistory(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}

+ 0 - 89
vendor/cloud.google.com/go/asset/v1beta1/doc.go

@@ -1,89 +0,0 @@
-// Copyright 2018 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.
-
-// AUTO-GENERATED CODE. 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.
-package asset // import "cloud.google.com/go/asset/v1beta1"
-
-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 = "20181219"

+ 0 - 266
vendor/cloud.google.com/go/asset/v1beta1/mock_test.go

@@ -1,266 +0,0 @@
-// Copyright 2018 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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package asset
-
-import (
-	assetpb "google.golang.org/genproto/googleapis/cloud/asset/v1beta1"
-	longrunningpb "google.golang.org/genproto/googleapis/longrunning"
-)
-
-import (
-	"context"
-	"flag"
-	"fmt"
-	"io"
-	"log"
-	"net"
-	"os"
-	"strings"
-	"testing"
-
-	"github.com/golang/protobuf/proto"
-	"github.com/golang/protobuf/ptypes"
-	"google.golang.org/api/option"
-	status "google.golang.org/genproto/googleapis/rpc/status"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/metadata"
-	gstatus "google.golang.org/grpc/status"
-)
-
-var _ = io.EOF
-var _ = ptypes.MarshalAny
-var _ status.Status
-
-type mockAssetServer struct {
-	// Embed for forward compatibility.
-	// Tests will keep working if more methods are added
-	// in the future.
-	assetpb.AssetServiceServer
-
-	reqs []proto.Message
-
-	// If set, all calls return this error.
-	err error
-
-	// responses to return if err == nil
-	resps []proto.Message
-}
-
-func (s *mockAssetServer) ExportAssets(ctx context.Context, req *assetpb.ExportAssetsRequest) (*longrunningpb.Operation, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*longrunningpb.Operation), nil
-}
-
-func (s *mockAssetServer) BatchGetAssetsHistory(ctx context.Context, req *assetpb.BatchGetAssetsHistoryRequest) (*assetpb.BatchGetAssetsHistoryResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*assetpb.BatchGetAssetsHistoryResponse), nil
-}
-
-// clientOpt is the option tests should use to connect to the test server.
-// It is initialized by TestMain.
-var clientOpt option.ClientOption
-
-var (
-	mockAsset mockAssetServer
-)
-
-func TestMain(m *testing.M) {
-	flag.Parse()
-
-	serv := grpc.NewServer()
-	assetpb.RegisterAssetServiceServer(serv, &mockAsset)
-
-	lis, err := net.Listen("tcp", "localhost:0")
-	if err != nil {
-		log.Fatal(err)
-	}
-	go serv.Serve(lis)
-
-	conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
-	if err != nil {
-		log.Fatal(err)
-	}
-	clientOpt = option.WithGRPCConn(conn)
-
-	os.Exit(m.Run())
-}
-
-func TestAssetServiceExportAssets(t *testing.T) {
-	var expectedResponse *assetpb.ExportAssetsResponse = &assetpb.ExportAssetsResponse{}
-
-	mockAsset.err = nil
-	mockAsset.reqs = nil
-
-	any, err := ptypes.MarshalAny(expectedResponse)
-	if err != nil {
-		t.Fatal(err)
-	}
-	mockAsset.resps = append(mockAsset.resps[:0], &longrunningpb.Operation{
-		Name:   "longrunning-test",
-		Done:   true,
-		Result: &longrunningpb.Operation_Response{Response: any},
-	})
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var outputConfig *assetpb.OutputConfig = &assetpb.OutputConfig{}
-	var request = &assetpb.ExportAssetsRequest{
-		Parent:       formattedParent,
-		OutputConfig: outputConfig,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	respLRO, err := c.ExportAssets(context.Background(), request)
-	if err != nil {
-		t.Fatal(err)
-	}
-	resp, err := respLRO.Wait(context.Background())
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockAsset.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestAssetServiceExportAssetsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockAsset.err = nil
-	mockAsset.resps = append(mockAsset.resps[:0], &longrunningpb.Operation{
-		Name: "longrunning-test",
-		Done: true,
-		Result: &longrunningpb.Operation_Error{
-			Error: &status.Status{
-				Code:    int32(errCode),
-				Message: "test error",
-			},
-		},
-	})
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var outputConfig *assetpb.OutputConfig = &assetpb.OutputConfig{}
-	var request = &assetpb.ExportAssetsRequest{
-		Parent:       formattedParent,
-		OutputConfig: outputConfig,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	respLRO, err := c.ExportAssets(context.Background(), request)
-	if err != nil {
-		t.Fatal(err)
-	}
-	resp, err := respLRO.Wait(context.Background())
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestAssetServiceBatchGetAssetsHistory(t *testing.T) {
-	var expectedResponse *assetpb.BatchGetAssetsHistoryResponse = &assetpb.BatchGetAssetsHistoryResponse{}
-
-	mockAsset.err = nil
-	mockAsset.reqs = nil
-
-	mockAsset.resps = append(mockAsset.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var contentType assetpb.ContentType = assetpb.ContentType_CONTENT_TYPE_UNSPECIFIED
-	var readTimeWindow *assetpb.TimeWindow = &assetpb.TimeWindow{}
-	var request = &assetpb.BatchGetAssetsHistoryRequest{
-		Parent:         formattedParent,
-		ContentType:    contentType,
-		ReadTimeWindow: readTimeWindow,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.BatchGetAssetsHistory(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockAsset.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestAssetServiceBatchGetAssetsHistoryError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockAsset.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var contentType assetpb.ContentType = assetpb.ContentType_CONTENT_TYPE_UNSPECIFIED
-	var readTimeWindow *assetpb.TimeWindow = &assetpb.TimeWindow{}
-	var request = &assetpb.BatchGetAssetsHistoryRequest{
-		Parent:         formattedParent,
-		ContentType:    contentType,
-		ReadTimeWindow: readTimeWindow,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.BatchGetAssetsHistory(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}

+ 0 - 73
vendor/cloud.google.com/go/authexample_test.go

@@ -1,73 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package cloud_test
-
-import (
-	"context"
-
-	"cloud.google.com/go/datastore"
-	"cloud.google.com/go/pubsub"
-	"golang.org/x/oauth2/google"
-	"google.golang.org/api/option"
-)
-
-// Google Application Default Credentials is the recommended way to authorize
-// and authenticate clients.
-//
-// For information on how to create and obtain Application Default Credentials, see
-// https://developers.google.com/identity/protocols/application-default-credentials.
-func Example_applicationDefaultCredentials() {
-	client, err := datastore.NewClient(context.Background(), "project-id")
-	if err != nil {
-		// TODO: handle error.
-	}
-	_ = client // Use the client.
-}
-
-// You can use a file with credentials to authenticate and authorize, such as a JSON
-// key file associated with a Google service account. Service Account keys can be
-// created and downloaded from
-// https://console.developers.google.com/permissions/serviceaccounts.
-//
-// This example uses the Datastore client, but the same steps apply to
-// the other client libraries underneath this package.
-func Example_credentialsFile() {
-	client, err := datastore.NewClient(context.Background(),
-		"project-id", option.WithCredentialsFile("/path/to/service-account-key.json"))
-	if err != nil {
-		// TODO: handle error.
-	}
-	_ = client // Use the client.
-}
-
-// In some cases (for instance, you don't want to store secrets on disk), you can
-// create credentials from in-memory JSON and use the WithCredentials option.
-//
-// The google package in this example is at golang.org/x/oauth2/google.
-//
-// This example uses the PubSub client, but the same steps apply to
-// the other client libraries underneath this package.
-func Example_credentialsFromJSON() {
-	ctx := context.Background()
-	creds, err := google.CredentialsFromJSON(ctx, []byte("JSON creds"), pubsub.ScopePubSub)
-	if err != nil {
-		// TODO: handle error.
-	}
-	client, err := pubsub.NewClient(ctx, "project-id", option.WithCredentials(creds))
-	if err != nil {
-		// TODO: handle error.
-	}
-	_ = client // Use the client.
-}

+ 0 - 8
vendor/cloud.google.com/go/bigquery/benchmarks/README.md

@@ -1,8 +0,0 @@
-# BigQuery Benchmark
-This directory contains benchmarks for BigQuery client.
-
-## Usage
-`go run bench.go -- <your project id> queries.json`
-
-BigQuery service caches requests so the benchmark should be run
-at least twice, disregarding the first result.

+ 0 - 85
vendor/cloud.google.com/go/bigquery/benchmarks/bench.go

@@ -1,85 +0,0 @@
-// Copyright 2017 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
-//
-//      http://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.
-
-//+build ignore
-
-package main
-
-import (
-	"context"
-	"encoding/json"
-	"flag"
-	"io/ioutil"
-	"log"
-	"time"
-
-	"cloud.google.com/go/bigquery"
-	"google.golang.org/api/iterator"
-)
-
-func main() {
-	flag.Parse()
-
-	ctx := context.Background()
-	c, err := bigquery.NewClient(ctx, flag.Arg(0))
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	queriesJSON, err := ioutil.ReadFile(flag.Arg(1))
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	var queries []string
-	if err := json.Unmarshal(queriesJSON, &queries); err != nil {
-		log.Fatal(err)
-	}
-
-	for _, q := range queries {
-		doQuery(ctx, c, q)
-	}
-}
-
-func doQuery(ctx context.Context, c *bigquery.Client, qt string) {
-	startTime := time.Now()
-	q := c.Query(qt)
-	it, err := q.Read(ctx)
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	numRows, numCols := 0, 0
-	var firstByte time.Duration
-
-	for {
-		var values []bigquery.Value
-		err := it.Next(&values)
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			log.Fatal(err)
-		}
-		if numRows == 0 {
-			numCols = len(values)
-			firstByte = time.Since(startTime)
-		} else if numCols != len(values) {
-			log.Fatalf("got %d columns, want %d", len(values), numCols)
-		}
-		numRows++
-	}
-	log.Printf("query %q: %d rows, %d cols, first byte %f sec, total %f sec",
-		qt, numRows, numCols, firstByte.Seconds(), time.Since(startTime).Seconds())
-}

+ 0 - 10
vendor/cloud.google.com/go/bigquery/benchmarks/queries.json

@@ -1,10 +0,0 @@
-[
-  "SELECT * FROM `nyc-tlc.yellow.trips` LIMIT 10000",
-  "SELECT * FROM `nyc-tlc.yellow.trips` LIMIT 100000",
-  "SELECT * FROM `nyc-tlc.yellow.trips` LIMIT 1000000",
-  "SELECT title FROM `bigquery-public-data.samples.wikipedia` ORDER BY title LIMIT 1000",
-  "SELECT title, id, timestamp, contributor_ip FROM `bigquery-public-data.samples.wikipedia` WHERE title like 'Blo%' ORDER BY id",
-  "SELECT * FROM `bigquery-public-data.baseball.games_post_wide` ORDER BY gameId",
-  "SELECT * FROM `bigquery-public-data.samples.github_nested` WHERE repository.has_downloads ORDER BY repository.created_at LIMIT 10000",
-  "SELECT repo_name, path FROM `bigquery-public-data.github_repos.files` WHERE path LIKE '%.java' ORDER BY id LIMIT 1000000"
-]

+ 0 - 162
vendor/cloud.google.com/go/bigquery/bigquery.go

@@ -1,162 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"fmt"
-	"io"
-	"net/http"
-	"time"
-
-	"cloud.google.com/go/internal"
-	"cloud.google.com/go/internal/version"
-	gax "github.com/googleapis/gax-go/v2"
-	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"
-)
-
-var xGoogHeader = fmt.Sprintf("gl-go/%s gccl/%s", version.Go(), version.Repo)
-
-func setClientHeader(headers http.Header) {
-	headers.Set("x-goog-api-client", xGoogHeader)
-}
-
-// Client may be used to perform BigQuery operations.
-type Client struct {
-	// Location, if set, will be used as the default location for all subsequent
-	// dataset creation and job operations. A location specified directly in one of
-	// those operations will override this value.
-	Location string
-
-	projectID string
-	bqs       *bq.Service
-}
-
-// NewClient constructs a new Client which can perform BigQuery operations.
-// 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),
-	}
-	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)
-	if err != nil {
-		return nil, fmt.Errorf("bigquery: constructing client: %v", err)
-	}
-	bqs.BasePath = endpoint
-	c := &Client{
-		projectID: projectID,
-		bqs:       bqs,
-	}
-	return c, nil
-}
-
-// Close closes any resources held by the client.
-// Close should be called when the client is no longer needed.
-// It need not be called at program exit.
-func (c *Client) Close() error {
-	return nil
-}
-
-// Calls the Jobs.Insert RPC and returns a Job.
-func (c *Client) insertJob(ctx context.Context, job *bq.Job, media io.Reader) (*Job, error) {
-	call := c.bqs.Jobs.Insert(c.projectID, job).Context(ctx)
-	setClientHeader(call.Header())
-	if media != nil {
-		call.Media(media)
-	}
-	var res *bq.Job
-	var err error
-	invoke := func() error {
-		res, err = call.Do()
-		return err
-	}
-	// A job with a client-generated ID can be retried; the presence of the
-	// ID makes the insert operation idempotent.
-	// We don't retry if there is media, because it is an io.Reader. We'd
-	// have to read the contents and keep it in memory, and that could be expensive.
-	// TODO(jba): Look into retrying if media != nil.
-	if job.JobReference != nil && media == nil {
-		err = runWithRetry(ctx, invoke)
-	} else {
-		err = invoke()
-	}
-	if err != nil {
-		return nil, err
-	}
-	return bqToJob(res, c)
-}
-
-// Convert a number of milliseconds since the Unix epoch to a time.Time.
-// Treat an input of zero specially: convert it to the zero time,
-// rather than the start of the epoch.
-func unixMillisToTime(m int64) time.Time {
-	if m == 0 {
-		return time.Time{}
-	}
-	return time.Unix(0, m*1e6)
-}
-
-// runWithRetry calls the function until it returns nil or a non-retryable error, or
-// the context is done.
-// See the similar function in ../storage/invoke.go. The main difference is the
-// reason for retrying.
-func runWithRetry(ctx context.Context, call func() error) error {
-	// These parameters match the suggestions in https://cloud.google.com/bigquery/sla.
-	backoff := gax.Backoff{
-		Initial:    1 * time.Second,
-		Max:        32 * time.Second,
-		Multiplier: 2,
-	}
-	return internal.Retry(ctx, backoff, func() (stop bool, err error) {
-		err = call()
-		if err == nil {
-			return true, nil
-		}
-		return !retryableError(err), err
-	})
-}
-
-// This is the correct definition of retryable according to the BigQuery team. It
-// also considers 502 ("Bad Gateway") and 503 ("Service Unavailable") errors
-// retryable; these are returned by systems between the client and the BigQuery
-// service.
-func retryableError(err error) bool {
-	e, ok := err.(*googleapi.Error)
-	if !ok {
-		return false
-	}
-	var reason string
-	if len(e.Errors) > 0 {
-		reason = e.Errors[0].Reason
-	}
-	return e.Code == http.StatusServiceUnavailable || e.Code == http.StatusBadGateway || reason == "backendError" || reason == "rateLimitExceeded"
-}

Разница между файлами не показана из-за своего большого размера
+ 0 - 8062
vendor/cloud.google.com/go/bigquery/bigquery.replay


+ 0 - 107
vendor/cloud.google.com/go/bigquery/copy.go

@@ -1,107 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// CopyConfig holds the configuration for a copy job.
-type CopyConfig struct {
-	// Srcs are the tables from which data will be copied.
-	Srcs []*Table
-
-	// Dst is the table into which the data will be copied.
-	Dst *Table
-
-	// CreateDisposition specifies the circumstances under which the destination table will be created.
-	// The default is CreateIfNeeded.
-	CreateDisposition TableCreateDisposition
-
-	// WriteDisposition specifies how existing data in the destination table is treated.
-	// The default is WriteEmpty.
-	WriteDisposition TableWriteDisposition
-
-	// The labels associated with this job.
-	Labels map[string]string
-
-	// Custom encryption configuration (e.g., Cloud KMS keys).
-	DestinationEncryptionConfig *EncryptionConfig
-}
-
-func (c *CopyConfig) toBQ() *bq.JobConfiguration {
-	var ts []*bq.TableReference
-	for _, t := range c.Srcs {
-		ts = append(ts, t.toBQ())
-	}
-	return &bq.JobConfiguration{
-		Labels: c.Labels,
-		Copy: &bq.JobConfigurationTableCopy{
-			CreateDisposition:                  string(c.CreateDisposition),
-			WriteDisposition:                   string(c.WriteDisposition),
-			DestinationTable:                   c.Dst.toBQ(),
-			DestinationEncryptionConfiguration: c.DestinationEncryptionConfig.toBQ(),
-			SourceTables:                       ts,
-		},
-	}
-}
-
-func bqToCopyConfig(q *bq.JobConfiguration, c *Client) *CopyConfig {
-	cc := &CopyConfig{
-		Labels:                      q.Labels,
-		CreateDisposition:           TableCreateDisposition(q.Copy.CreateDisposition),
-		WriteDisposition:            TableWriteDisposition(q.Copy.WriteDisposition),
-		Dst:                         bqToTable(q.Copy.DestinationTable, c),
-		DestinationEncryptionConfig: bqToEncryptionConfig(q.Copy.DestinationEncryptionConfiguration),
-	}
-	for _, t := range q.Copy.SourceTables {
-		cc.Srcs = append(cc.Srcs, bqToTable(t, c))
-	}
-	return cc
-}
-
-// A Copier copies data into a BigQuery table from one or more BigQuery tables.
-type Copier struct {
-	JobIDConfig
-	CopyConfig
-	c *Client
-}
-
-// CopierFrom returns a Copier which can be used to copy data into a
-// BigQuery table from one or more BigQuery tables.
-// The returned Copier may optionally be further configured before its Run method is called.
-func (t *Table) CopierFrom(srcs ...*Table) *Copier {
-	return &Copier{
-		c: t.c,
-		CopyConfig: CopyConfig{
-			Srcs: srcs,
-			Dst:  t,
-		},
-	}
-}
-
-// Run initiates a copy job.
-func (c *Copier) Run(ctx context.Context) (*Job, error) {
-	return c.c.insertJob(ctx, c.newJob(), nil)
-}
-
-func (c *Copier) newJob() *bq.Job {
-	return &bq.Job{
-		JobReference:  c.JobIDConfig.createJobRef(c.c),
-		Configuration: c.CopyConfig.toBQ(),
-	}
-}

+ 0 - 163
vendor/cloud.google.com/go/bigquery/copy_test.go

@@ -1,163 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"testing"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp/cmpopts"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func defaultCopyJob() *bq.Job {
-	return &bq.Job{
-		JobReference: &bq.JobReference{JobId: "RANDOM", ProjectId: "client-project-id"},
-		Configuration: &bq.JobConfiguration{
-			Copy: &bq.JobConfigurationTableCopy{
-				DestinationTable: &bq.TableReference{
-					ProjectId: "d-project-id",
-					DatasetId: "d-dataset-id",
-					TableId:   "d-table-id",
-				},
-				SourceTables: []*bq.TableReference{
-					{
-						ProjectId: "s-project-id",
-						DatasetId: "s-dataset-id",
-						TableId:   "s-table-id",
-					},
-				},
-			},
-		},
-	}
-}
-
-func TestCopy(t *testing.T) {
-	defer fixRandomID("RANDOM")()
-	testCases := []struct {
-		dst      *Table
-		srcs     []*Table
-		jobID    string
-		location string
-		config   CopyConfig
-		want     *bq.Job
-	}{
-		{
-			dst: &Table{
-				ProjectID: "d-project-id",
-				DatasetID: "d-dataset-id",
-				TableID:   "d-table-id",
-			},
-			srcs: []*Table{
-				{
-					ProjectID: "s-project-id",
-					DatasetID: "s-dataset-id",
-					TableID:   "s-table-id",
-				},
-			},
-			want: defaultCopyJob(),
-		},
-		{
-			dst: &Table{
-				ProjectID: "d-project-id",
-				DatasetID: "d-dataset-id",
-				TableID:   "d-table-id",
-			},
-			srcs: []*Table{
-				{
-					ProjectID: "s-project-id",
-					DatasetID: "s-dataset-id",
-					TableID:   "s-table-id",
-				},
-			},
-			config: CopyConfig{
-				CreateDisposition:           CreateNever,
-				WriteDisposition:            WriteTruncate,
-				DestinationEncryptionConfig: &EncryptionConfig{KMSKeyName: "keyName"},
-				Labels:                      map[string]string{"a": "b"},
-			},
-			want: func() *bq.Job {
-				j := defaultCopyJob()
-				j.Configuration.Labels = map[string]string{"a": "b"}
-				j.Configuration.Copy.CreateDisposition = "CREATE_NEVER"
-				j.Configuration.Copy.WriteDisposition = "WRITE_TRUNCATE"
-				j.Configuration.Copy.DestinationEncryptionConfiguration = &bq.EncryptionConfiguration{KmsKeyName: "keyName"}
-				return j
-			}(),
-		},
-		{
-			dst: &Table{
-				ProjectID: "d-project-id",
-				DatasetID: "d-dataset-id",
-				TableID:   "d-table-id",
-			},
-			srcs: []*Table{
-				{
-					ProjectID: "s-project-id",
-					DatasetID: "s-dataset-id",
-					TableID:   "s-table-id",
-				},
-			},
-			jobID: "job-id",
-			want: func() *bq.Job {
-				j := defaultCopyJob()
-				j.JobReference.JobId = "job-id"
-				return j
-			}(),
-		},
-		{
-			dst: &Table{
-				ProjectID: "d-project-id",
-				DatasetID: "d-dataset-id",
-				TableID:   "d-table-id",
-			},
-			srcs: []*Table{
-				{
-					ProjectID: "s-project-id",
-					DatasetID: "s-dataset-id",
-					TableID:   "s-table-id",
-				},
-			},
-			location: "asia-northeast1",
-			want: func() *bq.Job {
-				j := defaultCopyJob()
-				j.JobReference.Location = "asia-northeast1"
-				return j
-			}(),
-		},
-	}
-	c := &Client{projectID: "client-project-id"}
-	for i, tc := range testCases {
-		tc.dst.c = c
-		copier := tc.dst.CopierFrom(tc.srcs...)
-		copier.JobID = tc.jobID
-		copier.Location = tc.location
-		tc.config.Srcs = tc.srcs
-		tc.config.Dst = tc.dst
-		copier.CopyConfig = tc.config
-		got := copier.newJob()
-		checkJob(t, i, got, tc.want)
-
-		jc, err := bqToJobConfig(got.Configuration, c)
-		if err != nil {
-			t.Fatalf("#%d: %v", i, err)
-		}
-		diff := testutil.Diff(jc.(*CopyConfig), &copier.CopyConfig,
-			cmpopts.IgnoreUnexported(Table{}))
-		if diff != "" {
-			t.Errorf("#%d: (got=-, want=+:\n%s", i, diff)
-		}
-	}
-}

+ 0 - 536
vendor/cloud.google.com/go/bigquery/dataset.go

@@ -1,536 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"time"
-
-	"cloud.google.com/go/internal/optional"
-	"cloud.google.com/go/internal/trace"
-	bq "google.golang.org/api/bigquery/v2"
-	"google.golang.org/api/iterator"
-)
-
-// Dataset is a reference to a BigQuery dataset.
-type Dataset struct {
-	ProjectID string
-	DatasetID string
-	c         *Client
-}
-
-// 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.
-
-	// These fields are read-only.
-	CreationTime     time.Time
-	LastModifiedTime time.Time // When the dataset or any of its tables were modified.
-	FullID           string    // The full dataset ID in the form projectID:datasetID.
-
-	// ETag is the ETag obtained when reading metadata. Pass it to Dataset.Update to
-	// ensure that the metadata hasn't changed since it was read.
-	ETag string
-}
-
-// DatasetMetadataToUpdate is used when updating a dataset's metadata.
-// Only non-nil fields will be updated.
-type DatasetMetadataToUpdate struct {
-	Description optional.String // The user-friendly description of this table.
-	Name        optional.String // The user-friendly name for this dataset.
-
-	// DefaultTableExpiration is the default expiration time for new tables.
-	// If set to time.Duration(0), new tables never expire.
-	DefaultTableExpiration optional.Duration
-
-	// The entire access list. It is not possible to replace individual entries.
-	Access []*AccessEntry
-
-	labelUpdater
-}
-
-// Dataset creates a handle to a BigQuery dataset in the client's project.
-func (c *Client) Dataset(id string) *Dataset {
-	return c.DatasetInProject(c.projectID, id)
-}
-
-// DatasetInProject creates a handle to a BigQuery dataset in the specified project.
-func (c *Client) DatasetInProject(projectID, datasetID string) *Dataset {
-	return &Dataset{
-		ProjectID: projectID,
-		DatasetID: datasetID,
-		c:         c,
-	}
-}
-
-// Create creates a dataset in the BigQuery service. An error will be returned if the
-// dataset already exists. Pass in a DatasetMetadata value to configure the dataset.
-func (d *Dataset) Create(ctx context.Context, md *DatasetMetadata) (err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Dataset.Create")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	ds, err := md.toBQ()
-	if err != nil {
-		return err
-	}
-	ds.DatasetReference = &bq.DatasetReference{DatasetId: d.DatasetID}
-	// Use Client.Location as a default.
-	if ds.Location == "" {
-		ds.Location = d.c.Location
-	}
-	call := d.c.bqs.Datasets.Insert(d.ProjectID, ds).Context(ctx)
-	setClientHeader(call.Header())
-	_, err = call.Do()
-	return err
-}
-
-func (dm *DatasetMetadata) toBQ() (*bq.Dataset, error) {
-	ds := &bq.Dataset{}
-	if dm == nil {
-		return ds, nil
-	}
-	ds.FriendlyName = dm.Name
-	ds.Description = dm.Description
-	ds.Location = dm.Location
-	ds.DefaultTableExpirationMs = int64(dm.DefaultTableExpiration / time.Millisecond)
-	ds.Labels = dm.Labels
-	var err error
-	ds.Access, err = accessListToBQ(dm.Access)
-	if err != nil {
-		return nil, err
-	}
-	if !dm.CreationTime.IsZero() {
-		return nil, errors.New("bigquery: Dataset.CreationTime is not writable")
-	}
-	if !dm.LastModifiedTime.IsZero() {
-		return nil, errors.New("bigquery: Dataset.LastModifiedTime is not writable")
-	}
-	if dm.FullID != "" {
-		return nil, errors.New("bigquery: Dataset.FullID is not writable")
-	}
-	if dm.ETag != "" {
-		return nil, errors.New("bigquery: Dataset.ETag is not writable")
-	}
-	return ds, nil
-}
-
-func accessListToBQ(a []*AccessEntry) ([]*bq.DatasetAccess, error) {
-	var q []*bq.DatasetAccess
-	for _, e := range a {
-		a, err := e.toBQ()
-		if err != nil {
-			return nil, err
-		}
-		q = append(q, a)
-	}
-	return q, nil
-}
-
-// Delete deletes the dataset.  Delete will fail if the dataset is not empty.
-func (d *Dataset) Delete(ctx context.Context) (err error) {
-	return d.deleteInternal(ctx, false)
-}
-
-// DeleteWithContents deletes the dataset, as well as contained resources.
-func (d *Dataset) DeleteWithContents(ctx context.Context) (err error) {
-	return d.deleteInternal(ctx, true)
-}
-
-func (d *Dataset) deleteInternal(ctx context.Context, deleteContents bool) (err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Dataset.Delete")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	call := d.c.bqs.Datasets.Delete(d.ProjectID, d.DatasetID).Context(ctx).DeleteContents(deleteContents)
-	setClientHeader(call.Header())
-	return call.Do()
-}
-
-// Metadata fetches the metadata for the dataset.
-func (d *Dataset) Metadata(ctx context.Context) (md *DatasetMetadata, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Dataset.Metadata")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	call := d.c.bqs.Datasets.Get(d.ProjectID, d.DatasetID).Context(ctx)
-	setClientHeader(call.Header())
-	var ds *bq.Dataset
-	if err := runWithRetry(ctx, func() (err error) {
-		ds, err = call.Do()
-		return err
-	}); err != nil {
-		return nil, err
-	}
-	return bqToDatasetMetadata(ds)
-}
-
-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,
-	}
-	for _, a := range d.Access {
-		e, err := bqToAccessEntry(a, nil)
-		if err != nil {
-			return nil, err
-		}
-		dm.Access = append(dm.Access, e)
-	}
-	return dm, nil
-}
-
-// Update modifies specific Dataset metadata fields.
-// To perform a read-modify-write that protects against intervening reads,
-// set the etag argument to the DatasetMetadata.ETag field from the read.
-// Pass the empty string for etag for a "blind write" that will always succeed.
-func (d *Dataset) Update(ctx context.Context, dm DatasetMetadataToUpdate, etag string) (md *DatasetMetadata, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Dataset.Update")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	ds, err := dm.toBQ()
-	if err != nil {
-		return nil, err
-	}
-	call := d.c.bqs.Datasets.Patch(d.ProjectID, d.DatasetID, ds).Context(ctx)
-	setClientHeader(call.Header())
-	if etag != "" {
-		call.Header().Set("If-Match", etag)
-	}
-	var ds2 *bq.Dataset
-	if err := runWithRetry(ctx, func() (err error) {
-		ds2, err = call.Do()
-		return err
-	}); err != nil {
-		return nil, err
-	}
-	return bqToDatasetMetadata(ds2)
-}
-
-func (dm *DatasetMetadataToUpdate) toBQ() (*bq.Dataset, error) {
-	ds := &bq.Dataset{}
-	forceSend := func(field string) {
-		ds.ForceSendFields = append(ds.ForceSendFields, field)
-	}
-
-	if dm.Description != nil {
-		ds.Description = optional.ToString(dm.Description)
-		forceSend("Description")
-	}
-	if dm.Name != nil {
-		ds.FriendlyName = optional.ToString(dm.Name)
-		forceSend("FriendlyName")
-	}
-	if dm.DefaultTableExpiration != nil {
-		dur := optional.ToDuration(dm.DefaultTableExpiration)
-		if dur == 0 {
-			// Send a null to delete the field.
-			ds.NullFields = append(ds.NullFields, "DefaultTableExpirationMs")
-		} else {
-			ds.DefaultTableExpirationMs = int64(dur / time.Millisecond)
-		}
-	}
-	if dm.Access != nil {
-		var err error
-		ds.Access, err = accessListToBQ(dm.Access)
-		if err != nil {
-			return nil, err
-		}
-		if len(ds.Access) == 0 {
-			ds.NullFields = append(ds.NullFields, "Access")
-		}
-	}
-	labels, forces, nulls := dm.update()
-	ds.Labels = labels
-	ds.ForceSendFields = append(ds.ForceSendFields, forces...)
-	ds.NullFields = append(ds.NullFields, nulls...)
-	return ds, nil
-}
-
-// Table creates a handle to a BigQuery table in the dataset.
-// To determine if a table exists, call Table.Metadata.
-// If the table does not already exist, use Table.Create to create it.
-func (d *Dataset) Table(tableID string) *Table {
-	return &Table{ProjectID: d.ProjectID, DatasetID: d.DatasetID, TableID: tableID, c: d.c}
-}
-
-// Tables returns an iterator over the tables in the Dataset.
-func (d *Dataset) Tables(ctx context.Context) *TableIterator {
-	it := &TableIterator{
-		ctx:     ctx,
-		dataset: d,
-	}
-	it.pageInfo, it.nextFunc = iterator.NewPageInfo(
-		it.fetch,
-		func() int { return len(it.tables) },
-		func() interface{} { b := it.tables; it.tables = nil; return b })
-	return it
-}
-
-// A TableIterator is an iterator over Tables.
-type TableIterator struct {
-	ctx      context.Context
-	dataset  *Dataset
-	tables   []*Table
-	pageInfo *iterator.PageInfo
-	nextFunc func() error
-}
-
-// Next returns the next result. Its second return value is Done if there are
-// no more results. Once Next returns Done, all subsequent calls will return
-// Done.
-func (it *TableIterator) Next() (*Table, error) {
-	if err := it.nextFunc(); err != nil {
-		return nil, err
-	}
-	t := it.tables[0]
-	it.tables = it.tables[1:]
-	return t, nil
-}
-
-// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
-func (it *TableIterator) PageInfo() *iterator.PageInfo { return it.pageInfo }
-
-// for testing
-var listTables = func(it *TableIterator, pageSize int, pageToken string) (*bq.TableList, error) {
-	call := it.dataset.c.bqs.Tables.List(it.dataset.ProjectID, it.dataset.DatasetID).
-		PageToken(pageToken).
-		Context(it.ctx)
-	setClientHeader(call.Header())
-	if pageSize > 0 {
-		call.MaxResults(int64(pageSize))
-	}
-	var res *bq.TableList
-	err := runWithRetry(it.ctx, func() (err error) {
-		res, err = call.Do()
-		return err
-	})
-	return res, err
-}
-
-func (it *TableIterator) fetch(pageSize int, pageToken string) (string, error) {
-	res, err := listTables(it, pageSize, pageToken)
-	if err != nil {
-		return "", err
-	}
-	for _, t := range res.Tables {
-		it.tables = append(it.tables, bqToTable(t.TableReference, it.dataset.c))
-	}
-	return res.NextPageToken, nil
-}
-
-func bqToTable(tr *bq.TableReference, c *Client) *Table {
-	if tr == nil {
-		return nil
-	}
-	return &Table{
-		ProjectID: tr.ProjectId,
-		DatasetID: tr.DatasetId,
-		TableID:   tr.TableId,
-		c:         c,
-	}
-}
-
-// Datasets returns an iterator over the datasets in a project.
-// The Client's project is used by default, but that can be
-// changed by setting ProjectID on the returned iterator before calling Next.
-func (c *Client) Datasets(ctx context.Context) *DatasetIterator {
-	return c.DatasetsInProject(ctx, c.projectID)
-}
-
-// DatasetsInProject returns an iterator over the datasets in the provided project.
-//
-// Deprecated: call Client.Datasets, then set ProjectID on the returned iterator.
-func (c *Client) DatasetsInProject(ctx context.Context, projectID string) *DatasetIterator {
-	it := &DatasetIterator{
-		ctx:       ctx,
-		c:         c,
-		ProjectID: projectID,
-	}
-	it.pageInfo, it.nextFunc = iterator.NewPageInfo(
-		it.fetch,
-		func() int { return len(it.items) },
-		func() interface{} { b := it.items; it.items = nil; return b })
-	return it
-}
-
-// DatasetIterator iterates over the datasets in a project.
-type DatasetIterator struct {
-	// ListHidden causes hidden datasets to be listed when set to true.
-	// Set before the first call to Next.
-	ListHidden bool
-
-	// Filter restricts the datasets returned by label. The filter syntax is described in
-	// https://cloud.google.com/bigquery/docs/labeling-datasets#filtering_datasets_using_labels
-	// Set before the first call to Next.
-	Filter string
-
-	// The project ID of the listed datasets.
-	// Set before the first call to Next.
-	ProjectID string
-
-	ctx      context.Context
-	c        *Client
-	pageInfo *iterator.PageInfo
-	nextFunc func() error
-	items    []*Dataset
-}
-
-// 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 Dataset. 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() (*Dataset, error) {
-	if err := it.nextFunc(); err != nil {
-		return nil, err
-	}
-	item := it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-// for testing
-var listDatasets = func(it *DatasetIterator, pageSize int, pageToken string) (*bq.DatasetList, error) {
-	call := it.c.bqs.Datasets.List(it.ProjectID).
-		Context(it.ctx).
-		PageToken(pageToken).
-		All(it.ListHidden)
-	setClientHeader(call.Header())
-	if pageSize > 0 {
-		call.MaxResults(int64(pageSize))
-	}
-	if it.Filter != "" {
-		call.Filter(it.Filter)
-	}
-	var res *bq.DatasetList
-	err := runWithRetry(it.ctx, func() (err error) {
-		res, err = call.Do()
-		return err
-	})
-	return res, err
-}
-
-func (it *DatasetIterator) fetch(pageSize int, pageToken string) (string, error) {
-	res, err := listDatasets(it, pageSize, pageToken)
-	if err != nil {
-		return "", err
-	}
-	for _, d := range res.Datasets {
-		it.items = append(it.items, &Dataset{
-			ProjectID: d.DatasetReference.ProjectId,
-			DatasetID: d.DatasetReference.DatasetId,
-			c:         it.c,
-		})
-	}
-	return res.NextPageToken, nil
-}
-
-// An AccessEntry describes the permissions that an entity has on a dataset.
-type AccessEntry struct {
-	Role       AccessRole // The role of the entity
-	EntityType EntityType // The type of entity
-	Entity     string     // The entity (individual or group) granted access
-	View       *Table     // The view granted access (EntityType must be ViewEntity)
-}
-
-// AccessRole is the level of access to grant to a dataset.
-type AccessRole string
-
-const (
-	// OwnerRole is the OWNER AccessRole.
-	OwnerRole AccessRole = "OWNER"
-	// ReaderRole is the READER AccessRole.
-	ReaderRole AccessRole = "READER"
-	// WriterRole is the WRITER AccessRole.
-	WriterRole AccessRole = "WRITER"
-)
-
-// EntityType is the type of entity in an AccessEntry.
-type EntityType int
-
-const (
-	// DomainEntity is a domain (e.g. "example.com").
-	DomainEntity EntityType = iota + 1
-
-	// GroupEmailEntity is an email address of a Google Group.
-	GroupEmailEntity
-
-	// UserEmailEntity is an email address of an individual user.
-	UserEmailEntity
-
-	// SpecialGroupEntity is a special group: one of projectOwners, projectReaders, projectWriters or
-	// allAuthenticatedUsers.
-	SpecialGroupEntity
-
-	// ViewEntity is a BigQuery view.
-	ViewEntity
-)
-
-func (e *AccessEntry) toBQ() (*bq.DatasetAccess, error) {
-	q := &bq.DatasetAccess{Role: string(e.Role)}
-	switch e.EntityType {
-	case DomainEntity:
-		q.Domain = e.Entity
-	case GroupEmailEntity:
-		q.GroupByEmail = e.Entity
-	case UserEmailEntity:
-		q.UserByEmail = e.Entity
-	case SpecialGroupEntity:
-		q.SpecialGroup = e.Entity
-	case ViewEntity:
-		q.View = e.View.toBQ()
-	default:
-		return nil, fmt.Errorf("bigquery: unknown entity type %d", e.EntityType)
-	}
-	return q, nil
-}
-
-func bqToAccessEntry(q *bq.DatasetAccess, c *Client) (*AccessEntry, error) {
-	e := &AccessEntry{Role: AccessRole(q.Role)}
-	switch {
-	case q.Domain != "":
-		e.Entity = q.Domain
-		e.EntityType = DomainEntity
-	case q.GroupByEmail != "":
-		e.Entity = q.GroupByEmail
-		e.EntityType = GroupEmailEntity
-	case q.UserByEmail != "":
-		e.Entity = q.UserByEmail
-		e.EntityType = UserEmailEntity
-	case q.SpecialGroup != "":
-		e.Entity = q.SpecialGroup
-		e.EntityType = SpecialGroupEntity
-	case q.View != nil:
-		e.View = c.DatasetInProject(q.View.ProjectId, q.View.DatasetId).Table(q.View.TableId)
-		e.EntityType = ViewEntity
-	default:
-		return nil, errors.New("bigquery: invalid access value")
-	}
-	return e, nil
-}

+ 0 - 326
vendor/cloud.google.com/go/bigquery/dataset_test.go

@@ -1,326 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"strconv"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	bq "google.golang.org/api/bigquery/v2"
-	itest "google.golang.org/api/iterator/testing"
-)
-
-// readServiceStub services read requests by returning data from an in-memory list of values.
-type listTablesStub struct {
-	expectedProject, expectedDataset string
-	tables                           []*bq.TableListTables
-}
-
-func (s *listTablesStub) listTables(it *TableIterator, pageSize int, pageToken string) (*bq.TableList, error) {
-	if it.dataset.ProjectID != s.expectedProject {
-		return nil, errors.New("wrong project id")
-	}
-	if it.dataset.DatasetID != s.expectedDataset {
-		return nil, errors.New("wrong dataset id")
-	}
-	const maxPageSize = 2
-	if pageSize <= 0 || pageSize > maxPageSize {
-		pageSize = maxPageSize
-	}
-	start := 0
-	if pageToken != "" {
-		var err error
-		start, err = strconv.Atoi(pageToken)
-		if err != nil {
-			return nil, err
-		}
-	}
-	end := start + pageSize
-	if end > len(s.tables) {
-		end = len(s.tables)
-	}
-	nextPageToken := ""
-	if end < len(s.tables) {
-		nextPageToken = strconv.Itoa(end)
-	}
-	return &bq.TableList{
-		Tables:        s.tables[start:end],
-		NextPageToken: nextPageToken,
-	}, nil
-}
-
-func TestTables(t *testing.T) {
-	c := &Client{projectID: "p1"}
-	inTables := []*bq.TableListTables{
-		{TableReference: &bq.TableReference{ProjectId: "p1", DatasetId: "d1", TableId: "t1"}},
-		{TableReference: &bq.TableReference{ProjectId: "p1", DatasetId: "d1", TableId: "t2"}},
-		{TableReference: &bq.TableReference{ProjectId: "p1", DatasetId: "d1", TableId: "t3"}},
-	}
-	outTables := []*Table{
-		{ProjectID: "p1", DatasetID: "d1", TableID: "t1", c: c},
-		{ProjectID: "p1", DatasetID: "d1", TableID: "t2", c: c},
-		{ProjectID: "p1", DatasetID: "d1", TableID: "t3", c: c},
-	}
-
-	lts := &listTablesStub{
-		expectedProject: "p1",
-		expectedDataset: "d1",
-		tables:          inTables,
-	}
-	old := listTables
-	listTables = lts.listTables // cannot use t.Parallel with this test
-	defer func() { listTables = old }()
-
-	msg, ok := itest.TestIterator(outTables,
-		func() interface{} { return c.Dataset("d1").Tables(context.Background()) },
-		func(it interface{}) (interface{}, error) { return it.(*TableIterator).Next() })
-	if !ok {
-		t.Error(msg)
-	}
-}
-
-type listDatasetsStub struct {
-	expectedProject string
-	datasets        []*bq.DatasetListDatasets
-	hidden          map[*bq.DatasetListDatasets]bool
-}
-
-func (s *listDatasetsStub) listDatasets(it *DatasetIterator, pageSize int, pageToken string) (*bq.DatasetList, error) {
-	const maxPageSize = 2
-	if pageSize <= 0 || pageSize > maxPageSize {
-		pageSize = maxPageSize
-	}
-	if it.Filter != "" {
-		return nil, errors.New("filter not supported")
-	}
-	if it.ProjectID != s.expectedProject {
-		return nil, errors.New("bad project ID")
-	}
-	start := 0
-	if pageToken != "" {
-		var err error
-		start, err = strconv.Atoi(pageToken)
-		if err != nil {
-			return nil, err
-		}
-	}
-	var (
-		i             int
-		result        []*bq.DatasetListDatasets
-		nextPageToken string
-	)
-	for i = start; len(result) < pageSize && i < len(s.datasets); i++ {
-		if s.hidden[s.datasets[i]] && !it.ListHidden {
-			continue
-		}
-		result = append(result, s.datasets[i])
-	}
-	if i < len(s.datasets) {
-		nextPageToken = strconv.Itoa(i)
-	}
-	return &bq.DatasetList{
-		Datasets:      result,
-		NextPageToken: nextPageToken,
-	}, nil
-}
-
-func TestDatasets(t *testing.T) {
-	client := &Client{projectID: "p"}
-	inDatasets := []*bq.DatasetListDatasets{
-		{DatasetReference: &bq.DatasetReference{ProjectId: "p", DatasetId: "a"}},
-		{DatasetReference: &bq.DatasetReference{ProjectId: "p", DatasetId: "b"}},
-		{DatasetReference: &bq.DatasetReference{ProjectId: "p", DatasetId: "hidden"}},
-		{DatasetReference: &bq.DatasetReference{ProjectId: "p", DatasetId: "c"}},
-	}
-	outDatasets := []*Dataset{
-		{"p", "a", client},
-		{"p", "b", client},
-		{"p", "hidden", client},
-		{"p", "c", client},
-	}
-	lds := &listDatasetsStub{
-		expectedProject: "p",
-		datasets:        inDatasets,
-		hidden:          map[*bq.DatasetListDatasets]bool{inDatasets[2]: true},
-	}
-	old := listDatasets
-	listDatasets = lds.listDatasets // cannot use t.Parallel with this test
-	defer func() { listDatasets = old }()
-
-	msg, ok := itest.TestIterator(outDatasets,
-		func() interface{} { it := client.Datasets(context.Background()); it.ListHidden = true; return it },
-		func(it interface{}) (interface{}, error) { return it.(*DatasetIterator).Next() })
-	if !ok {
-		t.Fatalf("ListHidden=true: %s", msg)
-	}
-
-	msg, ok = itest.TestIterator([]*Dataset{outDatasets[0], outDatasets[1], outDatasets[3]},
-		func() interface{} { it := client.Datasets(context.Background()); it.ListHidden = false; return it },
-		func(it interface{}) (interface{}, error) { return it.(*DatasetIterator).Next() })
-	if !ok {
-		t.Fatalf("ListHidden=false: %s", msg)
-	}
-}
-
-func TestDatasetToBQ(t *testing.T) {
-	for _, test := range []struct {
-		in   *DatasetMetadata
-		want *bq.Dataset
-	}{
-		{nil, &bq.Dataset{}},
-		{&DatasetMetadata{Name: "name"}, &bq.Dataset{FriendlyName: "name"}},
-		{&DatasetMetadata{
-			Name:                   "name",
-			Description:            "desc",
-			DefaultTableExpiration: time.Hour,
-			Location:               "EU",
-			Labels:                 map[string]string{"x": "y"},
-			Access:                 []*AccessEntry{{Role: OwnerRole, Entity: "example.com", EntityType: DomainEntity}},
-		}, &bq.Dataset{
-			FriendlyName:             "name",
-			Description:              "desc",
-			DefaultTableExpirationMs: 60 * 60 * 1000,
-			Location:                 "EU",
-			Labels:                   map[string]string{"x": "y"},
-			Access:                   []*bq.DatasetAccess{{Role: "OWNER", Domain: "example.com"}},
-		}},
-	} {
-		got, err := test.in.toBQ()
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(got, test.want) {
-			t.Errorf("%v:\ngot  %+v\nwant %+v", test.in, got, test.want)
-		}
-	}
-
-	// Check that non-writeable fields are unset.
-	aTime := time.Date(2017, 1, 26, 0, 0, 0, 0, time.Local)
-	for _, dm := range []*DatasetMetadata{
-		{CreationTime: aTime},
-		{LastModifiedTime: aTime},
-		{FullID: "x"},
-		{ETag: "e"},
-	} {
-		if _, err := dm.toBQ(); err == nil {
-			t.Errorf("%+v: got nil, want error", dm)
-		}
-	}
-}
-
-func TestBQToDatasetMetadata(t *testing.T) {
-	cTime := time.Date(2017, 1, 26, 0, 0, 0, 0, time.Local)
-	cMillis := cTime.UnixNano() / 1e6
-	mTime := time.Date(2017, 10, 31, 0, 0, 0, 0, time.Local)
-	mMillis := mTime.UnixNano() / 1e6
-	q := &bq.Dataset{
-		CreationTime:             cMillis,
-		LastModifiedTime:         mMillis,
-		FriendlyName:             "name",
-		Description:              "desc",
-		DefaultTableExpirationMs: 60 * 60 * 1000,
-		Location:                 "EU",
-		Labels:                   map[string]string{"x": "y"},
-		Access: []*bq.DatasetAccess{
-			{Role: "READER", UserByEmail: "joe@example.com"},
-			{Role: "WRITER", GroupByEmail: "users@example.com"},
-		},
-		Etag: "etag",
-	}
-	want := &DatasetMetadata{
-		CreationTime:           cTime,
-		LastModifiedTime:       mTime,
-		Name:                   "name",
-		Description:            "desc",
-		DefaultTableExpiration: time.Hour,
-		Location:               "EU",
-		Labels:                 map[string]string{"x": "y"},
-		Access: []*AccessEntry{
-			{Role: ReaderRole, Entity: "joe@example.com", EntityType: UserEmailEntity},
-			{Role: WriterRole, Entity: "users@example.com", EntityType: GroupEmailEntity},
-		},
-		ETag: "etag",
-	}
-	got, err := bqToDatasetMetadata(q)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if diff := testutil.Diff(got, want); diff != "" {
-		t.Errorf("-got, +want:\n%s", diff)
-	}
-}
-
-func TestDatasetMetadataToUpdateToBQ(t *testing.T) {
-	dm := DatasetMetadataToUpdate{
-		Description:            "desc",
-		Name:                   "name",
-		DefaultTableExpiration: time.Hour,
-	}
-	dm.SetLabel("label", "value")
-	dm.DeleteLabel("del")
-
-	got, err := dm.toBQ()
-	if err != nil {
-		t.Fatal(err)
-	}
-	want := &bq.Dataset{
-		Description:              "desc",
-		FriendlyName:             "name",
-		DefaultTableExpirationMs: 60 * 60 * 1000,
-		Labels:                   map[string]string{"label": "value"},
-		ForceSendFields:          []string{"Description", "FriendlyName"},
-		NullFields:               []string{"Labels.del"},
-	}
-	if diff := testutil.Diff(got, want); diff != "" {
-		t.Errorf("-got, +want:\n%s", diff)
-	}
-}
-
-func TestConvertAccessEntry(t *testing.T) {
-	c := &Client{projectID: "pid"}
-	for _, e := range []*AccessEntry{
-		{Role: ReaderRole, Entity: "e", EntityType: DomainEntity},
-		{Role: WriterRole, Entity: "e", EntityType: GroupEmailEntity},
-		{Role: OwnerRole, Entity: "e", EntityType: UserEmailEntity},
-		{Role: ReaderRole, Entity: "e", EntityType: SpecialGroupEntity},
-		{Role: ReaderRole, EntityType: ViewEntity,
-			View: &Table{ProjectID: "p", DatasetID: "d", TableID: "t", c: c}},
-	} {
-		q, err := e.toBQ()
-		if err != nil {
-			t.Fatal(err)
-		}
-		got, err := bqToAccessEntry(q, c)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if diff := testutil.Diff(got, e, cmp.AllowUnexported(Table{}, Client{})); diff != "" {
-			t.Errorf("got=-, want=+:\n%s", diff)
-		}
-	}
-
-	e := &AccessEntry{Role: ReaderRole, Entity: "e"}
-	if _, err := e.toBQ(); err == nil {
-		t.Error("got nil, want error")
-	}
-	if _, err := bqToAccessEntry(&bq.DatasetAccess{Role: "WRITER"}, nil); err == nil {
-		t.Error("got nil, want error")
-	}
-}

+ 0 - 67
vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/ListDataSources_smoke_test.go

@@ -1,67 +0,0 @@
-// 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 datatransfer
-
-import (
-	datatransferpb "google.golang.org/genproto/googleapis/cloud/bigquery/datatransfer/v1"
-)
-
-import (
-	"context"
-	"fmt"
-	"strconv"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/internal/testutil"
-	"google.golang.org/api/iterator"
-	"google.golang.org/api/option"
-)
-
-var _ = fmt.Sprintf
-var _ = iterator.Done
-var _ = strconv.FormatUint
-var _ = time.Now
-
-func TestDataTransferServiceSmoke(t *testing.T) {
-	if testing.Short() {
-		t.Skip("skipping smoke test in short mode")
-	}
-	ctx := context.Background()
-	ts := testutil.TokenSource(ctx, DefaultAuthScopes()...)
-	if ts == nil {
-		t.Skip("Integration tests skipped. See CONTRIBUTING.md for details")
-	}
-
-	projectId := testutil.ProjID()
-	_ = projectId
-
-	c, err := NewClient(ctx, option.WithTokenSource(ts))
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	var formattedParent string = fmt.Sprintf("projects/%s", projectId)
-	var request = &datatransferpb.ListDataSourcesRequest{
-		Parent: formattedParent,
-	}
-
-	iter := c.ListDataSources(ctx, request)
-	if _, err := iter.Next(); err != nil && err != iterator.Done {
-		t.Error(err)
-	}
-}

+ 0 - 625
vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/data_transfer_client.go

@@ -1,625 +0,0 @@
-// 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 datatransfer
-
-import (
-	"context"
-	"fmt"
-	"math"
-	"time"
-
-	"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"
-	datatransferpb "google.golang.org/genproto/googleapis/cloud/bigquery/datatransfer/v1"
-	"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 {
-	GetDataSource        []gax.CallOption
-	ListDataSources      []gax.CallOption
-	CreateTransferConfig []gax.CallOption
-	UpdateTransferConfig []gax.CallOption
-	DeleteTransferConfig []gax.CallOption
-	GetTransferConfig    []gax.CallOption
-	ListTransferConfigs  []gax.CallOption
-	ScheduleTransferRuns []gax.CallOption
-	GetTransferRun       []gax.CallOption
-	DeleteTransferRun    []gax.CallOption
-	ListTransferRuns     []gax.CallOption
-	ListTransferLogs     []gax.CallOption
-	CheckValidCreds      []gax.CallOption
-}
-
-func defaultClientOptions() []option.ClientOption {
-	return []option.ClientOption{
-		option.WithEndpoint("bigquerydatatransfer.googleapis.com:443"),
-		option.WithScopes(DefaultAuthScopes()...),
-	}
-}
-
-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{
-		GetDataSource:        retry[[2]string{"default", "idempotent"}],
-		ListDataSources:      retry[[2]string{"default", "idempotent"}],
-		CreateTransferConfig: retry[[2]string{"default", "non_idempotent"}],
-		UpdateTransferConfig: retry[[2]string{"default", "non_idempotent"}],
-		DeleteTransferConfig: retry[[2]string{"default", "idempotent"}],
-		GetTransferConfig:    retry[[2]string{"default", "idempotent"}],
-		ListTransferConfigs:  retry[[2]string{"default", "idempotent"}],
-		ScheduleTransferRuns: retry[[2]string{"default", "non_idempotent"}],
-		GetTransferRun:       retry[[2]string{"default", "idempotent"}],
-		DeleteTransferRun:    retry[[2]string{"default", "idempotent"}],
-		ListTransferRuns:     retry[[2]string{"default", "idempotent"}],
-		ListTransferLogs:     retry[[2]string{"default", "idempotent"}],
-		CheckValidCreds:      retry[[2]string{"default", "idempotent"}],
-	}
-}
-
-// Client is a client for interacting with BigQuery Data Transfer 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 datatransferpb.DataTransferServiceClient
-
-	// 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 data transfer service client.
-//
-// The Google BigQuery Data Transfer Service API enables BigQuery users to
-// configure the transfer of their data from other Google Products into BigQuery.
-// This service contains methods that are end user exposed. It backs up the
-// frontend.
-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: datatransferpb.NewDataTransferServiceClient(conn),
-	}
-	c.setGoogleClientInfo()
-	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...))
-}
-
-// GetDataSource retrieves a supported data source and returns its settings,
-// which can be used for UI rendering.
-func (c *Client) GetDataSource(ctx context.Context, req *datatransferpb.GetDataSourceRequest, opts ...gax.CallOption) (*datatransferpb.DataSource, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", req.GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.GetDataSource[0:len(c.CallOptions.GetDataSource):len(c.CallOptions.GetDataSource)], opts...)
-	var resp *datatransferpb.DataSource
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.GetDataSource(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// ListDataSources lists supported data sources and returns their settings,
-// which can be used for UI rendering.
-func (c *Client) ListDataSources(ctx context.Context, req *datatransferpb.ListDataSourcesRequest, opts ...gax.CallOption) *DataSourceIterator {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", req.GetParent()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.ListDataSources[0:len(c.CallOptions.ListDataSources):len(c.CallOptions.ListDataSources)], opts...)
-	it := &DataSourceIterator{}
-	req = proto.Clone(req).(*datatransferpb.ListDataSourcesRequest)
-	it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.DataSource, string, error) {
-		var resp *datatransferpb.ListDataSourcesResponse
-		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.ListDataSources(ctx, req, settings.GRPC...)
-			return err
-		}, opts...)
-		if err != nil {
-			return nil, "", err
-		}
-		return resp.DataSources, 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)
-	return it
-}
-
-// CreateTransferConfig creates a new data transfer configuration.
-func (c *Client) CreateTransferConfig(ctx context.Context, req *datatransferpb.CreateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", req.GetParent()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.CreateTransferConfig[0:len(c.CallOptions.CreateTransferConfig):len(c.CallOptions.CreateTransferConfig)], opts...)
-	var resp *datatransferpb.TransferConfig
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.CreateTransferConfig(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// UpdateTransferConfig updates a data transfer configuration.
-// All fields must be set, even if they are not updated.
-func (c *Client) UpdateTransferConfig(ctx context.Context, req *datatransferpb.UpdateTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "transfer_config.name", req.GetTransferConfig().GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.UpdateTransferConfig[0:len(c.CallOptions.UpdateTransferConfig):len(c.CallOptions.UpdateTransferConfig)], opts...)
-	var resp *datatransferpb.TransferConfig
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.UpdateTransferConfig(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// DeleteTransferConfig deletes a data transfer configuration,
-// including any associated transfer runs and logs.
-func (c *Client) DeleteTransferConfig(ctx context.Context, req *datatransferpb.DeleteTransferConfigRequest, opts ...gax.CallOption) error {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", req.GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.DeleteTransferConfig[0:len(c.CallOptions.DeleteTransferConfig):len(c.CallOptions.DeleteTransferConfig)], opts...)
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		_, err = c.client.DeleteTransferConfig(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	return err
-}
-
-// GetTransferConfig returns information about a data transfer config.
-func (c *Client) GetTransferConfig(ctx context.Context, req *datatransferpb.GetTransferConfigRequest, opts ...gax.CallOption) (*datatransferpb.TransferConfig, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", req.GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.GetTransferConfig[0:len(c.CallOptions.GetTransferConfig):len(c.CallOptions.GetTransferConfig)], opts...)
-	var resp *datatransferpb.TransferConfig
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.GetTransferConfig(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// ListTransferConfigs returns information about all data transfers in the project.
-func (c *Client) ListTransferConfigs(ctx context.Context, req *datatransferpb.ListTransferConfigsRequest, opts ...gax.CallOption) *TransferConfigIterator {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", req.GetParent()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.ListTransferConfigs[0:len(c.CallOptions.ListTransferConfigs):len(c.CallOptions.ListTransferConfigs)], opts...)
-	it := &TransferConfigIterator{}
-	req = proto.Clone(req).(*datatransferpb.ListTransferConfigsRequest)
-	it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferConfig, string, error) {
-		var resp *datatransferpb.ListTransferConfigsResponse
-		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.ListTransferConfigs(ctx, req, settings.GRPC...)
-			return err
-		}, opts...)
-		if err != nil {
-			return nil, "", err
-		}
-		return resp.TransferConfigs, 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)
-	return it
-}
-
-// ScheduleTransferRuns creates transfer runs for a time range [start_time, end_time].
-// For each date - or whatever granularity the data source supports - in the
-// range, one transfer run is created.
-// Note that runs are created per UTC time in the time range.
-func (c *Client) ScheduleTransferRuns(ctx context.Context, req *datatransferpb.ScheduleTransferRunsRequest, opts ...gax.CallOption) (*datatransferpb.ScheduleTransferRunsResponse, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", req.GetParent()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.ScheduleTransferRuns[0:len(c.CallOptions.ScheduleTransferRuns):len(c.CallOptions.ScheduleTransferRuns)], opts...)
-	var resp *datatransferpb.ScheduleTransferRunsResponse
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.ScheduleTransferRuns(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// GetTransferRun returns information about the particular transfer run.
-func (c *Client) GetTransferRun(ctx context.Context, req *datatransferpb.GetTransferRunRequest, opts ...gax.CallOption) (*datatransferpb.TransferRun, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", req.GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.GetTransferRun[0:len(c.CallOptions.GetTransferRun):len(c.CallOptions.GetTransferRun)], opts...)
-	var resp *datatransferpb.TransferRun
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.GetTransferRun(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// DeleteTransferRun deletes the specified transfer run.
-func (c *Client) DeleteTransferRun(ctx context.Context, req *datatransferpb.DeleteTransferRunRequest, opts ...gax.CallOption) error {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", req.GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.DeleteTransferRun[0:len(c.CallOptions.DeleteTransferRun):len(c.CallOptions.DeleteTransferRun)], opts...)
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		_, err = c.client.DeleteTransferRun(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	return err
-}
-
-// ListTransferRuns returns information about running and completed jobs.
-func (c *Client) ListTransferRuns(ctx context.Context, req *datatransferpb.ListTransferRunsRequest, opts ...gax.CallOption) *TransferRunIterator {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", req.GetParent()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.ListTransferRuns[0:len(c.CallOptions.ListTransferRuns):len(c.CallOptions.ListTransferRuns)], opts...)
-	it := &TransferRunIterator{}
-	req = proto.Clone(req).(*datatransferpb.ListTransferRunsRequest)
-	it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferRun, string, error) {
-		var resp *datatransferpb.ListTransferRunsResponse
-		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.ListTransferRuns(ctx, req, settings.GRPC...)
-			return err
-		}, opts...)
-		if err != nil {
-			return nil, "", err
-		}
-		return resp.TransferRuns, 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)
-	return it
-}
-
-// ListTransferLogs returns user facing log messages for the data transfer run.
-func (c *Client) ListTransferLogs(ctx context.Context, req *datatransferpb.ListTransferLogsRequest, opts ...gax.CallOption) *TransferMessageIterator {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", req.GetParent()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.ListTransferLogs[0:len(c.CallOptions.ListTransferLogs):len(c.CallOptions.ListTransferLogs)], opts...)
-	it := &TransferMessageIterator{}
-	req = proto.Clone(req).(*datatransferpb.ListTransferLogsRequest)
-	it.InternalFetch = func(pageSize int, pageToken string) ([]*datatransferpb.TransferMessage, string, error) {
-		var resp *datatransferpb.ListTransferLogsResponse
-		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.ListTransferLogs(ctx, req, settings.GRPC...)
-			return err
-		}, opts...)
-		if err != nil {
-			return nil, "", err
-		}
-		return resp.TransferMessages, 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)
-	return it
-}
-
-// CheckValidCreds returns true if valid credentials exist for the given data source and
-// requesting user.
-// Some data sources doesn't support service account, so we need to talk to
-// them on behalf of the end user. This API just checks whether we have OAuth
-// token for the particular user, which is a pre-requisite before user can
-// create a transfer config.
-func (c *Client) CheckValidCreds(ctx context.Context, req *datatransferpb.CheckValidCredsRequest, opts ...gax.CallOption) (*datatransferpb.CheckValidCredsResponse, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", req.GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.CheckValidCreds[0:len(c.CallOptions.CheckValidCreds):len(c.CallOptions.CheckValidCreds)], opts...)
-	var resp *datatransferpb.CheckValidCredsResponse
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.client.CheckValidCreds(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// DataSourceIterator manages a stream of *datatransferpb.DataSource.
-type DataSourceIterator struct {
-	items    []*datatransferpb.DataSource
-	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 []*datatransferpb.DataSource, nextPageToken string, err error)
-}
-
-// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
-func (it *DataSourceIterator) 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 *DataSourceIterator) Next() (*datatransferpb.DataSource, error) {
-	var item *datatransferpb.DataSource
-	if err := it.nextFunc(); err != nil {
-		return item, err
-	}
-	item = it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-func (it *DataSourceIterator) bufLen() int {
-	return len(it.items)
-}
-
-func (it *DataSourceIterator) takeBuf() interface{} {
-	b := it.items
-	it.items = nil
-	return b
-}
-
-// TransferConfigIterator manages a stream of *datatransferpb.TransferConfig.
-type TransferConfigIterator struct {
-	items    []*datatransferpb.TransferConfig
-	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 []*datatransferpb.TransferConfig, nextPageToken string, err error)
-}
-
-// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
-func (it *TransferConfigIterator) 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 *TransferConfigIterator) Next() (*datatransferpb.TransferConfig, error) {
-	var item *datatransferpb.TransferConfig
-	if err := it.nextFunc(); err != nil {
-		return item, err
-	}
-	item = it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-func (it *TransferConfigIterator) bufLen() int {
-	return len(it.items)
-}
-
-func (it *TransferConfigIterator) takeBuf() interface{} {
-	b := it.items
-	it.items = nil
-	return b
-}
-
-// TransferMessageIterator manages a stream of *datatransferpb.TransferMessage.
-type TransferMessageIterator struct {
-	items    []*datatransferpb.TransferMessage
-	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 []*datatransferpb.TransferMessage, nextPageToken string, err error)
-}
-
-// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
-func (it *TransferMessageIterator) 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 *TransferMessageIterator) Next() (*datatransferpb.TransferMessage, error) {
-	var item *datatransferpb.TransferMessage
-	if err := it.nextFunc(); err != nil {
-		return item, err
-	}
-	item = it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-func (it *TransferMessageIterator) bufLen() int {
-	return len(it.items)
-}
-
-func (it *TransferMessageIterator) takeBuf() interface{} {
-	b := it.items
-	it.items = nil
-	return b
-}
-
-// TransferRunIterator manages a stream of *datatransferpb.TransferRun.
-type TransferRunIterator struct {
-	items    []*datatransferpb.TransferRun
-	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 []*datatransferpb.TransferRun, nextPageToken string, err error)
-}
-
-// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
-func (it *TransferRunIterator) 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 *TransferRunIterator) Next() (*datatransferpb.TransferRun, error) {
-	var item *datatransferpb.TransferRun
-	if err := it.nextFunc(); err != nil {
-		return item, err
-	}
-	item = it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-func (it *TransferRunIterator) bufLen() int {
-	return len(it.items)
-}
-
-func (it *TransferRunIterator) takeBuf() interface{} {
-	b := it.items
-	it.items = nil
-	return b
-}

+ 0 - 289
vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/data_transfer_client_example_test.go

@@ -1,289 +0,0 @@
-// 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 datatransfer_test
-
-import (
-	"context"
-
-	datatransfer "cloud.google.com/go/bigquery/datatransfer/apiv1"
-	"google.golang.org/api/iterator"
-	datatransferpb "google.golang.org/genproto/googleapis/cloud/bigquery/datatransfer/v1"
-)
-
-func ExampleNewClient() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use client.
-	_ = c
-}
-
-func ExampleClient_GetDataSource() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.GetDataSourceRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.GetDataSource(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_ListDataSources() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.ListDataSourcesRequest{
-		// TODO: Fill request struct fields.
-	}
-	it := c.ListDataSources(ctx, req)
-	for {
-		resp, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		// TODO: Use resp.
-		_ = resp
-	}
-}
-
-func ExampleClient_CreateTransferConfig() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.CreateTransferConfigRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.CreateTransferConfig(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_UpdateTransferConfig() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.UpdateTransferConfigRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.UpdateTransferConfig(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_DeleteTransferConfig() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.DeleteTransferConfigRequest{
-		// TODO: Fill request struct fields.
-	}
-	err = c.DeleteTransferConfig(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleClient_GetTransferConfig() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.GetTransferConfigRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.GetTransferConfig(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_ListTransferConfigs() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.ListTransferConfigsRequest{
-		// TODO: Fill request struct fields.
-	}
-	it := c.ListTransferConfigs(ctx, req)
-	for {
-		resp, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		// TODO: Use resp.
-		_ = resp
-	}
-}
-
-func ExampleClient_ScheduleTransferRuns() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.ScheduleTransferRunsRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.ScheduleTransferRuns(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_GetTransferRun() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.GetTransferRunRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.GetTransferRun(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleClient_DeleteTransferRun() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.DeleteTransferRunRequest{
-		// TODO: Fill request struct fields.
-	}
-	err = c.DeleteTransferRun(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleClient_ListTransferRuns() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.ListTransferRunsRequest{
-		// TODO: Fill request struct fields.
-	}
-	it := c.ListTransferRuns(ctx, req)
-	for {
-		resp, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		// TODO: Use resp.
-		_ = resp
-	}
-}
-
-func ExampleClient_ListTransferLogs() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.ListTransferLogsRequest{
-		// TODO: Fill request struct fields.
-	}
-	it := c.ListTransferLogs(ctx, req)
-	for {
-		resp, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		// TODO: Use resp.
-		_ = resp
-	}
-}
-
-func ExampleClient_CheckValidCreds() {
-	ctx := context.Background()
-	c, err := datatransfer.NewClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &datatransferpb.CheckValidCredsRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.CheckValidCreds(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}

+ 0 - 90
vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/doc.go

@@ -1,90 +0,0 @@
-// 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 datatransfer is an auto-generated package for the
-// BigQuery Data Transfer API.
-//
-//   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.
-package datatransfer // import "cloud.google.com/go/bigquery/datatransfer/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 = "20190121"

+ 0 - 1146
vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/mock_test.go

@@ -1,1146 +0,0 @@
-// 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 datatransfer
-
-import (
-	emptypb "github.com/golang/protobuf/ptypes/empty"
-	timestamppb "github.com/golang/protobuf/ptypes/timestamp"
-	datatransferpb "google.golang.org/genproto/googleapis/cloud/bigquery/datatransfer/v1"
-	field_maskpb "google.golang.org/genproto/protobuf/field_mask"
-)
-
-import (
-	"context"
-	"flag"
-	"fmt"
-	"io"
-	"log"
-	"net"
-	"os"
-	"strings"
-	"testing"
-
-	"github.com/golang/protobuf/proto"
-	"github.com/golang/protobuf/ptypes"
-	"google.golang.org/api/option"
-	status "google.golang.org/genproto/googleapis/rpc/status"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/metadata"
-	gstatus "google.golang.org/grpc/status"
-)
-
-var _ = io.EOF
-var _ = ptypes.MarshalAny
-var _ status.Status
-
-type mockDataTransferServer struct {
-	// Embed for forward compatibility.
-	// Tests will keep working if more methods are added
-	// in the future.
-	datatransferpb.DataTransferServiceServer
-
-	reqs []proto.Message
-
-	// If set, all calls return this error.
-	err error
-
-	// responses to return if err == nil
-	resps []proto.Message
-}
-
-func (s *mockDataTransferServer) GetDataSource(ctx context.Context, req *datatransferpb.GetDataSourceRequest) (*datatransferpb.DataSource, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.DataSource), nil
-}
-
-func (s *mockDataTransferServer) ListDataSources(ctx context.Context, req *datatransferpb.ListDataSourcesRequest) (*datatransferpb.ListDataSourcesResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.ListDataSourcesResponse), nil
-}
-
-func (s *mockDataTransferServer) CreateTransferConfig(ctx context.Context, req *datatransferpb.CreateTransferConfigRequest) (*datatransferpb.TransferConfig, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.TransferConfig), nil
-}
-
-func (s *mockDataTransferServer) UpdateTransferConfig(ctx context.Context, req *datatransferpb.UpdateTransferConfigRequest) (*datatransferpb.TransferConfig, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.TransferConfig), nil
-}
-
-func (s *mockDataTransferServer) DeleteTransferConfig(ctx context.Context, req *datatransferpb.DeleteTransferConfigRequest) (*emptypb.Empty, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*emptypb.Empty), nil
-}
-
-func (s *mockDataTransferServer) GetTransferConfig(ctx context.Context, req *datatransferpb.GetTransferConfigRequest) (*datatransferpb.TransferConfig, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.TransferConfig), nil
-}
-
-func (s *mockDataTransferServer) ListTransferConfigs(ctx context.Context, req *datatransferpb.ListTransferConfigsRequest) (*datatransferpb.ListTransferConfigsResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.ListTransferConfigsResponse), nil
-}
-
-func (s *mockDataTransferServer) ScheduleTransferRuns(ctx context.Context, req *datatransferpb.ScheduleTransferRunsRequest) (*datatransferpb.ScheduleTransferRunsResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.ScheduleTransferRunsResponse), nil
-}
-
-func (s *mockDataTransferServer) GetTransferRun(ctx context.Context, req *datatransferpb.GetTransferRunRequest) (*datatransferpb.TransferRun, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.TransferRun), nil
-}
-
-func (s *mockDataTransferServer) DeleteTransferRun(ctx context.Context, req *datatransferpb.DeleteTransferRunRequest) (*emptypb.Empty, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*emptypb.Empty), nil
-}
-
-func (s *mockDataTransferServer) ListTransferRuns(ctx context.Context, req *datatransferpb.ListTransferRunsRequest) (*datatransferpb.ListTransferRunsResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.ListTransferRunsResponse), nil
-}
-
-func (s *mockDataTransferServer) ListTransferLogs(ctx context.Context, req *datatransferpb.ListTransferLogsRequest) (*datatransferpb.ListTransferLogsResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.ListTransferLogsResponse), nil
-}
-
-func (s *mockDataTransferServer) CheckValidCreds(ctx context.Context, req *datatransferpb.CheckValidCredsRequest) (*datatransferpb.CheckValidCredsResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*datatransferpb.CheckValidCredsResponse), nil
-}
-
-// clientOpt is the option tests should use to connect to the test server.
-// It is initialized by TestMain.
-var clientOpt option.ClientOption
-
-var (
-	mockDataTransfer mockDataTransferServer
-)
-
-func TestMain(m *testing.M) {
-	flag.Parse()
-
-	serv := grpc.NewServer()
-	datatransferpb.RegisterDataTransferServiceServer(serv, &mockDataTransfer)
-
-	lis, err := net.Listen("tcp", "localhost:0")
-	if err != nil {
-		log.Fatal(err)
-	}
-	go serv.Serve(lis)
-
-	conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
-	if err != nil {
-		log.Fatal(err)
-	}
-	clientOpt = option.WithGRPCConn(conn)
-
-	os.Exit(m.Run())
-}
-
-func TestDataTransferServiceGetDataSource(t *testing.T) {
-	var name2 string = "name2-1052831874"
-	var dataSourceId string = "dataSourceId-1015796374"
-	var displayName string = "displayName1615086568"
-	var description string = "description-1724546052"
-	var clientId string = "clientId-1904089585"
-	var supportsMultipleTransfers bool = true
-	var updateDeadlineSeconds int32 = 991471694
-	var defaultSchedule string = "defaultSchedule-800168235"
-	var supportsCustomSchedule bool = true
-	var helpUrl string = "helpUrl-789431439"
-	var defaultDataRefreshWindowDays int32 = 1804935157
-	var manualRunsDisabled bool = true
-	var expectedResponse = &datatransferpb.DataSource{
-		Name:                         name2,
-		DataSourceId:                 dataSourceId,
-		DisplayName:                  displayName,
-		Description:                  description,
-		ClientId:                     clientId,
-		SupportsMultipleTransfers:    supportsMultipleTransfers,
-		UpdateDeadlineSeconds:        updateDeadlineSeconds,
-		DefaultSchedule:              defaultSchedule,
-		SupportsCustomSchedule:       supportsCustomSchedule,
-		HelpUrl:                      helpUrl,
-		DefaultDataRefreshWindowDays: defaultDataRefreshWindowDays,
-		ManualRunsDisabled:           manualRunsDisabled,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedName string = fmt.Sprintf("projects/%s/dataSources/%s", "[PROJECT]", "[DATA_SOURCE]")
-	var request = &datatransferpb.GetDataSourceRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.GetDataSource(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceGetDataSourceError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedName string = fmt.Sprintf("projects/%s/dataSources/%s", "[PROJECT]", "[DATA_SOURCE]")
-	var request = &datatransferpb.GetDataSourceRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.GetDataSource(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceListDataSources(t *testing.T) {
-	var nextPageToken string = ""
-	var dataSourcesElement *datatransferpb.DataSource = &datatransferpb.DataSource{}
-	var dataSources = []*datatransferpb.DataSource{dataSourcesElement}
-	var expectedResponse = &datatransferpb.ListDataSourcesResponse{
-		NextPageToken: nextPageToken,
-		DataSources:   dataSources,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var request = &datatransferpb.ListDataSourcesRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListDataSources(context.Background(), request).Next()
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	want := (interface{})(expectedResponse.DataSources[0])
-	got := (interface{})(resp)
-	var ok bool
-
-	switch want := (want).(type) {
-	case proto.Message:
-		ok = proto.Equal(want, got.(proto.Message))
-	default:
-		ok = want == got
-	}
-	if !ok {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceListDataSourcesError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var request = &datatransferpb.ListDataSourcesRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListDataSources(context.Background(), request).Next()
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceCreateTransferConfig(t *testing.T) {
-	var name string = "name3373707"
-	var destinationDatasetId string = "destinationDatasetId1541564179"
-	var displayName string = "displayName1615086568"
-	var dataSourceId string = "dataSourceId-1015796374"
-	var schedule string = "schedule-697920873"
-	var dataRefreshWindowDays int32 = 327632845
-	var disabled bool = true
-	var userId int64 = 147132913
-	var datasetRegion string = "datasetRegion959248539"
-	var expectedResponse = &datatransferpb.TransferConfig{
-		Name:                  name,
-		DestinationDatasetId:  destinationDatasetId,
-		DisplayName:           displayName,
-		DataSourceId:          dataSourceId,
-		Schedule:              schedule,
-		DataRefreshWindowDays: dataRefreshWindowDays,
-		Disabled:              disabled,
-		UserId:                userId,
-		DatasetRegion:         datasetRegion,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var transferConfig *datatransferpb.TransferConfig = &datatransferpb.TransferConfig{}
-	var request = &datatransferpb.CreateTransferConfigRequest{
-		Parent:         formattedParent,
-		TransferConfig: transferConfig,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.CreateTransferConfig(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceCreateTransferConfigError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var transferConfig *datatransferpb.TransferConfig = &datatransferpb.TransferConfig{}
-	var request = &datatransferpb.CreateTransferConfigRequest{
-		Parent:         formattedParent,
-		TransferConfig: transferConfig,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.CreateTransferConfig(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceUpdateTransferConfig(t *testing.T) {
-	var name string = "name3373707"
-	var destinationDatasetId string = "destinationDatasetId1541564179"
-	var displayName string = "displayName1615086568"
-	var dataSourceId string = "dataSourceId-1015796374"
-	var schedule string = "schedule-697920873"
-	var dataRefreshWindowDays int32 = 327632845
-	var disabled bool = true
-	var userId int64 = 147132913
-	var datasetRegion string = "datasetRegion959248539"
-	var expectedResponse = &datatransferpb.TransferConfig{
-		Name:                  name,
-		DestinationDatasetId:  destinationDatasetId,
-		DisplayName:           displayName,
-		DataSourceId:          dataSourceId,
-		Schedule:              schedule,
-		DataRefreshWindowDays: dataRefreshWindowDays,
-		Disabled:              disabled,
-		UserId:                userId,
-		DatasetRegion:         datasetRegion,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var transferConfig *datatransferpb.TransferConfig = &datatransferpb.TransferConfig{}
-	var updateMask *field_maskpb.FieldMask = &field_maskpb.FieldMask{}
-	var request = &datatransferpb.UpdateTransferConfigRequest{
-		TransferConfig: transferConfig,
-		UpdateMask:     updateMask,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.UpdateTransferConfig(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceUpdateTransferConfigError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var transferConfig *datatransferpb.TransferConfig = &datatransferpb.TransferConfig{}
-	var updateMask *field_maskpb.FieldMask = &field_maskpb.FieldMask{}
-	var request = &datatransferpb.UpdateTransferConfigRequest{
-		TransferConfig: transferConfig,
-		UpdateMask:     updateMask,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.UpdateTransferConfig(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceDeleteTransferConfig(t *testing.T) {
-	var expectedResponse *emptypb.Empty = &emptypb.Empty{}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var request = &datatransferpb.DeleteTransferConfigRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = c.DeleteTransferConfig(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-}
-
-func TestDataTransferServiceDeleteTransferConfigError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var request = &datatransferpb.DeleteTransferConfigRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = c.DeleteTransferConfig(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-}
-func TestDataTransferServiceGetTransferConfig(t *testing.T) {
-	var name2 string = "name2-1052831874"
-	var destinationDatasetId string = "destinationDatasetId1541564179"
-	var displayName string = "displayName1615086568"
-	var dataSourceId string = "dataSourceId-1015796374"
-	var schedule string = "schedule-697920873"
-	var dataRefreshWindowDays int32 = 327632845
-	var disabled bool = true
-	var userId int64 = 147132913
-	var datasetRegion string = "datasetRegion959248539"
-	var expectedResponse = &datatransferpb.TransferConfig{
-		Name:                  name2,
-		DestinationDatasetId:  destinationDatasetId,
-		DisplayName:           displayName,
-		DataSourceId:          dataSourceId,
-		Schedule:              schedule,
-		DataRefreshWindowDays: dataRefreshWindowDays,
-		Disabled:              disabled,
-		UserId:                userId,
-		DatasetRegion:         datasetRegion,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var request = &datatransferpb.GetTransferConfigRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.GetTransferConfig(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceGetTransferConfigError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var request = &datatransferpb.GetTransferConfigRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.GetTransferConfig(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceListTransferConfigs(t *testing.T) {
-	var nextPageToken string = ""
-	var transferConfigsElement *datatransferpb.TransferConfig = &datatransferpb.TransferConfig{}
-	var transferConfigs = []*datatransferpb.TransferConfig{transferConfigsElement}
-	var expectedResponse = &datatransferpb.ListTransferConfigsResponse{
-		NextPageToken:   nextPageToken,
-		TransferConfigs: transferConfigs,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var request = &datatransferpb.ListTransferConfigsRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListTransferConfigs(context.Background(), request).Next()
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	want := (interface{})(expectedResponse.TransferConfigs[0])
-	got := (interface{})(resp)
-	var ok bool
-
-	switch want := (want).(type) {
-	case proto.Message:
-		ok = proto.Equal(want, got.(proto.Message))
-	default:
-		ok = want == got
-	}
-	if !ok {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceListTransferConfigsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
-	var request = &datatransferpb.ListTransferConfigsRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListTransferConfigs(context.Background(), request).Next()
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceScheduleTransferRuns(t *testing.T) {
-	var expectedResponse *datatransferpb.ScheduleTransferRunsResponse = &datatransferpb.ScheduleTransferRunsResponse{}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var startTime *timestamppb.Timestamp = &timestamppb.Timestamp{}
-	var endTime *timestamppb.Timestamp = &timestamppb.Timestamp{}
-	var request = &datatransferpb.ScheduleTransferRunsRequest{
-		Parent:    formattedParent,
-		StartTime: startTime,
-		EndTime:   endTime,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ScheduleTransferRuns(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceScheduleTransferRunsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var startTime *timestamppb.Timestamp = &timestamppb.Timestamp{}
-	var endTime *timestamppb.Timestamp = &timestamppb.Timestamp{}
-	var request = &datatransferpb.ScheduleTransferRunsRequest{
-		Parent:    formattedParent,
-		StartTime: startTime,
-		EndTime:   endTime,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ScheduleTransferRuns(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceGetTransferRun(t *testing.T) {
-	var name2 string = "name2-1052831874"
-	var destinationDatasetId string = "destinationDatasetId1541564179"
-	var dataSourceId string = "dataSourceId-1015796374"
-	var userId int64 = 147132913
-	var schedule string = "schedule-697920873"
-	var expectedResponse = &datatransferpb.TransferRun{
-		Name:                 name2,
-		DestinationDatasetId: destinationDatasetId,
-		DataSourceId:         dataSourceId,
-		UserId:               userId,
-		Schedule:             schedule,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s/runs/%s", "[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
-	var request = &datatransferpb.GetTransferRunRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.GetTransferRun(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceGetTransferRunError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s/runs/%s", "[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
-	var request = &datatransferpb.GetTransferRunRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.GetTransferRun(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceDeleteTransferRun(t *testing.T) {
-	var expectedResponse *emptypb.Empty = &emptypb.Empty{}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s/runs/%s", "[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
-	var request = &datatransferpb.DeleteTransferRunRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = c.DeleteTransferRun(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-}
-
-func TestDataTransferServiceDeleteTransferRunError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedName string = fmt.Sprintf("projects/%s/transferConfigs/%s/runs/%s", "[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
-	var request = &datatransferpb.DeleteTransferRunRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = c.DeleteTransferRun(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-}
-func TestDataTransferServiceListTransferRuns(t *testing.T) {
-	var nextPageToken string = ""
-	var transferRunsElement *datatransferpb.TransferRun = &datatransferpb.TransferRun{}
-	var transferRuns = []*datatransferpb.TransferRun{transferRunsElement}
-	var expectedResponse = &datatransferpb.ListTransferRunsResponse{
-		NextPageToken: nextPageToken,
-		TransferRuns:  transferRuns,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var request = &datatransferpb.ListTransferRunsRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListTransferRuns(context.Background(), request).Next()
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	want := (interface{})(expectedResponse.TransferRuns[0])
-	got := (interface{})(resp)
-	var ok bool
-
-	switch want := (want).(type) {
-	case proto.Message:
-		ok = proto.Equal(want, got.(proto.Message))
-	default:
-		ok = want == got
-	}
-	if !ok {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceListTransferRunsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s/transferConfigs/%s", "[PROJECT]", "[TRANSFER_CONFIG]")
-	var request = &datatransferpb.ListTransferRunsRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListTransferRuns(context.Background(), request).Next()
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceListTransferLogs(t *testing.T) {
-	var nextPageToken string = ""
-	var transferMessagesElement *datatransferpb.TransferMessage = &datatransferpb.TransferMessage{}
-	var transferMessages = []*datatransferpb.TransferMessage{transferMessagesElement}
-	var expectedResponse = &datatransferpb.ListTransferLogsResponse{
-		NextPageToken:    nextPageToken,
-		TransferMessages: transferMessages,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedParent string = fmt.Sprintf("projects/%s/transferConfigs/%s/runs/%s", "[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
-	var request = &datatransferpb.ListTransferLogsRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListTransferLogs(context.Background(), request).Next()
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	want := (interface{})(expectedResponse.TransferMessages[0])
-	got := (interface{})(resp)
-	var ok bool
-
-	switch want := (want).(type) {
-	case proto.Message:
-		ok = proto.Equal(want, got.(proto.Message))
-	default:
-		ok = want == got
-	}
-	if !ok {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceListTransferLogsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedParent string = fmt.Sprintf("projects/%s/transferConfigs/%s/runs/%s", "[PROJECT]", "[TRANSFER_CONFIG]", "[RUN]")
-	var request = &datatransferpb.ListTransferLogsRequest{
-		Parent: formattedParent,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.ListTransferLogs(context.Background(), request).Next()
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestDataTransferServiceCheckValidCreds(t *testing.T) {
-	var hasValidCreds bool = false
-	var expectedResponse = &datatransferpb.CheckValidCredsResponse{
-		HasValidCreds: hasValidCreds,
-	}
-
-	mockDataTransfer.err = nil
-	mockDataTransfer.reqs = nil
-
-	mockDataTransfer.resps = append(mockDataTransfer.resps[:0], expectedResponse)
-
-	var formattedName string = fmt.Sprintf("projects/%s/dataSources/%s", "[PROJECT]", "[DATA_SOURCE]")
-	var request = &datatransferpb.CheckValidCredsRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.CheckValidCreds(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockDataTransfer.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestDataTransferServiceCheckValidCredsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockDataTransfer.err = gstatus.Error(errCode, "test error")
-
-	var formattedName string = fmt.Sprintf("projects/%s/dataSources/%s", "[PROJECT]", "[DATA_SOURCE]")
-	var request = &datatransferpb.CheckValidCredsRequest{
-		Name: formattedName,
-	}
-
-	c, err := NewClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.CheckValidCreds(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}

+ 0 - 135
vendor/cloud.google.com/go/bigquery/datatransfer/apiv1/path_funcs.go

@@ -1,135 +0,0 @@
-// Copyright 2018 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.
-
-package datatransfer
-
-// ProjectPath returns the path for the project resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s", project)
-// instead.
-func ProjectPath(project string) string {
-	return "" +
-		"projects/" +
-		project +
-		""
-}
-
-// LocationPath returns the path for the location resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s/locations/%s", project, location)
-// instead.
-func LocationPath(project, location string) string {
-	return "" +
-		"projects/" +
-		project +
-		"/locations/" +
-		location +
-		""
-}
-
-// LocationDataSourcePath returns the path for the location data source resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s/locations/%s/dataSources/%s", project, location, dataSource)
-// instead.
-func LocationDataSourcePath(project, location, dataSource string) string {
-	return "" +
-		"projects/" +
-		project +
-		"/locations/" +
-		location +
-		"/dataSources/" +
-		dataSource +
-		""
-}
-
-// LocationTransferConfigPath returns the path for the location transfer config resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s/locations/%s/transferConfigs/%s", project, location, transferConfig)
-// instead.
-func LocationTransferConfigPath(project, location, transferConfig string) string {
-	return "" +
-		"projects/" +
-		project +
-		"/locations/" +
-		location +
-		"/transferConfigs/" +
-		transferConfig +
-		""
-}
-
-// LocationRunPath returns the path for the location run resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s/locations/%s/transferConfigs/%s/runs/%s", project, location, transferConfig, run)
-// instead.
-func LocationRunPath(project, location, transferConfig, run string) string {
-	return "" +
-		"projects/" +
-		project +
-		"/locations/" +
-		location +
-		"/transferConfigs/" +
-		transferConfig +
-		"/runs/" +
-		run +
-		""
-}
-
-// DataSourcePath returns the path for the data source resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s/dataSources/%s", project, dataSource)
-// instead.
-func DataSourcePath(project, dataSource string) string {
-	return "" +
-		"projects/" +
-		project +
-		"/dataSources/" +
-		dataSource +
-		""
-}
-
-// TransferConfigPath returns the path for the transfer config resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s/transferConfigs/%s", project, transferConfig)
-// instead.
-func TransferConfigPath(project, transferConfig string) string {
-	return "" +
-		"projects/" +
-		project +
-		"/transferConfigs/" +
-		transferConfig +
-		""
-}
-
-// RunPath returns the path for the run resource.
-//
-// Deprecated: Use
-//   fmt.Sprintf("projects/%s/transferConfigs/%s/runs/%s", project, transferConfig, run)
-// instead.
-func RunPath(project, transferConfig, run string) string {
-	return "" +
-		"projects/" +
-		project +
-		"/transferConfigs/" +
-		transferConfig +
-		"/runs/" +
-		run +
-		""
-}

+ 0 - 310
vendor/cloud.google.com/go/bigquery/doc.go

@@ -1,310 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-/*
-Package bigquery provides a client for the BigQuery service.
-
-Note: This package is in beta.  Some backwards-incompatible changes may occur.
-
-The following assumes a basic familiarity with BigQuery concepts.
-See https://cloud.google.com/bigquery/docs.
-
-See https://godoc.org/cloud.google.com/go for authentication, timeouts,
-connection pooling and similar aspects of this package.
-
-
-Creating a Client
-
-To start working with this package, create a client:
-
-    ctx := context.Background()
-    client, err := bigquery.NewClient(ctx, projectID)
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-Querying
-
-To query existing tables, create a Query and call its Read method:
-
-    q := client.Query(`
-        SELECT year, SUM(number) as num
-        FROM ` + "`bigquery-public-data.usa_names.usa_1910_2013`" + `
-        WHERE name = "William"
-        GROUP BY year
-        ORDER BY year
-    `)
-    it, err := q.Read(ctx)
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-Then iterate through the resulting rows. You can store a row using
-anything that implements the ValueLoader interface, or with a slice or map of bigquery.Value.
-A slice is simplest:
-
-    for {
-        var values []bigquery.Value
-        err := it.Next(&values)
-        if err == iterator.Done {
-            break
-        }
-        if err != nil {
-            // TODO: Handle error.
-        }
-        fmt.Println(values)
-    }
-
-You can also use a struct whose exported fields match the query:
-
-    type Count struct {
-        Year int
-        Num  int
-    }
-    for {
-        var c Count
-        err := it.Next(&c)
-        if err == iterator.Done {
-            break
-        }
-        if err != nil {
-            // TODO: Handle error.
-        }
-        fmt.Println(c)
-    }
-
-You can also start the query running and get the results later.
-Create the query as above, but call Run instead of Read. This returns a Job,
-which represents an asynchronous operation.
-
-    job, err := q.Run(ctx)
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-Get the job's ID, a printable string. You can save this string to retrieve
-the results at a later time, even in another process.
-
-    jobID := job.ID()
-    fmt.Printf("The job ID is %s\n", jobID)
-
-To retrieve the job's results from the ID, first look up the Job:
-
-    job, err = client.JobFromID(ctx, jobID)
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-Use the Job.Read method to obtain an iterator, and loop over the rows.
-Query.Read is just a convenience method that combines Query.Run and Job.Read.
-
-    it, err = job.Read(ctx)
-    if err != nil {
-        // TODO: Handle error.
-    }
-    // Proceed with iteration as above.
-
-Datasets and Tables
-
-You can refer to datasets in the client's project with the Dataset method, and
-in other projects with the DatasetInProject method:
-
-    myDataset := client.Dataset("my_dataset")
-    yourDataset := client.DatasetInProject("your-project-id", "your_dataset")
-
-These methods create references to datasets, not the datasets themselves. You can have
-a dataset reference even if the dataset doesn't exist yet. Use Dataset.Create to
-create a dataset from a reference:
-
-    if err := myDataset.Create(ctx, nil); err != nil {
-        // TODO: Handle error.
-    }
-
-You can refer to tables with Dataset.Table. Like bigquery.Dataset, bigquery.Table is a reference
-to an object in BigQuery that may or may not exist.
-
-    table := myDataset.Table("my_table")
-
-You can create, delete and update the metadata of tables with methods on Table.
-For instance, you could create a temporary table with:
-
-    err = myDataset.Table("temp").Create(ctx, &bigquery.TableMetadata{
-        ExpirationTime: time.Now().Add(1*time.Hour)})
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-We'll see how to create a table with a schema in the next section.
-
-Schemas
-
-There are two ways to construct schemas with this package.
-You can build a schema by hand, like so:
-
-    schema1 := bigquery.Schema{
-        {Name: "Name", Required: true, Type: bigquery.StringFieldType},
-        {Name: "Grades", Repeated: true, Type: bigquery.IntegerFieldType},
-        {Name: "Optional", Required: false, Type: bigquery.IntegerFieldType},
-    }
-
-Or you can infer the schema from a struct:
-
-    type student struct {
-        Name   string
-        Grades []int
-        Optional bigquery.NullInt64
-    }
-    schema2, err := bigquery.InferSchema(student{})
-    if err != nil {
-        // TODO: Handle error.
-    }
-    // schema1 and schema2 are identical.
-
-Struct inference supports tags like those of the encoding/json package, so you can
-change names, ignore fields, or mark a field as nullable (non-required). Fields
-declared as one of the Null types (NullInt64, NullFloat64, NullString, NullBool,
-NullTimestamp, NullDate, NullTime and NullDateTime) are automatically inferred as
-nullable, so the "nullable" tag is only needed for []byte, *big.Rat and
-pointer-to-struct fields.
-
-    type student2 struct {
-        Name     string `bigquery:"full_name"`
-        Grades   []int
-        Secret   string `bigquery:"-"`
-        Optional []byte `bigquery:",nullable"
-    }
-    schema3, err := bigquery.InferSchema(student2{})
-    if err != nil {
-        // TODO: Handle error.
-    }
-    // schema3 has required fields "full_name" and "Grade", and nullable BYTES field "Optional".
-
-Having constructed a schema, you can create a table with it like so:
-
-    if err := table.Create(ctx, &bigquery.TableMetadata{Schema: schema1}); err != nil {
-        // TODO: Handle error.
-    }
-
-Copying
-
-You can copy one or more tables to another table. Begin by constructing a Copier
-describing the copy. Then set any desired copy options, and finally call Run to get a Job:
-
-    copier := myDataset.Table("dest").CopierFrom(myDataset.Table("src"))
-    copier.WriteDisposition = bigquery.WriteTruncate
-    job, err = copier.Run(ctx)
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-You can chain the call to Run if you don't want to set options:
-
-    job, err = myDataset.Table("dest").CopierFrom(myDataset.Table("src")).Run(ctx)
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-You can wait for your job to complete:
-
-    status, err := job.Wait(ctx)
-    if err != nil {
-        // TODO: Handle error.
-    }
-
-Job.Wait polls with exponential backoff. You can also poll yourself, if you
-wish:
-
-    for {
-        status, err := job.Status(ctx)
-        if err != nil {
-            // TODO: Handle error.
-        }
-        if status.Done() {
-            if status.Err() != nil {
-                log.Fatalf("Job failed with error %v", status.Err())
-            }
-            break
-        }
-        time.Sleep(pollInterval)
-    }
-
-Loading and Uploading
-
-There are two ways to populate a table with this package: load the data from a Google Cloud Storage
-object, or upload rows directly from your program.
-
-For loading, first create a GCSReference, configuring it if desired. Then make a Loader, optionally configure
-it as well, and call its Run method.
-
-    gcsRef := bigquery.NewGCSReference("gs://my-bucket/my-object")
-    gcsRef.AllowJaggedRows = true
-    loader := myDataset.Table("dest").LoaderFrom(gcsRef)
-    loader.CreateDisposition = bigquery.CreateNever
-    job, err = loader.Run(ctx)
-    // Poll the job for completion if desired, as above.
-
-To upload, first define a type that implements the ValueSaver interface, which has a single method named Save.
-Then create an Uploader, and call its Put method with a slice of values.
-
-    u := table.Uploader()
-    // Item implements the ValueSaver interface.
-    items := []*Item{
-        {Name: "n1", Size: 32.6, Count: 7},
-        {Name: "n2", Size: 4, Count: 2},
-        {Name: "n3", Size: 101.5, Count: 1},
-    }
-    if err := u.Put(ctx, items); err != nil {
-        // TODO: Handle error.
-    }
-
-You can also upload a struct that doesn't implement ValueSaver. Use the StructSaver type
-to specify the schema and insert ID by hand, or just supply the struct or struct pointer
-directly and the schema will be inferred:
-
-    type Item2 struct {
-        Name  string
-        Size  float64
-        Count int
-    }
-    // Item implements the ValueSaver interface.
-    items2 := []*Item2{
-        {Name: "n1", Size: 32.6, Count: 7},
-        {Name: "n2", Size: 4, Count: 2},
-        {Name: "n3", Size: 101.5, Count: 1},
-    }
-    if err := u.Put(ctx, items2); err != nil {
-        // TODO: Handle error.
-    }
-
-Extracting
-
-If you've been following so far, extracting data from a BigQuery table
-into a Google Cloud Storage object will feel familiar. First create an
-Extractor, then optionally configure it, and lastly call its Run method.
-
-    extractor := table.ExtractorTo(gcsRef)
-    extractor.DisableHeader = true
-    job, err = extractor.Run(ctx)
-    // Poll the job for completion if desired, as above.
-
-Errors
-
-Errors returned by this client are often of the type [`googleapi.Error`](https://godoc.org/google.golang.org/api/googleapi#Error).
-These errors can be introspected for more information by type asserting to the richer `googleapi.Error` type. For example:
-
-	if e, ok := err.(*googleapi.Error); ok {
-		  if e.Code = 409 { ... }
-	}
-*/
-package bigquery // import "cloud.google.com/go/bigquery"

+ 0 - 83
vendor/cloud.google.com/go/bigquery/error.go

@@ -1,83 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"fmt"
-
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// An Error contains detailed information about a failed bigquery operation.
-// Detailed description of possible Reasons can be found here: https://cloud.google.com/bigquery/troubleshooting-errors.
-type Error struct {
-	// Mirrors bq.ErrorProto, but drops DebugInfo
-	Location, Message, Reason string
-}
-
-func (e Error) Error() string {
-	return fmt.Sprintf("{Location: %q; Message: %q; Reason: %q}", e.Location, e.Message, e.Reason)
-}
-
-func bqToError(ep *bq.ErrorProto) *Error {
-	if ep == nil {
-		return nil
-	}
-	return &Error{
-		Location: ep.Location,
-		Message:  ep.Message,
-		Reason:   ep.Reason,
-	}
-}
-
-// A MultiError contains multiple related errors.
-type MultiError []error
-
-func (m MultiError) Error() string {
-	switch len(m) {
-	case 0:
-		return "(0 errors)"
-	case 1:
-		return m[0].Error()
-	case 2:
-		return m[0].Error() + " (and 1 other error)"
-	}
-	return fmt.Sprintf("%s (and %d other errors)", m[0].Error(), len(m)-1)
-}
-
-// RowInsertionError contains all errors that occurred when attempting to insert a row.
-type RowInsertionError struct {
-	InsertID string // The InsertID associated with the affected row.
-	RowIndex int    // The 0-based index of the affected row in the batch of rows being inserted.
-	Errors   MultiError
-}
-
-func (e *RowInsertionError) Error() string {
-	errFmt := "insertion of row [insertID: %q; insertIndex: %v] failed with error: %s"
-	return fmt.Sprintf(errFmt, e.InsertID, e.RowIndex, e.Errors.Error())
-}
-
-// PutMultiError contains an error for each row which was not successfully inserted
-// into a BigQuery table.
-type PutMultiError []RowInsertionError
-
-func (pme PutMultiError) Error() string {
-	plural := "s"
-	if len(pme) == 1 {
-		plural = ""
-	}
-
-	return fmt.Sprintf("%v row insertion%s failed", len(pme), plural)
-}

+ 0 - 109
vendor/cloud.google.com/go/bigquery/error_test.go

@@ -1,109 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"errors"
-	"strings"
-	"testing"
-
-	"cloud.google.com/go/internal/testutil"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func rowInsertionError(msg string) RowInsertionError {
-	return RowInsertionError{Errors: []error{errors.New(msg)}}
-}
-
-func TestPutMultiErrorString(t *testing.T) {
-	testCases := []struct {
-		errs PutMultiError
-		want string
-	}{
-		{
-			errs: PutMultiError{},
-			want: "0 row insertions failed",
-		},
-		{
-			errs: PutMultiError{rowInsertionError("a")},
-			want: "1 row insertion failed",
-		},
-		{
-			errs: PutMultiError{rowInsertionError("a"), rowInsertionError("b")},
-			want: "2 row insertions failed",
-		},
-	}
-
-	for _, tc := range testCases {
-		if tc.errs.Error() != tc.want {
-			t.Errorf("PutMultiError string: got:\n%v\nwant:\n%v", tc.errs.Error(), tc.want)
-		}
-	}
-}
-
-func TestMultiErrorString(t *testing.T) {
-	testCases := []struct {
-		errs MultiError
-		want string
-	}{
-		{
-			errs: MultiError{},
-			want: "(0 errors)",
-		},
-		{
-			errs: MultiError{errors.New("a")},
-			want: "a",
-		},
-		{
-			errs: MultiError{errors.New("a"), errors.New("b")},
-			want: "a (and 1 other error)",
-		},
-		{
-			errs: MultiError{errors.New("a"), errors.New("b"), errors.New("c")},
-			want: "a (and 2 other errors)",
-		},
-	}
-
-	for _, tc := range testCases {
-		if tc.errs.Error() != tc.want {
-			t.Errorf("PutMultiError string: got:\n%v\nwant:\n%v", tc.errs.Error(), tc.want)
-		}
-	}
-}
-
-func TestErrorFromErrorProto(t *testing.T) {
-	for _, test := range []struct {
-		in   *bq.ErrorProto
-		want *Error
-	}{
-		{nil, nil},
-		{
-			in:   &bq.ErrorProto{Location: "L", Message: "M", Reason: "R"},
-			want: &Error{Location: "L", Message: "M", Reason: "R"},
-		},
-	} {
-		if got := bqToError(test.in); !testutil.Equal(got, test.want) {
-			t.Errorf("%v: got %v, want %v", test.in, got, test.want)
-		}
-	}
-}
-
-func TestErrorString(t *testing.T) {
-	e := &Error{Location: "<L>", Message: "<M>", Reason: "<R>"}
-	got := e.Error()
-	if !strings.Contains(got, "<L>") || !strings.Contains(got, "<M>") || !strings.Contains(got, "<R>") {
-		t.Errorf(`got %q, expected to see "<L>", "<M>" and "<R>"`, got)
-	}
-}

+ 0 - 829
vendor/cloud.google.com/go/bigquery/examples_test.go

@@ -1,829 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery_test
-
-import (
-	"context"
-	"fmt"
-	"os"
-	"time"
-
-	"cloud.google.com/go/bigquery"
-	"google.golang.org/api/iterator"
-)
-
-func ExampleNewClient() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	_ = client // TODO: Use client.
-}
-
-func ExampleClient_Dataset() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ds := client.Dataset("my_dataset")
-	fmt.Println(ds)
-}
-
-func ExampleClient_DatasetInProject() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ds := client.DatasetInProject("their-project-id", "their-dataset")
-	fmt.Println(ds)
-}
-
-func ExampleClient_Datasets() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it := client.Datasets(ctx)
-	_ = it // TODO: iterate using Next or iterator.Pager.
-}
-
-func ExampleClient_DatasetsInProject() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it := client.DatasetsInProject(ctx, "their-project-id")
-	_ = it // TODO: iterate using Next or iterator.Pager.
-}
-
-func getJobID() string { return "" }
-
-func ExampleClient_JobFromID() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	jobID := getJobID() // Get a job ID using Job.ID, the console or elsewhere.
-	job, err := client.JobFromID(ctx, jobID)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(job.LastStatus()) // Display the job's status.
-}
-
-func ExampleClient_Jobs() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it := client.Jobs(ctx)
-	it.State = bigquery.Running // list only running jobs.
-	_ = it                      // TODO: iterate using Next or iterator.Pager.
-}
-
-func ExampleNewGCSReference() {
-	gcsRef := bigquery.NewGCSReference("gs://my-bucket/my-object")
-	fmt.Println(gcsRef)
-}
-
-func ExampleClient_Query() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	q := client.Query("select name, num from t1")
-	q.DefaultProjectID = "project-id"
-	// TODO: set other options on the Query.
-	// TODO: Call Query.Run or Query.Read.
-}
-
-func ExampleClient_Query_parameters() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	q := client.Query("select num from t1 where name = @user")
-	q.Parameters = []bigquery.QueryParameter{
-		{Name: "user", Value: "Elizabeth"},
-	}
-	// TODO: set other options on the Query.
-	// TODO: Call Query.Run or Query.Read.
-}
-
-// This example demonstrates how to run a query job on a table
-// with a customer-managed encryption key. The same
-// applies to load and copy jobs as well.
-func ExampleClient_Query_encryptionKey() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	q := client.Query("select name, num from t1")
-	// TODO: Replace this key with a key you have created in Cloud KMS.
-	keyName := "projects/P/locations/L/keyRings/R/cryptoKeys/K"
-	q.DestinationEncryptionConfig = &bigquery.EncryptionConfig{KMSKeyName: keyName}
-	// TODO: set other options on the Query.
-	// TODO: Call Query.Run or Query.Read.
-}
-
-func ExampleQuery_Read() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	q := client.Query("select name, num from t1")
-	it, err := q.Read(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	_ = it // TODO: iterate using Next or iterator.Pager.
-}
-
-func ExampleRowIterator_Next() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	q := client.Query("select name, num from t1")
-	it, err := q.Read(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	for {
-		var row []bigquery.Value
-		err := it.Next(&row)
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		fmt.Println(row)
-	}
-}
-
-func ExampleRowIterator_Next_struct() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	type score struct {
-		Name string
-		Num  int
-	}
-
-	q := client.Query("select name, num from t1")
-	it, err := q.Read(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	for {
-		var s score
-		err := it.Next(&s)
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		fmt.Println(s)
-	}
-}
-
-func ExampleJob_Read() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	q := client.Query("select name, num from t1")
-	// Call Query.Run to get a Job, then call Read on the job.
-	// Note: Query.Read is a shorthand for this.
-	job, err := q.Run(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it, err := job.Read(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	_ = it // TODO: iterate using Next or iterator.Pager.
-}
-
-func ExampleJob_Wait() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ds := client.Dataset("my_dataset")
-	job, err := ds.Table("t1").CopierFrom(ds.Table("t2")).Run(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	status, err := job.Wait(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	if status.Err() != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleJob_Config() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ds := client.Dataset("my_dataset")
-	job, err := ds.Table("t1").CopierFrom(ds.Table("t2")).Run(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	jc, err := job.Config()
-	if err != nil {
-		// TODO: Handle error.
-	}
-	copyConfig := jc.(*bigquery.CopyConfig)
-	fmt.Println(copyConfig.Dst, copyConfig.CreateDisposition)
-}
-
-func ExampleDataset_Create() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ds := client.Dataset("my_dataset")
-	if err := ds.Create(ctx, &bigquery.DatasetMetadata{Location: "EU"}); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleDataset_Delete() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	if err := client.Dataset("my_dataset").Delete(ctx); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleDataset_Metadata() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	md, err := client.Dataset("my_dataset").Metadata(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(md)
-}
-
-// This example illustrates how to perform a read-modify-write sequence on dataset
-// metadata. Passing the metadata's ETag to the Update call ensures that the call
-// will fail if the metadata was changed since the read.
-func ExampleDataset_Update_readModifyWrite() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ds := client.Dataset("my_dataset")
-	md, err := ds.Metadata(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	md2, err := ds.Update(ctx,
-		bigquery.DatasetMetadataToUpdate{Name: "new " + md.Name},
-		md.ETag)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(md2)
-}
-
-// To perform a blind write, ignoring the existing state (and possibly overwriting
-// other updates), pass the empty string as the etag.
-func ExampleDataset_Update_blindWrite() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	md, err := client.Dataset("my_dataset").Update(ctx, bigquery.DatasetMetadataToUpdate{Name: "blind"}, "")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(md)
-}
-
-func ExampleDataset_Table() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// Table creates a reference to the table. It does not create the actual
-	// table in BigQuery; to do so, use Table.Create.
-	t := client.Dataset("my_dataset").Table("my_table")
-	fmt.Println(t)
-}
-
-func ExampleDataset_Tables() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it := client.Dataset("my_dataset").Tables(ctx)
-	_ = it // TODO: iterate using Next or iterator.Pager.
-}
-
-func ExampleDatasetIterator_Next() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it := client.Datasets(ctx)
-	for {
-		ds, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		fmt.Println(ds)
-	}
-}
-
-func ExampleInferSchema() {
-	type Item struct {
-		Name  string
-		Size  float64
-		Count int
-	}
-	schema, err := bigquery.InferSchema(Item{})
-	if err != nil {
-		fmt.Println(err)
-		// TODO: Handle error.
-	}
-	for _, fs := range schema {
-		fmt.Println(fs.Name, fs.Type)
-	}
-	// Output:
-	// Name STRING
-	// Size FLOAT
-	// Count INTEGER
-}
-
-func ExampleInferSchema_tags() {
-	type Item struct {
-		Name     string
-		Size     float64
-		Count    int    `bigquery:"number"`
-		Secret   []byte `bigquery:"-"`
-		Optional bigquery.NullBool
-		OptBytes []byte `bigquery:",nullable"`
-	}
-	schema, err := bigquery.InferSchema(Item{})
-	if err != nil {
-		fmt.Println(err)
-		// TODO: Handle error.
-	}
-	for _, fs := range schema {
-		fmt.Println(fs.Name, fs.Type, fs.Required)
-	}
-	// Output:
-	// Name STRING true
-	// Size FLOAT true
-	// number INTEGER true
-	// Optional BOOLEAN false
-	// OptBytes BYTES false
-}
-
-func ExampleTable_Create() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	t := client.Dataset("my_dataset").Table("new-table")
-	if err := t.Create(ctx, nil); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-// Initialize a new table by passing TableMetadata to Table.Create.
-func ExampleTable_Create_initialize() {
-	ctx := context.Background()
-	// Infer table schema from a Go type.
-	schema, err := bigquery.InferSchema(Item{})
-	if err != nil {
-		// TODO: Handle error.
-	}
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	t := client.Dataset("my_dataset").Table("new-table")
-	if err := t.Create(ctx,
-		&bigquery.TableMetadata{
-			Name:           "My New Table",
-			Schema:         schema,
-			ExpirationTime: time.Now().Add(24 * time.Hour),
-		}); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-// This example demonstrates how to create a table with
-// a customer-managed encryption key.
-func ExampleTable_Create_encryptionKey() {
-	ctx := context.Background()
-	// Infer table schema from a Go type.
-	schema, err := bigquery.InferSchema(Item{})
-	if err != nil {
-		// TODO: Handle error.
-	}
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	t := client.Dataset("my_dataset").Table("new-table")
-
-	// TODO: Replace this key with a key you have created in Cloud KMS.
-	keyName := "projects/P/locations/L/keyRings/R/cryptoKeys/K"
-	if err := t.Create(ctx,
-		&bigquery.TableMetadata{
-			Name:             "My New Table",
-			Schema:           schema,
-			EncryptionConfig: &bigquery.EncryptionConfig{KMSKeyName: keyName},
-		}); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleTable_Delete() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	if err := client.Dataset("my_dataset").Table("my_table").Delete(ctx); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleTable_Metadata() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	md, err := client.Dataset("my_dataset").Table("my_table").Metadata(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(md)
-}
-
-func ExampleTable_Inserter() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ins := client.Dataset("my_dataset").Table("my_table").Inserter()
-	_ = ins // TODO: Use ins.
-}
-
-func ExampleTable_Inserter_options() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ins := client.Dataset("my_dataset").Table("my_table").Inserter()
-	ins.SkipInvalidRows = true
-	ins.IgnoreUnknownValues = true
-	_ = ins // TODO: Use ins.
-}
-
-func ExampleTable_CopierFrom() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ds := client.Dataset("my_dataset")
-	c := ds.Table("combined").CopierFrom(ds.Table("t1"), ds.Table("t2"))
-	c.WriteDisposition = bigquery.WriteTruncate
-	// TODO: set other options on the Copier.
-	job, err := c.Run(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	status, err := job.Wait(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	if status.Err() != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleTable_ExtractorTo() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	gcsRef := bigquery.NewGCSReference("gs://my-bucket/my-object")
-	gcsRef.FieldDelimiter = ":"
-	// TODO: set other options on the GCSReference.
-	ds := client.Dataset("my_dataset")
-	extractor := ds.Table("my_table").ExtractorTo(gcsRef)
-	extractor.DisableHeader = true
-	// TODO: set other options on the Extractor.
-	job, err := extractor.Run(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	status, err := job.Wait(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	if status.Err() != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleTable_LoaderFrom() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	gcsRef := bigquery.NewGCSReference("gs://my-bucket/my-object")
-	gcsRef.AllowJaggedRows = true
-	gcsRef.MaxBadRecords = 5
-	gcsRef.Schema = schema
-	// TODO: set other options on the GCSReference.
-	ds := client.Dataset("my_dataset")
-	loader := ds.Table("my_table").LoaderFrom(gcsRef)
-	loader.CreateDisposition = bigquery.CreateNever
-	// TODO: set other options on the Loader.
-	job, err := loader.Run(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	status, err := job.Wait(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	if status.Err() != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleTable_LoaderFrom_reader() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	f, err := os.Open("data.csv")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	rs := bigquery.NewReaderSource(f)
-	rs.AllowJaggedRows = true
-	rs.MaxBadRecords = 5
-	rs.Schema = schema
-	// TODO: set other options on the GCSReference.
-	ds := client.Dataset("my_dataset")
-	loader := ds.Table("my_table").LoaderFrom(rs)
-	loader.CreateDisposition = bigquery.CreateNever
-	// TODO: set other options on the Loader.
-	job, err := loader.Run(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	status, err := job.Wait(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	if status.Err() != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleTable_Read() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it := client.Dataset("my_dataset").Table("my_table").Read(ctx)
-	_ = it // TODO: iterate using Next or iterator.Pager.
-}
-
-// This example illustrates how to perform a read-modify-write sequence on table
-// metadata. Passing the metadata's ETag to the Update call ensures that the call
-// will fail if the metadata was changed since the read.
-func ExampleTable_Update_readModifyWrite() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	t := client.Dataset("my_dataset").Table("my_table")
-	md, err := t.Metadata(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	md2, err := t.Update(ctx,
-		bigquery.TableMetadataToUpdate{Name: "new " + md.Name},
-		md.ETag)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(md2)
-}
-
-// To perform a blind write, ignoring the existing state (and possibly overwriting
-// other updates), pass the empty string as the etag.
-func ExampleTable_Update_blindWrite() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	t := client.Dataset("my_dataset").Table("my_table")
-	tm, err := t.Update(ctx, bigquery.TableMetadataToUpdate{
-		Description: "my favorite table",
-	}, "")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	fmt.Println(tm)
-}
-
-func ExampleTableIterator_Next() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	it := client.Dataset("my_dataset").Tables(ctx)
-	for {
-		t, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			// TODO: Handle error.
-		}
-		fmt.Println(t)
-	}
-}
-
-type Item struct {
-	Name  string
-	Size  float64
-	Count int
-}
-
-// Save implements the ValueSaver interface.
-func (i *Item) Save() (map[string]bigquery.Value, string, error) {
-	return map[string]bigquery.Value{
-		"Name":  i.Name,
-		"Size":  i.Size,
-		"Count": i.Count,
-	}, "", nil
-}
-
-func ExampleInserter_Put() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ins := client.Dataset("my_dataset").Table("my_table").Inserter()
-	// Item implements the ValueSaver interface.
-	items := []*Item{
-		{Name: "n1", Size: 32.6, Count: 7},
-		{Name: "n2", Size: 4, Count: 2},
-		{Name: "n3", Size: 101.5, Count: 1},
-	}
-	if err := ins.Put(ctx, items); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-var schema bigquery.Schema
-
-func ExampleInserter_Put_structSaver() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ins := client.Dataset("my_dataset").Table("my_table").Inserter()
-
-	type score struct {
-		Name string
-		Num  int
-	}
-
-	// Assume schema holds the table's schema.
-	savers := []*bigquery.StructSaver{
-		{Struct: score{Name: "n1", Num: 12}, Schema: schema, InsertID: "id1"},
-		{Struct: score{Name: "n2", Num: 31}, Schema: schema, InsertID: "id2"},
-		{Struct: score{Name: "n3", Num: 7}, Schema: schema, InsertID: "id3"},
-	}
-	if err := ins.Put(ctx, savers); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleInserter_Put_struct() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-	ins := client.Dataset("my_dataset").Table("my_table").Inserter()
-
-	type score struct {
-		Name string
-		Num  int
-	}
-	scores := []score{
-		{Name: "n1", Num: 12},
-		{Name: "n2", Num: 31},
-		{Name: "n3", Num: 7},
-	}
-	// Schema is inferred from the score type.
-	if err := ins.Put(ctx, scores); err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleInserter_Put_valuesSaver() {
-	ctx := context.Background()
-	client, err := bigquery.NewClient(ctx, "project-id")
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	ins := client.Dataset("my_dataset").Table("my_table").Inserter()
-
-	var vss []*bigquery.ValuesSaver
-	for i, name := range []string{"n1", "n2", "n3"} {
-		// Assume schema holds the table's schema.
-		vss = append(vss, &bigquery.ValuesSaver{
-			Schema:   schema,
-			InsertID: name,
-			Row:      []bigquery.Value{name, int64(i)},
-		})
-	}
-
-	if err := ins.Put(ctx, vss); err != nil {
-		// TODO: Handle error.
-	}
-}

+ 0 - 400
vendor/cloud.google.com/go/bigquery/external.go

@@ -1,400 +0,0 @@
-// Copyright 2017 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"encoding/base64"
-	"unicode/utf8"
-
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// DataFormat describes the format of BigQuery table data.
-type DataFormat string
-
-// Constants describing the format of BigQuery table data.
-const (
-	CSV             DataFormat = "CSV"
-	Avro            DataFormat = "AVRO"
-	JSON            DataFormat = "NEWLINE_DELIMITED_JSON"
-	DatastoreBackup DataFormat = "DATASTORE_BACKUP"
-	GoogleSheets    DataFormat = "GOOGLE_SHEETS"
-	Bigtable        DataFormat = "BIGTABLE"
-	Parquet         DataFormat = "PARQUET"
-	ORC             DataFormat = "ORC"
-)
-
-// ExternalData is a table which is stored outside of BigQuery. It is implemented by
-// *ExternalDataConfig.
-// GCSReference also implements it, for backwards compatibility.
-type ExternalData interface {
-	toBQ() bq.ExternalDataConfiguration
-}
-
-// ExternalDataConfig describes data external to BigQuery that can be used
-// in queries and to create external tables.
-type ExternalDataConfig struct {
-	// The format of the data. Required.
-	SourceFormat DataFormat
-
-	// The fully-qualified URIs that point to your
-	// data in Google Cloud. Required.
-	//
-	// For Google Cloud Storage URIs, each URI can contain one '*' wildcard character
-	// and it must come after the 'bucket' name. Size limits related to load jobs
-	// apply to external data sources.
-	//
-	// For Google Cloud Bigtable URIs, exactly one URI can be specified and it has be
-	// a fully specified and valid HTTPS URL for a Google Cloud Bigtable table.
-	//
-	// For Google Cloud Datastore backups, exactly one URI can be specified. Also,
-	// the '*' wildcard character is not allowed.
-	SourceURIs []string
-
-	// The schema of the data. Required for CSV and JSON; disallowed for the
-	// other formats.
-	Schema Schema
-
-	// Try to detect schema and format options automatically.
-	// Any option specified explicitly will be honored.
-	AutoDetect bool
-
-	// The compression type of the data.
-	Compression Compression
-
-	// IgnoreUnknownValues causes values not matching the schema to be
-	// tolerated. Unknown values are ignored. For CSV this ignores extra values
-	// at the end of a line. For JSON this ignores named values that do not
-	// match any column name. If this field is not set, records containing
-	// unknown values are treated as bad records. The MaxBadRecords field can
-	// be used to customize how bad records are handled.
-	IgnoreUnknownValues bool
-
-	// MaxBadRecords is the maximum number of bad records that will be ignored
-	// when reading data.
-	MaxBadRecords int64
-
-	// Additional options for CSV, GoogleSheets and Bigtable formats.
-	Options ExternalDataConfigOptions
-}
-
-func (e *ExternalDataConfig) toBQ() bq.ExternalDataConfiguration {
-	q := bq.ExternalDataConfiguration{
-		SourceFormat:        string(e.SourceFormat),
-		SourceUris:          e.SourceURIs,
-		Autodetect:          e.AutoDetect,
-		Compression:         string(e.Compression),
-		IgnoreUnknownValues: e.IgnoreUnknownValues,
-		MaxBadRecords:       e.MaxBadRecords,
-	}
-	if e.Schema != nil {
-		q.Schema = e.Schema.toBQ()
-	}
-	if e.Options != nil {
-		e.Options.populateExternalDataConfig(&q)
-	}
-	return q
-}
-
-func bqToExternalDataConfig(q *bq.ExternalDataConfiguration) (*ExternalDataConfig, error) {
-	e := &ExternalDataConfig{
-		SourceFormat:        DataFormat(q.SourceFormat),
-		SourceURIs:          q.SourceUris,
-		AutoDetect:          q.Autodetect,
-		Compression:         Compression(q.Compression),
-		IgnoreUnknownValues: q.IgnoreUnknownValues,
-		MaxBadRecords:       q.MaxBadRecords,
-		Schema:              bqToSchema(q.Schema),
-	}
-	switch {
-	case q.CsvOptions != nil:
-		e.Options = bqToCSVOptions(q.CsvOptions)
-	case q.GoogleSheetsOptions != nil:
-		e.Options = bqToGoogleSheetsOptions(q.GoogleSheetsOptions)
-	case q.BigtableOptions != nil:
-		var err error
-		e.Options, err = bqToBigtableOptions(q.BigtableOptions)
-		if err != nil {
-			return nil, err
-		}
-	}
-	return e, nil
-}
-
-// ExternalDataConfigOptions are additional options for external data configurations.
-// This interface is implemented by CSVOptions, GoogleSheetsOptions and BigtableOptions.
-type ExternalDataConfigOptions interface {
-	populateExternalDataConfig(*bq.ExternalDataConfiguration)
-}
-
-// CSVOptions are additional options for CSV external data sources.
-type CSVOptions struct {
-	// AllowJaggedRows causes missing trailing optional columns to be tolerated
-	// when reading CSV data. Missing values are treated as nulls.
-	AllowJaggedRows bool
-
-	// AllowQuotedNewlines sets whether quoted data sections containing
-	// newlines are allowed when reading CSV data.
-	AllowQuotedNewlines bool
-
-	// Encoding is the character encoding of data to be read.
-	Encoding Encoding
-
-	// FieldDelimiter is the separator for fields in a CSV file, used when
-	// reading or exporting data. The default is ",".
-	FieldDelimiter string
-
-	// Quote is the value used to quote data sections in a CSV file. The
-	// default quotation character is the double quote ("), which is used if
-	// both Quote and ForceZeroQuote are unset.
-	// To specify that no character should be interpreted as a quotation
-	// character, set ForceZeroQuote to true.
-	// Only used when reading data.
-	Quote          string
-	ForceZeroQuote bool
-
-	// The number of rows at the top of a CSV file that BigQuery will skip when
-	// reading data.
-	SkipLeadingRows int64
-}
-
-func (o *CSVOptions) populateExternalDataConfig(c *bq.ExternalDataConfiguration) {
-	c.CsvOptions = &bq.CsvOptions{
-		AllowJaggedRows:     o.AllowJaggedRows,
-		AllowQuotedNewlines: o.AllowQuotedNewlines,
-		Encoding:            string(o.Encoding),
-		FieldDelimiter:      o.FieldDelimiter,
-		Quote:               o.quote(),
-		SkipLeadingRows:     o.SkipLeadingRows,
-	}
-}
-
-// quote returns the CSV quote character, or nil if unset.
-func (o *CSVOptions) quote() *string {
-	if o.ForceZeroQuote {
-		quote := ""
-		return &quote
-	}
-	if o.Quote == "" {
-		return nil
-	}
-	return &o.Quote
-}
-
-func (o *CSVOptions) setQuote(ps *string) {
-	if ps != nil {
-		o.Quote = *ps
-		if o.Quote == "" {
-			o.ForceZeroQuote = true
-		}
-	}
-}
-
-func bqToCSVOptions(q *bq.CsvOptions) *CSVOptions {
-	o := &CSVOptions{
-		AllowJaggedRows:     q.AllowJaggedRows,
-		AllowQuotedNewlines: q.AllowQuotedNewlines,
-		Encoding:            Encoding(q.Encoding),
-		FieldDelimiter:      q.FieldDelimiter,
-		SkipLeadingRows:     q.SkipLeadingRows,
-	}
-	o.setQuote(q.Quote)
-	return o
-}
-
-// GoogleSheetsOptions are additional options for GoogleSheets external data sources.
-type GoogleSheetsOptions struct {
-	// The number of rows at the top of a sheet that BigQuery will skip when
-	// reading data.
-	SkipLeadingRows int64
-}
-
-func (o *GoogleSheetsOptions) populateExternalDataConfig(c *bq.ExternalDataConfiguration) {
-	c.GoogleSheetsOptions = &bq.GoogleSheetsOptions{
-		SkipLeadingRows: o.SkipLeadingRows,
-	}
-}
-
-func bqToGoogleSheetsOptions(q *bq.GoogleSheetsOptions) *GoogleSheetsOptions {
-	return &GoogleSheetsOptions{
-		SkipLeadingRows: q.SkipLeadingRows,
-	}
-}
-
-// BigtableOptions are additional options for Bigtable external data sources.
-type BigtableOptions struct {
-	// A list of column families to expose in the table schema along with their
-	// types. If omitted, all column families are present in the table schema and
-	// their values are read as BYTES.
-	ColumnFamilies []*BigtableColumnFamily
-
-	// If true, then the column families that are not specified in columnFamilies
-	// list are not exposed in the table schema. Otherwise, they are read with BYTES
-	// type values. The default is false.
-	IgnoreUnspecifiedColumnFamilies bool
-
-	// If true, then the rowkey column families will be read and converted to string.
-	// Otherwise they are read with BYTES type values and users need to manually cast
-	// them with CAST if necessary. The default is false.
-	ReadRowkeyAsString bool
-}
-
-func (o *BigtableOptions) populateExternalDataConfig(c *bq.ExternalDataConfiguration) {
-	q := &bq.BigtableOptions{
-		IgnoreUnspecifiedColumnFamilies: o.IgnoreUnspecifiedColumnFamilies,
-		ReadRowkeyAsString:              o.ReadRowkeyAsString,
-	}
-	for _, f := range o.ColumnFamilies {
-		q.ColumnFamilies = append(q.ColumnFamilies, f.toBQ())
-	}
-	c.BigtableOptions = q
-}
-
-func bqToBigtableOptions(q *bq.BigtableOptions) (*BigtableOptions, error) {
-	b := &BigtableOptions{
-		IgnoreUnspecifiedColumnFamilies: q.IgnoreUnspecifiedColumnFamilies,
-		ReadRowkeyAsString:              q.ReadRowkeyAsString,
-	}
-	for _, f := range q.ColumnFamilies {
-		f2, err := bqToBigtableColumnFamily(f)
-		if err != nil {
-			return nil, err
-		}
-		b.ColumnFamilies = append(b.ColumnFamilies, f2)
-	}
-	return b, nil
-}
-
-// BigtableColumnFamily describes how BigQuery should access a Bigtable column family.
-type BigtableColumnFamily struct {
-	// Identifier of the column family.
-	FamilyID string
-
-	// Lists of columns that should be exposed as individual fields as opposed to a
-	// list of (column name, value) pairs. All columns whose qualifier matches a
-	// qualifier in this list can be accessed as .. Other columns can be accessed as
-	// a list through .Column field.
-	Columns []*BigtableColumn
-
-	// The encoding of the values when the type is not STRING. Acceptable encoding values are:
-	// - TEXT - indicates values are alphanumeric text strings.
-	// - BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions.
-	// This can be overridden for a specific column by listing that column in 'columns' and
-	// specifying an encoding for it.
-	Encoding string
-
-	// If true, only the latest version of values are exposed for all columns in this
-	// column family. This can be overridden for a specific column by listing that
-	// column in 'columns' and specifying a different setting for that column.
-	OnlyReadLatest bool
-
-	// The type to convert the value in cells of this
-	// column family. The values are expected to be encoded using HBase
-	// Bytes.toBytes function when using the BINARY encoding value.
-	// Following BigQuery types are allowed (case-sensitive):
-	// BYTES STRING INTEGER FLOAT BOOLEAN.
-	// The default type is BYTES. This can be overridden for a specific column by
-	// listing that column in 'columns' and specifying a type for it.
-	Type string
-}
-
-func (b *BigtableColumnFamily) toBQ() *bq.BigtableColumnFamily {
-	q := &bq.BigtableColumnFamily{
-		FamilyId:       b.FamilyID,
-		Encoding:       b.Encoding,
-		OnlyReadLatest: b.OnlyReadLatest,
-		Type:           b.Type,
-	}
-	for _, col := range b.Columns {
-		q.Columns = append(q.Columns, col.toBQ())
-	}
-	return q
-}
-
-func bqToBigtableColumnFamily(q *bq.BigtableColumnFamily) (*BigtableColumnFamily, error) {
-	b := &BigtableColumnFamily{
-		FamilyID:       q.FamilyId,
-		Encoding:       q.Encoding,
-		OnlyReadLatest: q.OnlyReadLatest,
-		Type:           q.Type,
-	}
-	for _, col := range q.Columns {
-		c, err := bqToBigtableColumn(col)
-		if err != nil {
-			return nil, err
-		}
-		b.Columns = append(b.Columns, c)
-	}
-	return b, nil
-}
-
-// BigtableColumn describes how BigQuery should access a Bigtable column.
-type BigtableColumn struct {
-	// Qualifier of the column. Columns in the parent column family that have this
-	// exact qualifier are exposed as . field. The column field name is the
-	// same as the column qualifier.
-	Qualifier string
-
-	// If the qualifier is not a valid BigQuery field identifier i.e. does not match
-	// [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as the column field
-	// name and is used as field name in queries.
-	FieldName string
-
-	// If true, only the latest version of values are exposed for this column.
-	// See BigtableColumnFamily.OnlyReadLatest.
-	OnlyReadLatest bool
-
-	// The encoding of the values when the type is not STRING.
-	// See BigtableColumnFamily.Encoding
-	Encoding string
-
-	// The type to convert the value in cells of this column.
-	// See BigtableColumnFamily.Type
-	Type string
-}
-
-func (b *BigtableColumn) toBQ() *bq.BigtableColumn {
-	q := &bq.BigtableColumn{
-		FieldName:      b.FieldName,
-		OnlyReadLatest: b.OnlyReadLatest,
-		Encoding:       b.Encoding,
-		Type:           b.Type,
-	}
-	if utf8.ValidString(b.Qualifier) {
-		q.QualifierString = b.Qualifier
-	} else {
-		q.QualifierEncoded = base64.RawStdEncoding.EncodeToString([]byte(b.Qualifier))
-	}
-	return q
-}
-
-func bqToBigtableColumn(q *bq.BigtableColumn) (*BigtableColumn, error) {
-	b := &BigtableColumn{
-		FieldName:      q.FieldName,
-		OnlyReadLatest: q.OnlyReadLatest,
-		Encoding:       q.Encoding,
-		Type:           q.Type,
-	}
-	if q.QualifierString != "" {
-		b.Qualifier = q.QualifierString
-	} else {
-		bytes, err := base64.RawStdEncoding.DecodeString(q.QualifierEncoded)
-		if err != nil {
-			return nil, err
-		}
-		b.Qualifier = string(bytes)
-	}
-	return b, nil
-}

+ 0 - 143
vendor/cloud.google.com/go/bigquery/external_test.go

@@ -1,143 +0,0 @@
-// Copyright 2017 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"testing"
-
-	"cloud.google.com/go/internal/pretty"
-	"cloud.google.com/go/internal/testutil"
-)
-
-func TestExternalDataConfig(t *testing.T) {
-	// Round-trip of ExternalDataConfig to underlying representation.
-	for i, want := range []*ExternalDataConfig{
-		{
-			SourceFormat:        CSV,
-			SourceURIs:          []string{"uri"},
-			Schema:              Schema{{Name: "n", Type: IntegerFieldType}},
-			AutoDetect:          true,
-			Compression:         Gzip,
-			IgnoreUnknownValues: true,
-			MaxBadRecords:       17,
-			Options: &CSVOptions{
-				AllowJaggedRows:     true,
-				AllowQuotedNewlines: true,
-				Encoding:            UTF_8,
-				FieldDelimiter:      "f",
-				Quote:               "q",
-				SkipLeadingRows:     3,
-			},
-		},
-		{
-			SourceFormat: GoogleSheets,
-			Options:      &GoogleSheetsOptions{SkipLeadingRows: 4},
-		},
-		{
-			SourceFormat: Bigtable,
-			Options: &BigtableOptions{
-				IgnoreUnspecifiedColumnFamilies: true,
-				ReadRowkeyAsString:              true,
-				ColumnFamilies: []*BigtableColumnFamily{
-					{
-						FamilyID:       "f1",
-						Encoding:       "TEXT",
-						OnlyReadLatest: true,
-						Type:           "FLOAT",
-						Columns: []*BigtableColumn{
-							{
-								Qualifier:      "valid-utf-8",
-								FieldName:      "fn",
-								OnlyReadLatest: true,
-								Encoding:       "BINARY",
-								Type:           "STRING",
-							},
-						},
-					},
-				},
-			},
-		},
-	} {
-		q := want.toBQ()
-		got, err := bqToExternalDataConfig(&q)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if diff := testutil.Diff(got, want); diff != "" {
-			t.Errorf("#%d: got=-, want=+:\n%s", i, diff)
-		}
-	}
-}
-
-func TestQuote(t *testing.T) {
-	ptr := func(s string) *string { return &s }
-
-	for _, test := range []struct {
-		quote string
-		force bool
-		want  *string
-	}{
-		{"", false, nil},
-		{"", true, ptr("")},
-		{"-", false, ptr("-")},
-		{"-", true, ptr("")},
-	} {
-		o := CSVOptions{
-			Quote:          test.quote,
-			ForceZeroQuote: test.force,
-		}
-		got := o.quote()
-		if (got == nil) != (test.want == nil) {
-			t.Errorf("%+v\ngot %v\nwant %v", test, pretty.Value(got), pretty.Value(test.want))
-		}
-		if got != nil && test.want != nil && *got != *test.want {
-			t.Errorf("%+v: got %q, want %q", test, *got, *test.want)
-		}
-	}
-}
-
-func TestQualifier(t *testing.T) {
-	b := BigtableColumn{Qualifier: "a"}
-	q := b.toBQ()
-	if q.QualifierString != b.Qualifier || q.QualifierEncoded != "" {
-		t.Errorf("got (%q, %q), want (%q, %q)",
-			q.QualifierString, q.QualifierEncoded, b.Qualifier, "")
-	}
-	b2, err := bqToBigtableColumn(q)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got, want := b2.Qualifier, b.Qualifier; got != want {
-		t.Errorf("got %q, want %q", got, want)
-	}
-
-	const (
-		invalidUTF8    = "\xDF\xFF"
-		invalidEncoded = "3/8"
-	)
-	b = BigtableColumn{Qualifier: invalidUTF8}
-	q = b.toBQ()
-	if q.QualifierString != "" || q.QualifierEncoded != invalidEncoded {
-		t.Errorf("got (%q, %q), want (%q, %q)",
-			q.QualifierString, "", b.Qualifier, invalidEncoded)
-	}
-	b2, err = bqToBigtableColumn(q)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got, want := b2.Qualifier, b.Qualifier; got != want {
-		t.Errorf("got %q, want %q", got, want)
-	}
-}

+ 0 - 110
vendor/cloud.google.com/go/bigquery/extract.go

@@ -1,110 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-
-	"cloud.google.com/go/internal/trace"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// ExtractConfig holds the configuration for an extract job.
-type ExtractConfig struct {
-	// Src is the table from which data will be extracted.
-	Src *Table
-
-	// Dst is the destination into which the data will be extracted.
-	Dst *GCSReference
-
-	// DisableHeader disables the printing of a header row in exported data.
-	DisableHeader bool
-
-	// The labels associated with this job.
-	Labels map[string]string
-}
-
-func (e *ExtractConfig) toBQ() *bq.JobConfiguration {
-	var printHeader *bool
-	if e.DisableHeader {
-		f := false
-		printHeader = &f
-	}
-	return &bq.JobConfiguration{
-		Labels: e.Labels,
-		Extract: &bq.JobConfigurationExtract{
-			DestinationUris:   append([]string{}, e.Dst.URIs...),
-			Compression:       string(e.Dst.Compression),
-			DestinationFormat: string(e.Dst.DestinationFormat),
-			FieldDelimiter:    e.Dst.FieldDelimiter,
-			SourceTable:       e.Src.toBQ(),
-			PrintHeader:       printHeader,
-		},
-	}
-}
-
-func bqToExtractConfig(q *bq.JobConfiguration, c *Client) *ExtractConfig {
-	qe := q.Extract
-	return &ExtractConfig{
-		Labels: q.Labels,
-		Dst: &GCSReference{
-			URIs:              qe.DestinationUris,
-			Compression:       Compression(qe.Compression),
-			DestinationFormat: DataFormat(qe.DestinationFormat),
-			FileConfig: FileConfig{
-				CSVOptions: CSVOptions{
-					FieldDelimiter: qe.FieldDelimiter,
-				},
-			},
-		},
-		DisableHeader: qe.PrintHeader != nil && !*qe.PrintHeader,
-		Src:           bqToTable(qe.SourceTable, c),
-	}
-}
-
-// An Extractor extracts data from a BigQuery table into Google Cloud Storage.
-type Extractor struct {
-	JobIDConfig
-	ExtractConfig
-	c *Client
-}
-
-// ExtractorTo returns an Extractor which can be used to extract data from a
-// BigQuery table into Google Cloud Storage.
-// The returned Extractor may optionally be further configured before its Run method is called.
-func (t *Table) ExtractorTo(dst *GCSReference) *Extractor {
-	return &Extractor{
-		c: t.c,
-		ExtractConfig: ExtractConfig{
-			Src: t,
-			Dst: dst,
-		},
-	}
-}
-
-// Run initiates an extract job.
-func (e *Extractor) Run(ctx context.Context) (j *Job, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Extractor.Run")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	return e.c.insertJob(ctx, e.newJob(), nil)
-}
-
-func (e *Extractor) newJob() *bq.Job {
-	return &bq.Job{
-		JobReference:  e.JobIDConfig.createJobRef(e.c),
-		Configuration: e.ExtractConfig.toBQ(),
-	}
-}

+ 0 - 116
vendor/cloud.google.com/go/bigquery/extract_test.go

@@ -1,116 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"testing"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func defaultExtractJob() *bq.Job {
-	return &bq.Job{
-		JobReference: &bq.JobReference{JobId: "RANDOM", ProjectId: "client-project-id"},
-		Configuration: &bq.JobConfiguration{
-			Extract: &bq.JobConfigurationExtract{
-				SourceTable: &bq.TableReference{
-					ProjectId: "client-project-id",
-					DatasetId: "dataset-id",
-					TableId:   "table-id",
-				},
-				DestinationUris: []string{"uri"},
-			},
-		},
-	}
-}
-
-func defaultGCS() *GCSReference {
-	return &GCSReference{
-		URIs: []string{"uri"},
-	}
-}
-
-func TestExtract(t *testing.T) {
-	defer fixRandomID("RANDOM")()
-	c := &Client{
-		projectID: "client-project-id",
-	}
-
-	testCases := []struct {
-		dst    *GCSReference
-		src    *Table
-		config ExtractConfig
-		want   *bq.Job
-	}{
-		{
-			dst:  defaultGCS(),
-			src:  c.Dataset("dataset-id").Table("table-id"),
-			want: defaultExtractJob(),
-		},
-		{
-			dst: defaultGCS(),
-			src: c.Dataset("dataset-id").Table("table-id"),
-			config: ExtractConfig{
-				DisableHeader: true,
-				Labels:        map[string]string{"a": "b"},
-			},
-			want: func() *bq.Job {
-				j := defaultExtractJob()
-				j.Configuration.Labels = map[string]string{"a": "b"}
-				f := false
-				j.Configuration.Extract.PrintHeader = &f
-				return j
-			}(),
-		},
-		{
-			dst: func() *GCSReference {
-				g := NewGCSReference("uri")
-				g.Compression = Gzip
-				g.DestinationFormat = JSON
-				g.FieldDelimiter = "\t"
-				return g
-			}(),
-			src: c.Dataset("dataset-id").Table("table-id"),
-			want: func() *bq.Job {
-				j := defaultExtractJob()
-				j.Configuration.Extract.Compression = "GZIP"
-				j.Configuration.Extract.DestinationFormat = "NEWLINE_DELIMITED_JSON"
-				j.Configuration.Extract.FieldDelimiter = "\t"
-				return j
-			}(),
-		},
-	}
-
-	for i, tc := range testCases {
-		ext := tc.src.ExtractorTo(tc.dst)
-		tc.config.Src = ext.Src
-		tc.config.Dst = ext.Dst
-		ext.ExtractConfig = tc.config
-		got := ext.newJob()
-		checkJob(t, i, got, tc.want)
-
-		jc, err := bqToJobConfig(got.Configuration, c)
-		if err != nil {
-			t.Fatalf("#%d: %v", i, err)
-		}
-		diff := testutil.Diff(jc, &ext.ExtractConfig,
-			cmp.AllowUnexported(Table{}, Client{}))
-		if diff != "" {
-			t.Errorf("#%d: (got=-, want=+:\n%s", i, diff)
-		}
-	}
-}

+ 0 - 137
vendor/cloud.google.com/go/bigquery/file.go

@@ -1,137 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"io"
-
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// A ReaderSource is a source for a load operation that gets
-// data from an io.Reader.
-//
-// When a ReaderSource is part of a LoadConfig obtained via Job.Config,
-// its internal io.Reader will be nil, so it cannot be used for a
-// subsequent load operation.
-type ReaderSource struct {
-	r io.Reader
-	FileConfig
-}
-
-// NewReaderSource creates a ReaderSource from an io.Reader. You may
-// optionally configure properties on the ReaderSource that describe the
-// data being read, before passing it to Table.LoaderFrom.
-func NewReaderSource(r io.Reader) *ReaderSource {
-	return &ReaderSource{r: r}
-}
-
-func (r *ReaderSource) populateLoadConfig(lc *bq.JobConfigurationLoad) io.Reader {
-	r.FileConfig.populateLoadConfig(lc)
-	return r.r
-}
-
-// FileConfig contains configuration options that pertain to files, typically
-// text files that require interpretation to be used as a BigQuery table. A
-// file may live in Google Cloud Storage (see GCSReference), or it may be
-// loaded into a table via the Table.LoaderFromReader.
-type FileConfig struct {
-	// SourceFormat is the format of the data to be read.
-	// Allowed values are: Avro, CSV, DatastoreBackup, JSON, ORC, and Parquet.  The default is CSV.
-	SourceFormat DataFormat
-
-	// Indicates if we should automatically infer the options and
-	// schema for CSV and JSON sources.
-	AutoDetect bool
-
-	// MaxBadRecords is the maximum number of bad records that will be ignored
-	// when reading data.
-	MaxBadRecords int64
-
-	// IgnoreUnknownValues causes values not matching the schema to be
-	// tolerated. Unknown values are ignored. For CSV this ignores extra values
-	// at the end of a line. For JSON this ignores named values that do not
-	// match any column name. If this field is not set, records containing
-	// unknown values are treated as bad records. The MaxBadRecords field can
-	// be used to customize how bad records are handled.
-	IgnoreUnknownValues bool
-
-	// Schema describes the data. It is required when reading CSV or JSON data,
-	// unless the data is being loaded into a table that already exists.
-	Schema Schema
-
-	// Additional options for CSV files.
-	CSVOptions
-}
-
-func (fc *FileConfig) populateLoadConfig(conf *bq.JobConfigurationLoad) {
-	conf.SkipLeadingRows = fc.SkipLeadingRows
-	conf.SourceFormat = string(fc.SourceFormat)
-	conf.Autodetect = fc.AutoDetect
-	conf.AllowJaggedRows = fc.AllowJaggedRows
-	conf.AllowQuotedNewlines = fc.AllowQuotedNewlines
-	conf.Encoding = string(fc.Encoding)
-	conf.FieldDelimiter = fc.FieldDelimiter
-	conf.IgnoreUnknownValues = fc.IgnoreUnknownValues
-	conf.MaxBadRecords = fc.MaxBadRecords
-	if fc.Schema != nil {
-		conf.Schema = fc.Schema.toBQ()
-	}
-	conf.Quote = fc.quote()
-}
-
-func bqPopulateFileConfig(conf *bq.JobConfigurationLoad, fc *FileConfig) {
-	fc.SourceFormat = DataFormat(conf.SourceFormat)
-	fc.AutoDetect = conf.Autodetect
-	fc.MaxBadRecords = conf.MaxBadRecords
-	fc.IgnoreUnknownValues = conf.IgnoreUnknownValues
-	fc.Schema = bqToSchema(conf.Schema)
-	fc.SkipLeadingRows = conf.SkipLeadingRows
-	fc.AllowJaggedRows = conf.AllowJaggedRows
-	fc.AllowQuotedNewlines = conf.AllowQuotedNewlines
-	fc.Encoding = Encoding(conf.Encoding)
-	fc.FieldDelimiter = conf.FieldDelimiter
-	fc.CSVOptions.setQuote(conf.Quote)
-}
-
-func (fc *FileConfig) populateExternalDataConfig(conf *bq.ExternalDataConfiguration) {
-	format := fc.SourceFormat
-	if format == "" {
-		// Format must be explicitly set for external data sources.
-		format = CSV
-	}
-	conf.Autodetect = fc.AutoDetect
-	conf.IgnoreUnknownValues = fc.IgnoreUnknownValues
-	conf.MaxBadRecords = fc.MaxBadRecords
-	conf.SourceFormat = string(format)
-	if fc.Schema != nil {
-		conf.Schema = fc.Schema.toBQ()
-	}
-	if format == CSV {
-		fc.CSVOptions.populateExternalDataConfig(conf)
-	}
-}
-
-// Encoding specifies the character encoding of data to be loaded into BigQuery.
-// See https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.load.encoding
-// for more details about how this is used.
-type Encoding string
-
-const (
-	// UTF_8 specifies the UTF-8 encoding type.
-	UTF_8 Encoding = "UTF-8"
-	// ISO_8859_1 specifies the ISO-8859-1 encoding type.
-	ISO_8859_1 Encoding = "ISO-8859-1"
-)

+ 0 - 98
vendor/cloud.google.com/go/bigquery/file_test.go

@@ -1,98 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"testing"
-
-	"cloud.google.com/go/internal/pretty"
-	"cloud.google.com/go/internal/testutil"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-var (
-	hyphen = "-"
-	fc     = FileConfig{
-		SourceFormat:        CSV,
-		AutoDetect:          true,
-		MaxBadRecords:       7,
-		IgnoreUnknownValues: true,
-		Schema: Schema{
-			stringFieldSchema(),
-			nestedFieldSchema(),
-		},
-		CSVOptions: CSVOptions{
-			Quote:               hyphen,
-			FieldDelimiter:      "\t",
-			SkipLeadingRows:     8,
-			AllowJaggedRows:     true,
-			AllowQuotedNewlines: true,
-			Encoding:            UTF_8,
-		},
-	}
-)
-
-func TestFileConfigPopulateLoadConfig(t *testing.T) {
-	want := &bq.JobConfigurationLoad{
-		SourceFormat:        "CSV",
-		FieldDelimiter:      "\t",
-		SkipLeadingRows:     8,
-		AllowJaggedRows:     true,
-		AllowQuotedNewlines: true,
-		Autodetect:          true,
-		Encoding:            "UTF-8",
-		MaxBadRecords:       7,
-		IgnoreUnknownValues: true,
-		Schema: &bq.TableSchema{
-			Fields: []*bq.TableFieldSchema{
-				bqStringFieldSchema(),
-				bqNestedFieldSchema(),
-			}},
-		Quote: &hyphen,
-	}
-	got := &bq.JobConfigurationLoad{}
-	fc.populateLoadConfig(got)
-	if !testutil.Equal(got, want) {
-		t.Errorf("got:\n%v\nwant:\n%v", pretty.Value(got), pretty.Value(want))
-	}
-}
-
-func TestFileConfigPopulateExternalDataConfig(t *testing.T) {
-	got := &bq.ExternalDataConfiguration{}
-	fc.populateExternalDataConfig(got)
-
-	want := &bq.ExternalDataConfiguration{
-		SourceFormat:        "CSV",
-		Autodetect:          true,
-		MaxBadRecords:       7,
-		IgnoreUnknownValues: true,
-		Schema: &bq.TableSchema{
-			Fields: []*bq.TableFieldSchema{
-				bqStringFieldSchema(),
-				bqNestedFieldSchema(),
-			}},
-		CsvOptions: &bq.CsvOptions{
-			AllowJaggedRows:     true,
-			AllowQuotedNewlines: true,
-			Encoding:            "UTF-8",
-			FieldDelimiter:      "\t",
-			Quote:               &hyphen,
-			SkipLeadingRows:     8,
-		},
-	}
-	if diff := testutil.Diff(got, want); diff != "" {
-		t.Errorf("got=-, want=+:\n%s", diff)
-	}
-}

+ 0 - 75
vendor/cloud.google.com/go/bigquery/gcs.go

@@ -1,75 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"io"
-
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// GCSReference is a reference to one or more Google Cloud Storage objects, which together constitute
-// an input or output to a BigQuery operation.
-type GCSReference struct {
-	// URIs refer to Google Cloud Storage objects.
-	URIs []string
-
-	FileConfig
-
-	// DestinationFormat is the format to use when writing exported files.
-	// Allowed values are: CSV, Avro, JSON.  The default is CSV.
-	// CSV is not supported for tables with nested or repeated fields.
-	DestinationFormat DataFormat
-
-	// Compression specifies the type of compression to apply when writing data
-	// to Google Cloud Storage, or using this GCSReference as an ExternalData
-	// source with CSV or JSON SourceFormat. Default is None.
-	Compression Compression
-}
-
-// NewGCSReference constructs a reference to one or more Google Cloud Storage objects, which together constitute a data source or destination.
-// In the simple case, a single URI in the form gs://bucket/object may refer to a single GCS object.
-// Data may also be split into mutiple files, if multiple URIs or URIs containing wildcards are provided.
-// Each URI may contain one '*' wildcard character, which (if present) must come after the bucket name.
-// For more information about the treatment of wildcards and multiple URIs,
-// see https://cloud.google.com/bigquery/exporting-data-from-bigquery#exportingmultiple
-func NewGCSReference(uri ...string) *GCSReference {
-	return &GCSReference{URIs: uri}
-}
-
-// Compression is the type of compression to apply when writing data to Google Cloud Storage.
-type Compression string
-
-const (
-	// None specifies no compression.
-	None Compression = "NONE"
-	// Gzip specifies gzip compression.
-	Gzip Compression = "GZIP"
-)
-
-func (gcs *GCSReference) populateLoadConfig(lc *bq.JobConfigurationLoad) io.Reader {
-	lc.SourceUris = gcs.URIs
-	gcs.FileConfig.populateLoadConfig(lc)
-	return nil
-}
-
-func (gcs *GCSReference) toBQ() bq.ExternalDataConfiguration {
-	conf := bq.ExternalDataConfiguration{
-		Compression: string(gcs.Compression),
-		SourceUris:  append([]string{}, gcs.URIs...),
-	}
-	gcs.FileConfig.populateExternalDataConfig(&conf)
-	return conf
-}

+ 0 - 238
vendor/cloud.google.com/go/bigquery/inserter.go

@@ -1,238 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"reflect"
-
-	"cloud.google.com/go/internal/trace"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// An Inserter does streaming inserts into a BigQuery table.
-// It is safe for concurrent use.
-type Inserter struct {
-	t *Table
-
-	// SkipInvalidRows causes rows containing invalid data to be silently
-	// ignored. The default value is false, which causes the entire request to
-	// fail if there is an attempt to insert an invalid row.
-	SkipInvalidRows bool
-
-	// IgnoreUnknownValues causes values not matching the schema to be ignored.
-	// The default value is false, which causes records containing such values
-	// to be treated as invalid records.
-	IgnoreUnknownValues bool
-
-	// A TableTemplateSuffix allows Inserters to create tables automatically.
-	//
-	// Experimental: this option is experimental and may be modified or removed in future versions,
-	// regardless of any other documented package stability guarantees.
-	//
-	// When you specify a suffix, the table you upload data to
-	// will be used as a template for creating a new table, with the same schema,
-	// called <table> + <suffix>.
-	//
-	// More information is available at
-	// https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables
-	TableTemplateSuffix string
-}
-
-// Inserter returns an Inserter that can be used to append rows to t.
-// The returned Inserter may optionally be further configured before its Put method is called.
-//
-// To stream rows into a date-partitioned table at a particular date, add the
-// $yyyymmdd suffix to the table name when constructing the Table.
-func (t *Table) Inserter() *Inserter {
-	return &Inserter{t: t}
-}
-
-// Uploader calls Inserter.
-// Deprecated: use Table.Inserter instead.
-func (t *Table) Uploader() *Inserter { return t.Inserter() }
-
-// Put uploads one or more rows to the BigQuery service.
-//
-// If src is ValueSaver, then its Save method is called to produce a row for uploading.
-//
-// If src is a struct or pointer to a struct, then a schema is inferred from it
-// and used to create a StructSaver. The InsertID of the StructSaver will be
-// empty.
-//
-// If src is a slice of ValueSavers, structs, or struct pointers, then each
-// element of the slice is treated as above, and multiple rows are uploaded.
-//
-// Put returns a PutMultiError if one or more rows failed to be uploaded.
-// The PutMultiError contains a RowInsertionError for each failed row.
-//
-// Put will retry on temporary errors (see
-// https://cloud.google.com/bigquery/troubleshooting-errors). This can result
-// in duplicate rows if you do not use insert IDs. Also, if the error persists,
-// the call will run indefinitely. Pass a context with a timeout to prevent
-// hanging calls.
-func (u *Inserter) Put(ctx context.Context, src interface{}) (err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Inserter.Put")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	savers, err := valueSavers(src)
-	if err != nil {
-		return err
-	}
-	return u.putMulti(ctx, savers)
-}
-
-func valueSavers(src interface{}) ([]ValueSaver, error) {
-	saver, ok, err := toValueSaver(src)
-	if err != nil {
-		return nil, err
-	}
-	if ok {
-		return []ValueSaver{saver}, nil
-	}
-	srcVal := reflect.ValueOf(src)
-	if srcVal.Kind() != reflect.Slice {
-		return nil, fmt.Errorf("%T is not a ValueSaver, struct, struct pointer, or slice", src)
-
-	}
-	var savers []ValueSaver
-	for i := 0; i < srcVal.Len(); i++ {
-		s := srcVal.Index(i).Interface()
-		saver, ok, err := toValueSaver(s)
-		if err != nil {
-			return nil, err
-		}
-		if !ok {
-			return nil, fmt.Errorf("src[%d] has type %T, which is not a ValueSaver, struct or struct pointer", i, s)
-		}
-		savers = append(savers, saver)
-	}
-	return savers, nil
-}
-
-// Make a ValueSaver from x, which must implement ValueSaver already
-// or be a struct or pointer to struct.
-func toValueSaver(x interface{}) (ValueSaver, bool, error) {
-	if _, ok := x.(StructSaver); ok {
-		return nil, false, errors.New("bigquery: use &StructSaver, not StructSaver")
-	}
-	var insertID string
-	// Handle StructSavers specially so we can infer the schema if necessary.
-	if ss, ok := x.(*StructSaver); ok && ss.Schema == nil {
-		x = ss.Struct
-		insertID = ss.InsertID
-		// Fall through so we can infer the schema.
-	}
-	if saver, ok := x.(ValueSaver); ok {
-		return saver, ok, nil
-	}
-	v := reflect.ValueOf(x)
-	// Support Put with []interface{}
-	if v.Kind() == reflect.Interface {
-		v = v.Elem()
-	}
-	if v.Kind() == reflect.Ptr {
-		v = v.Elem()
-	}
-	if v.Kind() != reflect.Struct {
-		return nil, false, nil
-	}
-	schema, err := inferSchemaReflectCached(v.Type())
-	if err != nil {
-		return nil, false, err
-	}
-	return &StructSaver{
-		Struct:   x,
-		InsertID: insertID,
-		Schema:   schema,
-	}, true, nil
-}
-
-func (u *Inserter) putMulti(ctx context.Context, src []ValueSaver) error {
-	req, err := u.newInsertRequest(src)
-	if err != nil {
-		return err
-	}
-	if req == nil {
-		return nil
-	}
-	call := u.t.c.bqs.Tabledata.InsertAll(u.t.ProjectID, u.t.DatasetID, u.t.TableID, req)
-	call = call.Context(ctx)
-	setClientHeader(call.Header())
-	var res *bq.TableDataInsertAllResponse
-	err = runWithRetry(ctx, func() (err error) {
-		res, err = call.Do()
-		return err
-	})
-	if err != nil {
-		return err
-	}
-	return handleInsertErrors(res.InsertErrors, req.Rows)
-}
-
-func (u *Inserter) newInsertRequest(savers []ValueSaver) (*bq.TableDataInsertAllRequest, error) {
-	if savers == nil { // If there are no rows, do nothing.
-		return nil, nil
-	}
-	req := &bq.TableDataInsertAllRequest{
-		TemplateSuffix:      u.TableTemplateSuffix,
-		IgnoreUnknownValues: u.IgnoreUnknownValues,
-		SkipInvalidRows:     u.SkipInvalidRows,
-	}
-	for _, saver := range savers {
-		row, insertID, err := saver.Save()
-		if err != nil {
-			return nil, err
-		}
-		if insertID == "" {
-			insertID = randomIDFn()
-		}
-		m := make(map[string]bq.JsonValue)
-		for k, v := range row {
-			m[k] = bq.JsonValue(v)
-		}
-		req.Rows = append(req.Rows, &bq.TableDataInsertAllRequestRows{
-			InsertId: insertID,
-			Json:     m,
-		})
-	}
-	return req, nil
-}
-
-func handleInsertErrors(ierrs []*bq.TableDataInsertAllResponseInsertErrors, rows []*bq.TableDataInsertAllRequestRows) error {
-	if len(ierrs) == 0 {
-		return nil
-	}
-	var errs PutMultiError
-	for _, e := range ierrs {
-		if int(e.Index) > len(rows) {
-			return fmt.Errorf("internal error: unexpected row index: %v", e.Index)
-		}
-		rie := RowInsertionError{
-			InsertID: rows[e.Index].InsertId,
-			RowIndex: int(e.Index),
-		}
-		for _, errp := range e.Errors {
-			rie.Errors = append(rie.Errors, bqToError(errp))
-		}
-		errs = append(errs, rie)
-	}
-	return errs
-}
-
-// Uploader is an obsolete name for Inserter.
-type Uploader = Inserter

+ 0 - 210
vendor/cloud.google.com/go/bigquery/inserter_test.go

@@ -1,210 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"errors"
-	"strconv"
-	"testing"
-
-	"cloud.google.com/go/internal/pretty"
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-type testSaver struct {
-	row      map[string]Value
-	insertID string
-	err      error
-}
-
-func (ts testSaver) Save() (map[string]Value, string, error) {
-	return ts.row, ts.insertID, ts.err
-}
-
-func TestNewInsertRequest(t *testing.T) {
-	prev := randomIDFn
-	n := 0
-	randomIDFn = func() string { n++; return strconv.Itoa(n) }
-	defer func() { randomIDFn = prev }()
-
-	tests := []struct {
-		ul     *Uploader
-		savers []ValueSaver
-		req    *bq.TableDataInsertAllRequest
-	}{
-		{
-			ul:     &Uploader{},
-			savers: nil,
-			req:    nil,
-		},
-		{
-			ul: &Uploader{},
-			savers: []ValueSaver{
-				testSaver{row: map[string]Value{"one": 1}},
-				testSaver{row: map[string]Value{"two": 2}},
-			},
-			req: &bq.TableDataInsertAllRequest{
-				Rows: []*bq.TableDataInsertAllRequestRows{
-					{InsertId: "1", Json: map[string]bq.JsonValue{"one": 1}},
-					{InsertId: "2", Json: map[string]bq.JsonValue{"two": 2}},
-				},
-			},
-		},
-		{
-			ul: &Uploader{
-				TableTemplateSuffix: "suffix",
-				IgnoreUnknownValues: true,
-				SkipInvalidRows:     true,
-			},
-			savers: []ValueSaver{
-				testSaver{insertID: "a", row: map[string]Value{"one": 1}},
-				testSaver{insertID: "", row: map[string]Value{"two": 2}},
-			},
-			req: &bq.TableDataInsertAllRequest{
-				Rows: []*bq.TableDataInsertAllRequestRows{
-					{InsertId: "a", Json: map[string]bq.JsonValue{"one": 1}},
-					{InsertId: "3", Json: map[string]bq.JsonValue{"two": 2}},
-				},
-				TemplateSuffix:      "suffix",
-				SkipInvalidRows:     true,
-				IgnoreUnknownValues: true,
-			},
-		},
-	}
-	for i, tc := range tests {
-		got, err := tc.ul.newInsertRequest(tc.savers)
-		if err != nil {
-			t.Fatal(err)
-		}
-		want := tc.req
-		if !testutil.Equal(got, want) {
-			t.Errorf("%d: %#v: got %#v, want %#v", i, tc.ul, got, want)
-		}
-	}
-}
-
-func TestNewInsertRequestErrors(t *testing.T) {
-	var u Uploader
-	_, err := u.newInsertRequest([]ValueSaver{testSaver{err: errors.New("bang")}})
-	if err == nil {
-		t.Error("got nil, want error")
-	}
-}
-
-func TestHandleInsertErrors(t *testing.T) {
-	rows := []*bq.TableDataInsertAllRequestRows{
-		{InsertId: "a"},
-		{InsertId: "b"},
-	}
-	for _, test := range []struct {
-		in   []*bq.TableDataInsertAllResponseInsertErrors
-		want error
-	}{
-		{
-			in:   nil,
-			want: nil,
-		},
-		{
-			in:   []*bq.TableDataInsertAllResponseInsertErrors{{Index: 1}},
-			want: PutMultiError{RowInsertionError{InsertID: "b", RowIndex: 1}},
-		},
-		{
-			in:   []*bq.TableDataInsertAllResponseInsertErrors{{Index: 1}},
-			want: PutMultiError{RowInsertionError{InsertID: "b", RowIndex: 1}},
-		},
-		{
-			in: []*bq.TableDataInsertAllResponseInsertErrors{
-				{Errors: []*bq.ErrorProto{{Message: "m0"}}, Index: 0},
-				{Errors: []*bq.ErrorProto{{Message: "m1"}}, Index: 1},
-			},
-			want: PutMultiError{
-				RowInsertionError{InsertID: "a", RowIndex: 0, Errors: []error{&Error{Message: "m0"}}},
-				RowInsertionError{InsertID: "b", RowIndex: 1, Errors: []error{&Error{Message: "m1"}}},
-			},
-		},
-	} {
-		got := handleInsertErrors(test.in, rows)
-		if !testutil.Equal(got, test.want) {
-			t.Errorf("%#v:\ngot\n%#v\nwant\n%#v", test.in, got, test.want)
-		}
-	}
-}
-
-func TestValueSavers(t *testing.T) {
-	ts := &testSaver{}
-	type T struct{ I int }
-	schema, err := InferSchema(T{})
-	if err != nil {
-		t.Fatal(err)
-	}
-	for _, test := range []struct {
-		in   interface{}
-		want []ValueSaver
-	}{
-		{[]interface{}(nil), nil},
-		{[]interface{}{}, nil},
-		{ts, []ValueSaver{ts}},
-		{T{I: 1}, []ValueSaver{&StructSaver{Schema: schema, Struct: T{I: 1}}}},
-		{[]ValueSaver{ts, ts}, []ValueSaver{ts, ts}},
-		{[]interface{}{ts, ts}, []ValueSaver{ts, ts}},
-		{[]T{{I: 1}, {I: 2}}, []ValueSaver{
-			&StructSaver{Schema: schema, Struct: T{I: 1}},
-			&StructSaver{Schema: schema, Struct: T{I: 2}},
-		}},
-		{[]interface{}{T{I: 1}, &T{I: 2}}, []ValueSaver{
-			&StructSaver{Schema: schema, Struct: T{I: 1}},
-			&StructSaver{Schema: schema, Struct: &T{I: 2}},
-		}},
-		{&StructSaver{Struct: T{I: 3}, InsertID: "foo"},
-			[]ValueSaver{
-				&StructSaver{Schema: schema, Struct: T{I: 3}, InsertID: "foo"},
-			}},
-	} {
-		got, err := valueSavers(test.in)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(got, test.want, cmp.AllowUnexported(testSaver{})) {
-			t.Errorf("%+v: got %v, want %v", test.in, pretty.Value(got), pretty.Value(test.want))
-		}
-		// Make sure Save is successful.
-		for i, vs := range got {
-			_, _, err := vs.Save()
-			if err != nil {
-				t.Fatalf("%+v, #%d: got error %v, want nil", test.in, i, err)
-			}
-		}
-	}
-}
-
-func TestValueSaversErrors(t *testing.T) {
-	inputs := []interface{}{
-		nil,
-		1,
-		[]int{1, 2},
-		[]interface{}{
-			testSaver{row: map[string]Value{"one": 1}, insertID: "a"},
-			1,
-		},
-		StructSaver{},
-	}
-	for _, in := range inputs {
-		if _, err := valueSavers(in); err == nil {
-			t.Errorf("%#v: got nil, want error", in)
-		}
-	}
-}

+ 0 - 2186
vendor/cloud.google.com/go/bigquery/integration_test.go

@@ -1,2186 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"encoding/json"
-	"errors"
-	"flag"
-	"fmt"
-	"log"
-	"math/big"
-	"net/http"
-	"os"
-	"sort"
-	"strings"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/civil"
-	"cloud.google.com/go/httpreplay"
-	"cloud.google.com/go/internal"
-	"cloud.google.com/go/internal/pretty"
-	"cloud.google.com/go/internal/testutil"
-	"cloud.google.com/go/internal/uid"
-	"cloud.google.com/go/storage"
-	"github.com/google/go-cmp/cmp"
-	"github.com/google/go-cmp/cmp/cmpopts"
-	gax "github.com/googleapis/gax-go/v2"
-	"google.golang.org/api/googleapi"
-	"google.golang.org/api/iterator"
-	"google.golang.org/api/option"
-)
-
-const replayFilename = "bigquery.replay"
-
-var record = flag.Bool("record", false, "record RPCs")
-
-var (
-	client        *Client
-	storageClient *storage.Client
-	dataset       *Dataset
-	schema        = Schema{
-		{Name: "name", Type: StringFieldType},
-		{Name: "nums", Type: IntegerFieldType, Repeated: true},
-		{Name: "rec", Type: RecordFieldType, Schema: Schema{
-			{Name: "bool", Type: BooleanFieldType},
-		}},
-	}
-	testTableExpiration  time.Time
-	datasetIDs, tableIDs *uid.Space
-)
-
-// Note: integration tests cannot be run in parallel, because TestIntegration_Location
-// modifies the client.
-
-func TestMain(m *testing.M) {
-	cleanup := initIntegrationTest()
-	r := m.Run()
-	cleanup()
-	os.Exit(r)
-}
-
-func getClient(t *testing.T) *Client {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	return client
-}
-
-// If integration tests will be run, create a unique dataset for them.
-// Return a cleanup function.
-func initIntegrationTest() func() {
-	ctx := context.Background()
-	flag.Parse() // needed for testing.Short()
-	projID := testutil.ProjID()
-	switch {
-	case testing.Short() && *record:
-		log.Fatal("cannot combine -short and -record")
-		return func() {}
-
-	case testing.Short() && httpreplay.Supported() && testutil.CanReplay(replayFilename) && projID != "":
-		// go test -short with a replay file will replay the integration tests if the
-		// environment variables are set.
-		log.Printf("replaying from %s", replayFilename)
-		httpreplay.DebugHeaders()
-		replayer, err := httpreplay.NewReplayer(replayFilename)
-		if err != nil {
-			log.Fatal(err)
-		}
-		var t time.Time
-		if err := json.Unmarshal(replayer.Initial(), &t); err != nil {
-			log.Fatal(err)
-		}
-		hc, err := replayer.Client(ctx) // no creds needed
-		if err != nil {
-			log.Fatal(err)
-		}
-		client, err = NewClient(ctx, projID, option.WithHTTPClient(hc))
-		if err != nil {
-			log.Fatal(err)
-		}
-		storageClient, err = storage.NewClient(ctx, option.WithHTTPClient(hc))
-		if err != nil {
-			log.Fatal(err)
-		}
-		cleanup := initTestState(client, t)
-		return func() {
-			cleanup()
-			_ = replayer.Close() // No actionable error returned.
-		}
-
-	case testing.Short():
-		// go test -short without a replay file skips the integration tests.
-		if testutil.CanReplay(replayFilename) && projID != "" {
-			log.Print("replay not supported for Go versions before 1.8")
-		}
-		client = nil
-		storageClient = nil
-		return func() {}
-
-	default: // Run integration tests against a real backend.
-		ts := testutil.TokenSource(ctx, Scope)
-		if ts == nil {
-			log.Println("Integration tests skipped. See CONTRIBUTING.md for details")
-			return func() {}
-		}
-		bqOpt := option.WithTokenSource(ts)
-		sOpt := option.WithTokenSource(testutil.TokenSource(ctx, storage.ScopeFullControl))
-		cleanup := func() {}
-		now := time.Now().UTC()
-		if *record {
-			if !httpreplay.Supported() {
-				log.Print("record not supported for Go versions before 1.8")
-			} else {
-				nowBytes, err := json.Marshal(now)
-				if err != nil {
-					log.Fatal(err)
-				}
-				recorder, err := httpreplay.NewRecorder(replayFilename, nowBytes)
-				if err != nil {
-					log.Fatalf("could not record: %v", err)
-				}
-				log.Printf("recording to %s", replayFilename)
-				hc, err := recorder.Client(ctx, bqOpt)
-				if err != nil {
-					log.Fatal(err)
-				}
-				bqOpt = option.WithHTTPClient(hc)
-				hc, err = recorder.Client(ctx, sOpt)
-				if err != nil {
-					log.Fatal(err)
-				}
-				sOpt = option.WithHTTPClient(hc)
-				cleanup = func() {
-					if err := recorder.Close(); err != nil {
-						log.Printf("saving recording: %v", err)
-					}
-				}
-			}
-		}
-		var err error
-		client, err = NewClient(ctx, projID, bqOpt)
-		if err != nil {
-			log.Fatalf("NewClient: %v", err)
-		}
-		storageClient, err = storage.NewClient(ctx, sOpt)
-		if err != nil {
-			log.Fatalf("storage.NewClient: %v", err)
-		}
-		c := initTestState(client, now)
-		return func() { c(); cleanup() }
-	}
-}
-
-func initTestState(client *Client, t time.Time) func() {
-	// BigQuery does not accept hyphens in dataset or table IDs, so we create IDs
-	// with underscores.
-	ctx := context.Background()
-	opts := &uid.Options{Sep: '_', Time: t}
-	datasetIDs = uid.NewSpace("dataset", opts)
-	tableIDs = uid.NewSpace("table", opts)
-	testTableExpiration = t.Add(10 * time.Minute).Round(time.Second)
-	// For replayability, seed the random source with t.
-	Seed(t.UnixNano())
-
-	dataset = client.Dataset(datasetIDs.New())
-	if err := dataset.Create(ctx, nil); err != nil {
-		log.Fatalf("creating dataset %s: %v", dataset.DatasetID, err)
-	}
-	return func() {
-		if err := dataset.DeleteWithContents(ctx); err != nil {
-			log.Printf("could not delete %s", dataset.DatasetID)
-		}
-	}
-}
-
-func TestIntegration_TableCreate(t *testing.T) {
-	// Check that creating a record field with an empty schema is an error.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	table := dataset.Table("t_bad")
-	schema := Schema{
-		{Name: "rec", Type: RecordFieldType, Schema: Schema{}},
-	}
-	err := table.Create(context.Background(), &TableMetadata{
-		Schema:         schema,
-		ExpirationTime: testTableExpiration.Add(5 * time.Minute),
-	})
-	if err == nil {
-		t.Fatal("want error, got nil")
-	}
-	if !hasStatusCode(err, http.StatusBadRequest) {
-		t.Fatalf("want a 400 error, got %v", err)
-	}
-}
-
-func TestIntegration_TableCreateView(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	// Test that standard SQL views work.
-	view := dataset.Table("t_view_standardsql")
-	query := fmt.Sprintf("SELECT APPROX_COUNT_DISTINCT(name) FROM `%s.%s.%s`",
-		dataset.ProjectID, dataset.DatasetID, table.TableID)
-	err := view.Create(context.Background(), &TableMetadata{
-		ViewQuery:      query,
-		UseStandardSQL: true,
-	})
-	if err != nil {
-		t.Fatalf("table.create: Did not expect an error, got: %v", err)
-	}
-	if err := view.Delete(ctx); err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestIntegration_TableMetadata(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-	// Check table metadata.
-	md, err := table.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	// TODO(jba): check md more thorougly.
-	if got, want := md.FullID, fmt.Sprintf("%s:%s.%s", dataset.ProjectID, dataset.DatasetID, table.TableID); got != want {
-		t.Errorf("metadata.FullID: got %q, want %q", got, want)
-	}
-	if got, want := md.Type, RegularTable; got != want {
-		t.Errorf("metadata.Type: got %v, want %v", got, want)
-	}
-	if got, want := md.ExpirationTime, testTableExpiration; !got.Equal(want) {
-		t.Errorf("metadata.Type: got %v, want %v", got, want)
-	}
-
-	// Check that timePartitioning is nil by default
-	if md.TimePartitioning != nil {
-		t.Errorf("metadata.TimePartitioning: got %v, want %v", md.TimePartitioning, nil)
-	}
-
-	// Create tables that have time partitioning
-	partitionCases := []struct {
-		timePartitioning TimePartitioning
-		wantExpiration   time.Duration
-		wantField        string
-		wantPruneFilter  bool
-	}{
-		{TimePartitioning{}, time.Duration(0), "", false},
-		{TimePartitioning{Expiration: time.Second}, time.Second, "", false},
-		{TimePartitioning{RequirePartitionFilter: true}, time.Duration(0), "", true},
-		{
-			TimePartitioning{
-				Expiration:             time.Second,
-				Field:                  "date",
-				RequirePartitionFilter: true,
-			}, time.Second, "date", true},
-	}
-
-	schema2 := Schema{
-		{Name: "name", Type: StringFieldType},
-		{Name: "date", Type: DateFieldType},
-	}
-
-	clustering := &Clustering{
-		Fields: []string{"name"},
-	}
-
-	// Currently, clustering depends on partitioning.  Interleave testing of the two features.
-	for i, c := range partitionCases {
-		table := dataset.Table(fmt.Sprintf("t_metadata_partition_nocluster_%v", i))
-		clusterTable := dataset.Table(fmt.Sprintf("t_metadata_partition_cluster_%v", i))
-
-		// Create unclustered, partitioned variant and get metadata.
-		err = table.Create(context.Background(), &TableMetadata{
-			Schema:           schema2,
-			TimePartitioning: &c.timePartitioning,
-			ExpirationTime:   testTableExpiration,
-		})
-		if err != nil {
-			t.Fatal(err)
-		}
-		defer table.Delete(ctx)
-		md, err := table.Metadata(ctx)
-		if err != nil {
-			t.Fatal(err)
-		}
-
-		// Created clustered table and get metadata.
-		err = clusterTable.Create(context.Background(), &TableMetadata{
-			Schema:           schema2,
-			TimePartitioning: &c.timePartitioning,
-			ExpirationTime:   testTableExpiration,
-			Clustering:       clustering,
-		})
-		if err != nil {
-			t.Fatal(err)
-		}
-		clusterMD, err := clusterTable.Metadata(ctx)
-		if err != nil {
-			t.Fatal(err)
-		}
-
-		for _, v := range []*TableMetadata{md, clusterMD} {
-			got := v.TimePartitioning
-			want := &TimePartitioning{
-				Expiration:             c.wantExpiration,
-				Field:                  c.wantField,
-				RequirePartitionFilter: c.wantPruneFilter,
-			}
-			if !testutil.Equal(got, want) {
-				t.Errorf("metadata.TimePartitioning: got %v, want %v", got, want)
-			}
-			// check that RequirePartitionFilter can be inverted.
-			mdUpdate := TableMetadataToUpdate{
-				TimePartitioning: &TimePartitioning{
-					Expiration:             v.TimePartitioning.Expiration,
-					RequirePartitionFilter: !want.RequirePartitionFilter,
-				},
-			}
-
-			newmd, err := table.Update(ctx, mdUpdate, "")
-			if err != nil {
-				t.Errorf("failed to invert RequirePartitionFilter on %s: %v", table.FullyQualifiedName(), err)
-			}
-			if newmd.TimePartitioning.RequirePartitionFilter == want.RequirePartitionFilter {
-				t.Errorf("inverting RequirePartitionFilter on %s failed, want %t got %t", table.FullyQualifiedName(), !want.RequirePartitionFilter, newmd.TimePartitioning.RequirePartitionFilter)
-			}
-
-		}
-
-		if md.Clustering != nil {
-			t.Errorf("metadata.Clustering was not nil on unclustered table %s", table.TableID)
-		}
-		got := clusterMD.Clustering
-		want := clustering
-		if clusterMD.Clustering != clustering {
-			if !testutil.Equal(got, want) {
-				t.Errorf("metadata.Clustering: got %v, want %v", got, want)
-			}
-		}
-	}
-
-}
-
-func TestIntegration_RemoveTimePartitioning(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := dataset.Table(tableIDs.New())
-	want := 24 * time.Hour
-	err := table.Create(ctx, &TableMetadata{
-		ExpirationTime: testTableExpiration,
-		TimePartitioning: &TimePartitioning{
-			Expiration: want,
-		},
-	})
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer table.Delete(ctx)
-
-	md, err := table.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got := md.TimePartitioning.Expiration; got != want {
-		t.Fatalf("TimeParitioning expiration want = %v, got = %v", want, got)
-	}
-
-	// Remove time partitioning expiration
-	md, err = table.Update(context.Background(), TableMetadataToUpdate{
-		TimePartitioning: &TimePartitioning{Expiration: 0},
-	}, md.ETag)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	want = time.Duration(0)
-	if got := md.TimePartitioning.Expiration; got != want {
-		t.Fatalf("TimeParitioning expiration want = %v, got = %v", want, got)
-	}
-}
-
-func TestIntegration_DatasetCreate(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	ds := client.Dataset(datasetIDs.New())
-	wmd := &DatasetMetadata{Name: "name", Location: "EU"}
-	err := ds.Create(ctx, wmd)
-	if err != nil {
-		t.Fatal(err)
-	}
-	gmd, err := ds.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got, want := gmd.Name, wmd.Name; got != want {
-		t.Errorf("name: got %q, want %q", got, want)
-	}
-	if got, want := gmd.Location, wmd.Location; got != want {
-		t.Errorf("location: got %q, want %q", got, want)
-	}
-	if err := ds.Delete(ctx); err != nil {
-		t.Fatalf("deleting dataset %v: %v", ds, err)
-	}
-}
-
-func TestIntegration_DatasetMetadata(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	md, err := dataset.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got, want := md.FullID, fmt.Sprintf("%s:%s", dataset.ProjectID, dataset.DatasetID); got != want {
-		t.Errorf("FullID: got %q, want %q", got, want)
-	}
-	jan2016 := time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)
-	if md.CreationTime.Before(jan2016) {
-		t.Errorf("CreationTime: got %s, want > 2016-1-1", md.CreationTime)
-	}
-	if md.LastModifiedTime.Before(jan2016) {
-		t.Errorf("LastModifiedTime: got %s, want > 2016-1-1", md.LastModifiedTime)
-	}
-
-	// Verify that we get a NotFound for a nonexistent dataset.
-	_, err = client.Dataset("does_not_exist").Metadata(ctx)
-	if err == nil || !hasStatusCode(err, http.StatusNotFound) {
-		t.Errorf("got %v, want NotFound error", err)
-	}
-}
-
-func TestIntegration_DatasetDelete(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	ds := client.Dataset(datasetIDs.New())
-	if err := ds.Create(ctx, nil); err != nil {
-		t.Fatalf("creating dataset %s: %v", ds.DatasetID, err)
-	}
-	if err := ds.Delete(ctx); err != nil {
-		t.Fatalf("deleting dataset %s: %v", ds.DatasetID, err)
-	}
-}
-
-func TestIntegration_DatasetDeleteWithContents(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	ds := client.Dataset(datasetIDs.New())
-	if err := ds.Create(ctx, nil); err != nil {
-		t.Fatalf("creating dataset %s: %v", ds.DatasetID, err)
-	}
-	table := ds.Table(tableIDs.New())
-	if err := table.Create(ctx, nil); err != nil {
-		t.Fatalf("creating table %s in dataset %s: %v", table.TableID, table.DatasetID, err)
-	}
-	// We expect failure here
-	if err := ds.Delete(ctx); err == nil {
-		t.Fatalf("non-recursive delete of dataset %s succeeded unexpectedly.", ds.DatasetID)
-	}
-	if err := ds.DeleteWithContents(ctx); err != nil {
-		t.Fatalf("deleting recursively dataset %s: %v", ds.DatasetID, err)
-	}
-}
-
-func TestIntegration_DatasetUpdateETags(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-
-	check := func(md *DatasetMetadata, wantDesc, wantName string) {
-		if md.Description != wantDesc {
-			t.Errorf("description: got %q, want %q", md.Description, wantDesc)
-		}
-		if md.Name != wantName {
-			t.Errorf("name: got %q, want %q", md.Name, wantName)
-		}
-	}
-
-	ctx := context.Background()
-	md, err := dataset.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if md.ETag == "" {
-		t.Fatal("empty ETag")
-	}
-	// Write without ETag succeeds.
-	desc := md.Description + "d2"
-	name := md.Name + "n2"
-	md2, err := dataset.Update(ctx, DatasetMetadataToUpdate{Description: desc, Name: name}, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	check(md2, desc, name)
-
-	// Write with original ETag fails because of intervening write.
-	_, err = dataset.Update(ctx, DatasetMetadataToUpdate{Description: "d", Name: "n"}, md.ETag)
-	if err == nil {
-		t.Fatal("got nil, want error")
-	}
-
-	// Write with most recent ETag succeeds.
-	md3, err := dataset.Update(ctx, DatasetMetadataToUpdate{Description: "", Name: ""}, md2.ETag)
-	if err != nil {
-		t.Fatal(err)
-	}
-	check(md3, "", "")
-}
-
-func TestIntegration_DatasetUpdateDefaultExpiration(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	_, err := dataset.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	// Set the default expiration time.
-	md, err := dataset.Update(ctx, DatasetMetadataToUpdate{DefaultTableExpiration: time.Hour}, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if md.DefaultTableExpiration != time.Hour {
-		t.Fatalf("got %s, want 1h", md.DefaultTableExpiration)
-	}
-	// Omitting DefaultTableExpiration doesn't change it.
-	md, err = dataset.Update(ctx, DatasetMetadataToUpdate{Name: "xyz"}, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if md.DefaultTableExpiration != time.Hour {
-		t.Fatalf("got %s, want 1h", md.DefaultTableExpiration)
-	}
-	// Setting it to 0 deletes it (which looks like a 0 duration).
-	md, err = dataset.Update(ctx, DatasetMetadataToUpdate{DefaultTableExpiration: time.Duration(0)}, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if md.DefaultTableExpiration != 0 {
-		t.Fatalf("got %s, want 0", md.DefaultTableExpiration)
-	}
-}
-
-func TestIntegration_DatasetUpdateAccess(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	md, err := dataset.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	origAccess := append([]*AccessEntry(nil), md.Access...)
-	newEntry := &AccessEntry{
-		Role:       ReaderRole,
-		Entity:     "Joe@example.com",
-		EntityType: UserEmailEntity,
-	}
-	newAccess := append(md.Access, newEntry)
-	dm := DatasetMetadataToUpdate{Access: newAccess}
-	md, err = dataset.Update(ctx, dm, md.ETag)
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer func() {
-		_, err := dataset.Update(ctx, DatasetMetadataToUpdate{Access: origAccess}, md.ETag)
-		if err != nil {
-			t.Log("could not restore dataset access list")
-		}
-	}()
-	if diff := testutil.Diff(md.Access, newAccess); diff != "" {
-		t.Fatalf("got=-, want=+:\n%s", diff)
-	}
-}
-
-func TestIntegration_DatasetUpdateLabels(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	_, err := dataset.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	var dm DatasetMetadataToUpdate
-	dm.SetLabel("label", "value")
-	md, err := dataset.Update(ctx, dm, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got, want := md.Labels["label"], "value"; got != want {
-		t.Errorf("got %q, want %q", got, want)
-	}
-	dm = DatasetMetadataToUpdate{}
-	dm.DeleteLabel("label")
-	md, err = dataset.Update(ctx, dm, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if _, ok := md.Labels["label"]; ok {
-		t.Error("label still present after deletion")
-	}
-}
-
-func TestIntegration_TableUpdateLabels(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	var tm TableMetadataToUpdate
-	tm.SetLabel("label", "value")
-	md, err := table.Update(ctx, tm, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got, want := md.Labels["label"], "value"; got != want {
-		t.Errorf("got %q, want %q", got, want)
-	}
-	tm = TableMetadataToUpdate{}
-	tm.DeleteLabel("label")
-	md, err = table.Update(ctx, tm, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if _, ok := md.Labels["label"]; ok {
-		t.Error("label still present after deletion")
-	}
-}
-
-func TestIntegration_Tables(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-	wantName := table.FullyQualifiedName()
-
-	// This test is flaky due to eventual consistency.
-	ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
-	defer cancel()
-	err := internal.Retry(ctx, gax.Backoff{}, func() (stop bool, err error) {
-		// Iterate over tables in the dataset.
-		it := dataset.Tables(ctx)
-		var tableNames []string
-		for {
-			tbl, err := it.Next()
-			if err == iterator.Done {
-				break
-			}
-			if err != nil {
-				return false, err
-			}
-			tableNames = append(tableNames, tbl.FullyQualifiedName())
-		}
-		// Other tests may be running with this dataset, so there might be more
-		// than just our table in the list. So don't try for an exact match; just
-		// make sure that our table is there somewhere.
-		for _, tn := range tableNames {
-			if tn == wantName {
-				return true, nil
-			}
-		}
-		return false, fmt.Errorf("got %v\nwant %s in the list", tableNames, wantName)
-	})
-	if err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestIntegration_InsertAndRead(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	// Populate the table.
-	ins := table.Inserter()
-	var (
-		wantRows  [][]Value
-		saverRows []*ValuesSaver
-	)
-	for i, name := range []string{"a", "b", "c"} {
-		row := []Value{name, []Value{int64(i)}, []Value{true}}
-		wantRows = append(wantRows, row)
-		saverRows = append(saverRows, &ValuesSaver{
-			Schema:   schema,
-			InsertID: name,
-			Row:      row,
-		})
-	}
-	if err := ins.Put(ctx, saverRows); err != nil {
-		t.Fatal(putError(err))
-	}
-
-	// Wait until the data has been uploaded. This can take a few seconds, according
-	// to https://cloud.google.com/bigquery/streaming-data-into-bigquery.
-	if err := waitForRow(ctx, table); err != nil {
-		t.Fatal(err)
-	}
-	// Read the table.
-	checkRead(t, "upload", table.Read(ctx), wantRows)
-
-	// Query the table.
-	q := client.Query(fmt.Sprintf("select name, nums, rec from %s", table.TableID))
-	q.DefaultProjectID = dataset.ProjectID
-	q.DefaultDatasetID = dataset.DatasetID
-
-	rit, err := q.Read(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	checkRead(t, "query", rit, wantRows)
-
-	// Query the long way.
-	job1, err := q.Run(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if job1.LastStatus() == nil {
-		t.Error("no LastStatus")
-	}
-	job2, err := client.JobFromID(ctx, job1.ID())
-	if err != nil {
-		t.Fatal(err)
-	}
-	if job2.LastStatus() == nil {
-		t.Error("no LastStatus")
-	}
-	rit, err = job2.Read(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	checkRead(t, "job.Read", rit, wantRows)
-
-	// Get statistics.
-	jobStatus, err := job2.Status(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if jobStatus.Statistics == nil {
-		t.Fatal("jobStatus missing statistics")
-	}
-	if _, ok := jobStatus.Statistics.Details.(*QueryStatistics); !ok {
-		t.Errorf("expected QueryStatistics, got %T", jobStatus.Statistics.Details)
-	}
-
-	// Test reading directly into a []Value.
-	valueLists, schema, _, err := readAll(table.Read(ctx))
-	if err != nil {
-		t.Fatal(err)
-	}
-	it := table.Read(ctx)
-	for i, vl := range valueLists {
-		var got []Value
-		if err := it.Next(&got); err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(it.Schema, schema) {
-			t.Fatalf("got schema %v, want %v", it.Schema, schema)
-		}
-		want := []Value(vl)
-		if !testutil.Equal(got, want) {
-			t.Errorf("%d: got %v, want %v", i, got, want)
-		}
-	}
-
-	// Test reading into a map.
-	it = table.Read(ctx)
-	for _, vl := range valueLists {
-		var vm map[string]Value
-		if err := it.Next(&vm); err != nil {
-			t.Fatal(err)
-		}
-		if got, want := len(vm), len(vl); got != want {
-			t.Fatalf("valueMap len: got %d, want %d", got, want)
-		}
-		// With maps, structs become nested maps.
-		vl[2] = map[string]Value{"bool": vl[2].([]Value)[0]}
-		for i, v := range vl {
-			if got, want := vm[schema[i].Name], v; !testutil.Equal(got, want) {
-				t.Errorf("%d, name=%s: got %#v, want %#v",
-					i, schema[i].Name, got, want)
-			}
-		}
-	}
-
-}
-
-type SubSubTestStruct struct {
-	Integer int64
-}
-
-type SubTestStruct struct {
-	String      string
-	Record      SubSubTestStruct
-	RecordArray []SubSubTestStruct
-}
-
-type TestStruct struct {
-	Name      string
-	Bytes     []byte
-	Integer   int64
-	Float     float64
-	Boolean   bool
-	Timestamp time.Time
-	Date      civil.Date
-	Time      civil.Time
-	DateTime  civil.DateTime
-	Numeric   *big.Rat
-
-	StringArray    []string
-	IntegerArray   []int64
-	FloatArray     []float64
-	BooleanArray   []bool
-	TimestampArray []time.Time
-	DateArray      []civil.Date
-	TimeArray      []civil.Time
-	DateTimeArray  []civil.DateTime
-	NumericArray   []*big.Rat
-
-	Record      SubTestStruct
-	RecordArray []SubTestStruct
-}
-
-// Round times to the microsecond for comparison purposes.
-var roundToMicros = cmp.Transformer("RoundToMicros",
-	func(t time.Time) time.Time { return t.Round(time.Microsecond) })
-
-func TestIntegration_InsertAndReadStructs(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	schema, err := InferSchema(TestStruct{})
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	d := civil.Date{Year: 2016, Month: 3, Day: 20}
-	tm := civil.Time{Hour: 15, Minute: 4, Second: 5, Nanosecond: 6000}
-	ts := time.Date(2016, 3, 20, 15, 4, 5, 6000, time.UTC)
-	dtm := civil.DateTime{Date: d, Time: tm}
-	d2 := civil.Date{Year: 1994, Month: 5, Day: 15}
-	tm2 := civil.Time{Hour: 1, Minute: 2, Second: 4, Nanosecond: 0}
-	ts2 := time.Date(1994, 5, 15, 1, 2, 4, 0, time.UTC)
-	dtm2 := civil.DateTime{Date: d2, Time: tm2}
-
-	// Populate the table.
-	ins := table.Inserter()
-	want := []*TestStruct{
-		{
-			"a",
-			[]byte("byte"),
-			42,
-			3.14,
-			true,
-			ts,
-			d,
-			tm,
-			dtm,
-			big.NewRat(57, 100),
-			[]string{"a", "b"},
-			[]int64{1, 2},
-			[]float64{1, 1.41},
-			[]bool{true, false},
-			[]time.Time{ts, ts2},
-			[]civil.Date{d, d2},
-			[]civil.Time{tm, tm2},
-			[]civil.DateTime{dtm, dtm2},
-			[]*big.Rat{big.NewRat(1, 2), big.NewRat(3, 5)},
-			SubTestStruct{
-				"string",
-				SubSubTestStruct{24},
-				[]SubSubTestStruct{{1}, {2}},
-			},
-			[]SubTestStruct{
-				{String: "empty"},
-				{
-					"full",
-					SubSubTestStruct{1},
-					[]SubSubTestStruct{{1}, {2}},
-				},
-			},
-		},
-		{
-			Name:      "b",
-			Bytes:     []byte("byte2"),
-			Integer:   24,
-			Float:     4.13,
-			Boolean:   false,
-			Timestamp: ts,
-			Date:      d,
-			Time:      tm,
-			DateTime:  dtm,
-			Numeric:   big.NewRat(4499, 10000),
-		},
-	}
-	var savers []*StructSaver
-	for _, s := range want {
-		savers = append(savers, &StructSaver{Schema: schema, Struct: s})
-	}
-	if err := ins.Put(ctx, savers); err != nil {
-		t.Fatal(putError(err))
-	}
-
-	// Wait until the data has been uploaded. This can take a few seconds, according
-	// to https://cloud.google.com/bigquery/streaming-data-into-bigquery.
-	if err := waitForRow(ctx, table); err != nil {
-		t.Fatal(err)
-	}
-
-	// Test iteration with structs.
-	it := table.Read(ctx)
-	var got []*TestStruct
-	for {
-		var g TestStruct
-		err := it.Next(&g)
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			t.Fatal(err)
-		}
-		got = append(got, &g)
-	}
-	sort.Sort(byName(got))
-
-	// BigQuery does not elide nils. It reports an error for nil fields.
-	for i, g := range got {
-		if i >= len(want) {
-			t.Errorf("%d: got %v, past end of want", i, pretty.Value(g))
-		} else if diff := testutil.Diff(g, want[i], roundToMicros); diff != "" {
-			t.Errorf("%d: got=-, want=+:\n%s", i, diff)
-		}
-	}
-}
-
-type byName []*TestStruct
-
-func (b byName) Len() int           { return len(b) }
-func (b byName) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
-func (b byName) Less(i, j int) bool { return b[i].Name < b[j].Name }
-
-func TestIntegration_InsertAndReadNullable(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctm := civil.Time{Hour: 15, Minute: 4, Second: 5, Nanosecond: 6000}
-	cdt := civil.DateTime{Date: testDate, Time: ctm}
-	rat := big.NewRat(33, 100)
-	testInsertAndReadNullable(t, testStructNullable{}, make([]Value, len(testStructNullableSchema)))
-	testInsertAndReadNullable(t, testStructNullable{
-		String:    NullString{"x", true},
-		Bytes:     []byte{1, 2, 3},
-		Integer:   NullInt64{1, true},
-		Float:     NullFloat64{2.3, true},
-		Boolean:   NullBool{true, true},
-		Timestamp: NullTimestamp{testTimestamp, true},
-		Date:      NullDate{testDate, true},
-		Time:      NullTime{ctm, true},
-		DateTime:  NullDateTime{cdt, true},
-		Numeric:   rat,
-		Record:    &subNullable{X: NullInt64{4, true}},
-	},
-		[]Value{"x", []byte{1, 2, 3}, int64(1), 2.3, true, testTimestamp, testDate, ctm, cdt, rat, []Value{int64(4)}})
-}
-
-func testInsertAndReadNullable(t *testing.T, ts testStructNullable, wantRow []Value) {
-	ctx := context.Background()
-	table := newTable(t, testStructNullableSchema)
-	defer table.Delete(ctx)
-
-	// Populate the table.
-	ins := table.Inserter()
-	if err := ins.Put(ctx, []*StructSaver{{Schema: testStructNullableSchema, Struct: ts}}); err != nil {
-		t.Fatal(putError(err))
-	}
-	// Wait until the data has been uploaded. This can take a few seconds, according
-	// to https://cloud.google.com/bigquery/streaming-data-into-bigquery.
-	if err := waitForRow(ctx, table); err != nil {
-		t.Fatal(err)
-	}
-
-	// Read into a []Value.
-	iter := table.Read(ctx)
-	gotRows, _, _, err := readAll(iter)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if len(gotRows) != 1 {
-		t.Fatalf("got %d rows, want 1", len(gotRows))
-	}
-	if diff := testutil.Diff(gotRows[0], wantRow, roundToMicros); diff != "" {
-		t.Error(diff)
-	}
-
-	// Read into a struct.
-	want := ts
-	var sn testStructNullable
-	it := table.Read(ctx)
-	if err := it.Next(&sn); err != nil {
-		t.Fatal(err)
-	}
-	if diff := testutil.Diff(sn, want, roundToMicros); diff != "" {
-		t.Error(diff)
-	}
-}
-
-func TestIntegration_TableUpdate(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	// Test Update of non-schema fields.
-	tm, err := table.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	wantDescription := tm.Description + "more"
-	wantName := tm.Name + "more"
-	wantExpiration := tm.ExpirationTime.Add(time.Hour * 24)
-	got, err := table.Update(ctx, TableMetadataToUpdate{
-		Description:    wantDescription,
-		Name:           wantName,
-		ExpirationTime: wantExpiration,
-	}, tm.ETag)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got.Description != wantDescription {
-		t.Errorf("Description: got %q, want %q", got.Description, wantDescription)
-	}
-	if got.Name != wantName {
-		t.Errorf("Name: got %q, want %q", got.Name, wantName)
-	}
-	if got.ExpirationTime != wantExpiration {
-		t.Errorf("ExpirationTime: got %q, want %q", got.ExpirationTime, wantExpiration)
-	}
-	if !testutil.Equal(got.Schema, schema) {
-		t.Errorf("Schema: got %v, want %v", pretty.Value(got.Schema), pretty.Value(schema))
-	}
-
-	// Blind write succeeds.
-	_, err = table.Update(ctx, TableMetadataToUpdate{Name: "x"}, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	// Write with old etag fails.
-	_, err = table.Update(ctx, TableMetadataToUpdate{Name: "y"}, got.ETag)
-	if err == nil {
-		t.Fatal("Update with old ETag succeeded, wanted failure")
-	}
-
-	// Test schema update.
-	// Columns can be added. schema2 is the same as schema, except for the
-	// added column in the middle.
-	nested := Schema{
-		{Name: "nested", Type: BooleanFieldType},
-		{Name: "other", Type: StringFieldType},
-	}
-	schema2 := Schema{
-		schema[0],
-		{Name: "rec2", Type: RecordFieldType, Schema: nested},
-		schema[1],
-		schema[2],
-	}
-
-	got, err = table.Update(ctx, TableMetadataToUpdate{Schema: schema2}, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	// Wherever you add the column, it appears at the end.
-	schema3 := Schema{schema2[0], schema2[2], schema2[3], schema2[1]}
-	if !testutil.Equal(got.Schema, schema3) {
-		t.Errorf("add field:\ngot  %v\nwant %v",
-			pretty.Value(got.Schema), pretty.Value(schema3))
-	}
-
-	// Updating with the empty schema succeeds, but is a no-op.
-	got, err = table.Update(ctx, TableMetadataToUpdate{Schema: Schema{}}, "")
-	if err != nil {
-		t.Fatal(err)
-	}
-	if !testutil.Equal(got.Schema, schema3) {
-		t.Errorf("empty schema:\ngot  %v\nwant %v",
-			pretty.Value(got.Schema), pretty.Value(schema3))
-	}
-
-	// Error cases when updating schema.
-	for _, test := range []struct {
-		desc   string
-		fields Schema
-	}{
-		{"change from optional to required", Schema{
-			{Name: "name", Type: StringFieldType, Required: true},
-			schema3[1],
-			schema3[2],
-			schema3[3],
-		}},
-		{"add a required field", Schema{
-			schema3[0], schema3[1], schema3[2], schema3[3],
-			{Name: "req", Type: StringFieldType, Required: true},
-		}},
-		{"remove a field", Schema{schema3[0], schema3[1], schema3[2]}},
-		{"remove a nested field", Schema{
-			schema3[0], schema3[1], schema3[2],
-			{Name: "rec2", Type: RecordFieldType, Schema: Schema{nested[0]}}}},
-		{"remove all nested fields", Schema{
-			schema3[0], schema3[1], schema3[2],
-			{Name: "rec2", Type: RecordFieldType, Schema: Schema{}}}},
-	} {
-		_, err = table.Update(ctx, TableMetadataToUpdate{Schema: Schema(test.fields)}, "")
-		if err == nil {
-			t.Errorf("%s: want error, got nil", test.desc)
-		} else if !hasStatusCode(err, 400) {
-			t.Errorf("%s: want 400, got %v", test.desc, err)
-		}
-	}
-}
-
-func TestIntegration_Load(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	// CSV data can't be loaded into a repeated field, so we use a different schema.
-	table := newTable(t, Schema{
-		{Name: "name", Type: StringFieldType},
-		{Name: "nums", Type: IntegerFieldType},
-	})
-	defer table.Delete(ctx)
-
-	// Load the table from a reader.
-	r := strings.NewReader("a,0\nb,1\nc,2\n")
-	wantRows := [][]Value{
-		{"a", int64(0)},
-		{"b", int64(1)},
-		{"c", int64(2)},
-	}
-	rs := NewReaderSource(r)
-	loader := table.LoaderFrom(rs)
-	loader.WriteDisposition = WriteTruncate
-	loader.Labels = map[string]string{"test": "go"}
-	job, err := loader.Run(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if job.LastStatus() == nil {
-		t.Error("no LastStatus")
-	}
-	conf, err := job.Config()
-	if err != nil {
-		t.Fatal(err)
-	}
-	config, ok := conf.(*LoadConfig)
-	if !ok {
-		t.Fatalf("got %T, want LoadConfig", conf)
-	}
-	diff := testutil.Diff(config, &loader.LoadConfig,
-		cmp.AllowUnexported(Table{}),
-		cmpopts.IgnoreUnexported(Client{}, ReaderSource{}),
-		// returned schema is at top level, not in the config
-		cmpopts.IgnoreFields(FileConfig{}, "Schema"))
-	if diff != "" {
-		t.Errorf("got=-, want=+:\n%s", diff)
-	}
-	if err := wait(ctx, job); err != nil {
-		t.Fatal(err)
-	}
-	checkReadAndTotalRows(t, "reader load", table.Read(ctx), wantRows)
-
-}
-
-func TestIntegration_DML(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	sql := fmt.Sprintf(`INSERT %s.%s (name, nums, rec)
-						VALUES ('a', [0], STRUCT<BOOL>(TRUE)),
-							   ('b', [1], STRUCT<BOOL>(FALSE)),
-							   ('c', [2], STRUCT<BOOL>(TRUE))`,
-		table.DatasetID, table.TableID)
-	if err := runDML(ctx, sql); err != nil {
-		t.Fatal(err)
-	}
-	wantRows := [][]Value{
-		{"a", []Value{int64(0)}, []Value{true}},
-		{"b", []Value{int64(1)}, []Value{false}},
-		{"c", []Value{int64(2)}, []Value{true}},
-	}
-	checkRead(t, "DML", table.Read(ctx), wantRows)
-}
-
-func runDML(ctx context.Context, sql string) error {
-	// Retry insert; sometimes it fails with INTERNAL.
-	return internal.Retry(ctx, gax.Backoff{}, func() (stop bool, err error) {
-		ri, err := client.Query(sql).Read(ctx)
-		if err != nil {
-			if e, ok := err.(*googleapi.Error); ok && e.Code < 500 {
-				return true, err // fail on 4xx
-			}
-			return false, err
-		}
-		// It is OK to try to iterate over DML results. The first call to Next
-		// will return iterator.Done.
-		err = ri.Next(nil)
-		if err == nil {
-			return true, errors.New("want iterator.Done on the first call, got nil")
-		}
-		if err == iterator.Done {
-			return true, nil
-		}
-		if e, ok := err.(*googleapi.Error); ok && e.Code < 500 {
-			return true, err // fail on 4xx
-		}
-		return false, err
-	})
-}
-
-func TestIntegration_TimeTypes(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	dtSchema := Schema{
-		{Name: "d", Type: DateFieldType},
-		{Name: "t", Type: TimeFieldType},
-		{Name: "dt", Type: DateTimeFieldType},
-		{Name: "ts", Type: TimestampFieldType},
-	}
-	table := newTable(t, dtSchema)
-	defer table.Delete(ctx)
-
-	d := civil.Date{Year: 2016, Month: 3, Day: 20}
-	tm := civil.Time{Hour: 12, Minute: 30, Second: 0, Nanosecond: 6000}
-	dtm := civil.DateTime{Date: d, Time: tm}
-	ts := time.Date(2016, 3, 20, 15, 04, 05, 0, time.UTC)
-	wantRows := [][]Value{
-		{d, tm, dtm, ts},
-	}
-	ins := table.Inserter()
-	if err := ins.Put(ctx, []*ValuesSaver{
-		{Schema: dtSchema, Row: wantRows[0]},
-	}); err != nil {
-		t.Fatal(putError(err))
-	}
-	if err := waitForRow(ctx, table); err != nil {
-		t.Fatal(err)
-	}
-
-	// SQL wants DATETIMEs with a space between date and time, but the service
-	// returns them in RFC3339 form, with a "T" between.
-	query := fmt.Sprintf("INSERT %s.%s (d, t, dt, ts) "+
-		"VALUES ('%s', '%s', '%s', '%s')",
-		table.DatasetID, table.TableID,
-		d, CivilTimeString(tm), CivilDateTimeString(dtm), ts.Format("2006-01-02 15:04:05"))
-	if err := runDML(ctx, query); err != nil {
-		t.Fatal(err)
-	}
-	wantRows = append(wantRows, wantRows[0])
-	checkRead(t, "TimeTypes", table.Read(ctx), wantRows)
-}
-
-func TestIntegration_StandardQuery(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-
-	d := civil.Date{Year: 2016, Month: 3, Day: 20}
-	tm := civil.Time{Hour: 15, Minute: 04, Second: 05, Nanosecond: 0}
-	ts := time.Date(2016, 3, 20, 15, 04, 05, 0, time.UTC)
-	dtm := ts.Format("2006-01-02 15:04:05")
-
-	// Constructs Value slices made up of int64s.
-	ints := func(args ...int) []Value {
-		vals := make([]Value, len(args))
-		for i, arg := range args {
-			vals[i] = int64(arg)
-		}
-		return vals
-	}
-
-	testCases := []struct {
-		query   string
-		wantRow []Value
-	}{
-		{"SELECT 1", ints(1)},
-		{"SELECT 1.3", []Value{1.3}},
-		{"SELECT CAST(1.3  AS NUMERIC)", []Value{big.NewRat(13, 10)}},
-		{"SELECT NUMERIC '0.25'", []Value{big.NewRat(1, 4)}},
-		{"SELECT TRUE", []Value{true}},
-		{"SELECT 'ABC'", []Value{"ABC"}},
-		{"SELECT CAST('foo' AS BYTES)", []Value{[]byte("foo")}},
-		{fmt.Sprintf("SELECT TIMESTAMP '%s'", dtm), []Value{ts}},
-		{fmt.Sprintf("SELECT [TIMESTAMP '%s', TIMESTAMP '%s']", dtm, dtm), []Value{[]Value{ts, ts}}},
-		{fmt.Sprintf("SELECT ('hello', TIMESTAMP '%s')", dtm), []Value{[]Value{"hello", ts}}},
-		{fmt.Sprintf("SELECT DATETIME(TIMESTAMP '%s')", dtm), []Value{civil.DateTime{Date: d, Time: tm}}},
-		{fmt.Sprintf("SELECT DATE(TIMESTAMP '%s')", dtm), []Value{d}},
-		{fmt.Sprintf("SELECT TIME(TIMESTAMP '%s')", dtm), []Value{tm}},
-		{"SELECT (1, 2)", []Value{ints(1, 2)}},
-		{"SELECT [1, 2, 3]", []Value{ints(1, 2, 3)}},
-		{"SELECT ([1, 2], 3, [4, 5])", []Value{[]Value{ints(1, 2), int64(3), ints(4, 5)}}},
-		{"SELECT [(1, 2, 3), (4, 5, 6)]", []Value{[]Value{ints(1, 2, 3), ints(4, 5, 6)}}},
-		{"SELECT [([1, 2, 3], 4), ([5, 6], 7)]", []Value{[]Value{[]Value{ints(1, 2, 3), int64(4)}, []Value{ints(5, 6), int64(7)}}}},
-		{"SELECT ARRAY(SELECT STRUCT([1, 2]))", []Value{[]Value{[]Value{ints(1, 2)}}}},
-	}
-	for _, c := range testCases {
-		q := client.Query(c.query)
-		it, err := q.Read(ctx)
-		if err != nil {
-			t.Fatal(err)
-		}
-		checkRead(t, "StandardQuery", it, [][]Value{c.wantRow})
-	}
-}
-
-func TestIntegration_LegacyQuery(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-
-	ts := time.Date(2016, 3, 20, 15, 04, 05, 0, time.UTC)
-	dtm := ts.Format("2006-01-02 15:04:05")
-
-	testCases := []struct {
-		query   string
-		wantRow []Value
-	}{
-		{"SELECT 1", []Value{int64(1)}},
-		{"SELECT 1.3", []Value{1.3}},
-		{"SELECT TRUE", []Value{true}},
-		{"SELECT 'ABC'", []Value{"ABC"}},
-		{"SELECT CAST('foo' AS BYTES)", []Value{[]byte("foo")}},
-		{fmt.Sprintf("SELECT TIMESTAMP('%s')", dtm), []Value{ts}},
-		{fmt.Sprintf("SELECT DATE(TIMESTAMP('%s'))", dtm), []Value{"2016-03-20"}},
-		{fmt.Sprintf("SELECT TIME(TIMESTAMP('%s'))", dtm), []Value{"15:04:05"}},
-	}
-	for _, c := range testCases {
-		q := client.Query(c.query)
-		q.UseLegacySQL = true
-		it, err := q.Read(ctx)
-		if err != nil {
-			t.Fatal(err)
-		}
-		checkRead(t, "LegacyQuery", it, [][]Value{c.wantRow})
-	}
-}
-
-func TestIntegration_QueryParameters(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-
-	d := civil.Date{Year: 2016, Month: 3, Day: 20}
-	tm := civil.Time{Hour: 15, Minute: 04, Second: 05, Nanosecond: 3008}
-	rtm := tm
-	rtm.Nanosecond = 3000 // round to microseconds
-	dtm := civil.DateTime{Date: d, Time: tm}
-	ts := time.Date(2016, 3, 20, 15, 04, 05, 0, time.UTC)
-	rat := big.NewRat(13, 10)
-
-	type ss struct {
-		String string
-	}
-
-	type s struct {
-		Timestamp      time.Time
-		StringArray    []string
-		SubStruct      ss
-		SubStructArray []ss
-	}
-
-	testCases := []struct {
-		query      string
-		parameters []QueryParameter
-		wantRow    []Value
-		wantConfig interface{}
-	}{
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", 1}},
-			[]Value{int64(1)},
-			int64(1),
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", 1.3}},
-			[]Value{1.3},
-			1.3,
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", rat}},
-			[]Value{rat},
-			rat,
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", true}},
-			[]Value{true},
-			true,
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", "ABC"}},
-			[]Value{"ABC"},
-			"ABC",
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", []byte("foo")}},
-			[]Value{[]byte("foo")},
-			[]byte("foo"),
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", ts}},
-			[]Value{ts},
-			ts,
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", []time.Time{ts, ts}}},
-			[]Value{[]Value{ts, ts}},
-			[]interface{}{ts, ts},
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", dtm}},
-			[]Value{civil.DateTime{Date: d, Time: rtm}},
-			civil.DateTime{Date: d, Time: rtm},
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", d}},
-			[]Value{d},
-			d,
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", tm}},
-			[]Value{rtm},
-			rtm,
-		},
-		{
-			"SELECT @val",
-			[]QueryParameter{{"val", s{ts, []string{"a", "b"}, ss{"c"}, []ss{{"d"}, {"e"}}}}},
-			[]Value{[]Value{ts, []Value{"a", "b"}, []Value{"c"}, []Value{[]Value{"d"}, []Value{"e"}}}},
-			map[string]interface{}{
-				"Timestamp":   ts,
-				"StringArray": []interface{}{"a", "b"},
-				"SubStruct":   map[string]interface{}{"String": "c"},
-				"SubStructArray": []interface{}{
-					map[string]interface{}{"String": "d"},
-					map[string]interface{}{"String": "e"},
-				},
-			},
-		},
-		{
-			"SELECT @val.Timestamp, @val.SubStruct.String",
-			[]QueryParameter{{"val", s{Timestamp: ts, SubStruct: ss{"a"}}}},
-			[]Value{ts, "a"},
-			map[string]interface{}{
-				"Timestamp":      ts,
-				"SubStruct":      map[string]interface{}{"String": "a"},
-				"StringArray":    nil,
-				"SubStructArray": nil,
-			},
-		},
-	}
-	for _, c := range testCases {
-		q := client.Query(c.query)
-		q.Parameters = c.parameters
-		job, err := q.Run(ctx)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if job.LastStatus() == nil {
-			t.Error("no LastStatus")
-		}
-		it, err := job.Read(ctx)
-		if err != nil {
-			t.Fatal(err)
-		}
-		checkRead(t, "QueryParameters", it, [][]Value{c.wantRow})
-		config, err := job.Config()
-		if err != nil {
-			t.Fatal(err)
-		}
-		got := config.(*QueryConfig).Parameters[0].Value
-		if !testutil.Equal(got, c.wantConfig) {
-			t.Errorf("param %[1]v (%[1]T): config:\ngot %[2]v (%[2]T)\nwant %[3]v (%[3]T)",
-				c.parameters[0].Value, got, c.wantConfig)
-		}
-	}
-}
-
-func TestIntegration_QueryDryRun(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	q := client.Query("SELECT word from " + stdName + " LIMIT 10")
-	q.DryRun = true
-	job, err := q.Run(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	s := job.LastStatus()
-	if s.State != Done {
-		t.Errorf("state is %v, expected Done", s.State)
-	}
-	if s.Statistics == nil {
-		t.Fatal("no statistics")
-	}
-	if s.Statistics.Details.(*QueryStatistics).Schema == nil {
-		t.Fatal("no schema")
-	}
-}
-
-func TestIntegration_ExtractExternal(t *testing.T) {
-	// Create a table, extract it to GCS, then query it externally.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	schema := Schema{
-		{Name: "name", Type: StringFieldType},
-		{Name: "num", Type: IntegerFieldType},
-	}
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	// Insert table data.
-	sql := fmt.Sprintf(`INSERT %s.%s (name, num)
-		                VALUES ('a', 1), ('b', 2), ('c', 3)`,
-		table.DatasetID, table.TableID)
-	if err := runDML(ctx, sql); err != nil {
-		t.Fatal(err)
-	}
-	// Extract to a GCS object as CSV.
-	bucketName := testutil.ProjID()
-	objectName := fmt.Sprintf("bq-test-%s.csv", table.TableID)
-	uri := fmt.Sprintf("gs://%s/%s", bucketName, objectName)
-	defer storageClient.Bucket(bucketName).Object(objectName).Delete(ctx)
-	gr := NewGCSReference(uri)
-	gr.DestinationFormat = CSV
-	e := table.ExtractorTo(gr)
-	job, err := e.Run(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	conf, err := job.Config()
-	if err != nil {
-		t.Fatal(err)
-	}
-	config, ok := conf.(*ExtractConfig)
-	if !ok {
-		t.Fatalf("got %T, want ExtractConfig", conf)
-	}
-	diff := testutil.Diff(config, &e.ExtractConfig,
-		cmp.AllowUnexported(Table{}),
-		cmpopts.IgnoreUnexported(Client{}))
-	if diff != "" {
-		t.Errorf("got=-, want=+:\n%s", diff)
-	}
-	if err := wait(ctx, job); err != nil {
-		t.Fatal(err)
-	}
-
-	edc := &ExternalDataConfig{
-		SourceFormat: CSV,
-		SourceURIs:   []string{uri},
-		Schema:       schema,
-		Options: &CSVOptions{
-			SkipLeadingRows: 1,
-			// This is the default. Since we use edc as an expectation later on,
-			// let's just be explicit.
-			FieldDelimiter: ",",
-		},
-	}
-	// Query that CSV file directly.
-	q := client.Query("SELECT * FROM csv")
-	q.TableDefinitions = map[string]ExternalData{"csv": edc}
-	wantRows := [][]Value{
-		{"a", int64(1)},
-		{"b", int64(2)},
-		{"c", int64(3)},
-	}
-	iter, err := q.Read(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	checkReadAndTotalRows(t, "external query", iter, wantRows)
-
-	// Make a table pointing to the file, and query it.
-	// BigQuery does not allow a Table.Read on an external table.
-	table = dataset.Table(tableIDs.New())
-	err = table.Create(context.Background(), &TableMetadata{
-		Schema:             schema,
-		ExpirationTime:     testTableExpiration,
-		ExternalDataConfig: edc,
-	})
-	if err != nil {
-		t.Fatal(err)
-	}
-	q = client.Query(fmt.Sprintf("SELECT * FROM %s.%s", table.DatasetID, table.TableID))
-	iter, err = q.Read(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	checkReadAndTotalRows(t, "external table", iter, wantRows)
-
-	// While we're here, check that the table metadata is correct.
-	md, err := table.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	// One difference: since BigQuery returns the schema as part of the ordinary
-	// table metadata, it does not populate ExternalDataConfig.Schema.
-	md.ExternalDataConfig.Schema = md.Schema
-	if diff := testutil.Diff(md.ExternalDataConfig, edc); diff != "" {
-		t.Errorf("got=-, want=+\n%s", diff)
-	}
-}
-
-func TestIntegration_ReadNullIntoStruct(t *testing.T) {
-	// Reading a null into a struct field should return an error (not panic).
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	ins := table.Inserter()
-	row := &ValuesSaver{
-		Schema: schema,
-		Row:    []Value{nil, []Value{}, []Value{nil}},
-	}
-	if err := ins.Put(ctx, []*ValuesSaver{row}); err != nil {
-		t.Fatal(putError(err))
-	}
-	if err := waitForRow(ctx, table); err != nil {
-		t.Fatal(err)
-	}
-
-	q := client.Query(fmt.Sprintf("select name from %s", table.TableID))
-	q.DefaultProjectID = dataset.ProjectID
-	q.DefaultDatasetID = dataset.DatasetID
-	it, err := q.Read(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	type S struct{ Name string }
-	var s S
-	if err := it.Next(&s); err == nil {
-		t.Fatal("got nil, want error")
-	}
-}
-
-const (
-	stdName    = "`bigquery-public-data.samples.shakespeare`"
-	legacyName = "[bigquery-public-data:samples.shakespeare]"
-)
-
-// These tests exploit the fact that the two SQL versions have different syntaxes for
-// fully-qualified table names.
-var useLegacySQLTests = []struct {
-	t           string // name of table
-	std, legacy bool   // use standard/legacy SQL
-	err         bool   // do we expect an error?
-}{
-	{t: legacyName, std: false, legacy: true, err: false},
-	{t: legacyName, std: true, legacy: false, err: true},
-	{t: legacyName, std: false, legacy: false, err: true}, // standard SQL is default
-	{t: legacyName, std: true, legacy: true, err: true},
-	{t: stdName, std: false, legacy: true, err: true},
-	{t: stdName, std: true, legacy: false, err: false},
-	{t: stdName, std: false, legacy: false, err: false}, // standard SQL is default
-	{t: stdName, std: true, legacy: true, err: true},
-}
-
-func TestIntegration_QueryUseLegacySQL(t *testing.T) {
-	// Test the UseLegacySQL and UseStandardSQL options for queries.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	for _, test := range useLegacySQLTests {
-		q := client.Query(fmt.Sprintf("select word from %s limit 1", test.t))
-		q.UseStandardSQL = test.std
-		q.UseLegacySQL = test.legacy
-		_, err := q.Read(ctx)
-		gotErr := err != nil
-		if gotErr && !test.err {
-			t.Errorf("%+v:\nunexpected error: %v", test, err)
-		} else if !gotErr && test.err {
-			t.Errorf("%+v:\nsucceeded, but want error", test)
-		}
-	}
-}
-
-func TestIntegration_TableUseLegacySQL(t *testing.T) {
-	// Test UseLegacySQL and UseStandardSQL for Table.Create.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-	for i, test := range useLegacySQLTests {
-		view := dataset.Table(fmt.Sprintf("t_view_%d", i))
-		tm := &TableMetadata{
-			ViewQuery:      fmt.Sprintf("SELECT word from %s", test.t),
-			UseStandardSQL: test.std,
-			UseLegacySQL:   test.legacy,
-		}
-		err := view.Create(ctx, tm)
-		gotErr := err != nil
-		if gotErr && !test.err {
-			t.Errorf("%+v:\nunexpected error: %v", test, err)
-		} else if !gotErr && test.err {
-			t.Errorf("%+v:\nsucceeded, but want error", test)
-		}
-		_ = view.Delete(ctx)
-	}
-}
-
-func TestIntegration_ListJobs(t *testing.T) {
-	// It's difficult to test the list of jobs, because we can't easily
-	// control what's in it. Also, there are many jobs in the test project,
-	// and it takes considerable time to list them all.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-
-	// About all we can do is list a few jobs.
-	const max = 20
-	var jobs []*Job
-	it := client.Jobs(ctx)
-	for {
-		job, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			t.Fatal(err)
-		}
-		jobs = append(jobs, job)
-		if len(jobs) >= max {
-			break
-		}
-	}
-	// We expect that there is at least one job in the last few months.
-	if len(jobs) == 0 {
-		t.Fatal("did not get any jobs")
-	}
-}
-
-const tokyo = "asia-northeast1"
-
-func TestIntegration_Location(t *testing.T) {
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	client.Location = ""
-	testLocation(t, tokyo)
-	client.Location = tokyo
-	defer func() {
-		client.Location = ""
-	}()
-	testLocation(t, "")
-}
-
-func testLocation(t *testing.T, loc string) {
-	ctx := context.Background()
-	tokyoDataset := client.Dataset("tokyo")
-	err := tokyoDataset.Create(ctx, &DatasetMetadata{Location: loc})
-	if err != nil && !hasStatusCode(err, 409) { // 409 = already exists
-		t.Fatal(err)
-	}
-	md, err := tokyoDataset.Metadata(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if md.Location != tokyo {
-		t.Fatalf("dataset location: got %s, want %s", md.Location, tokyo)
-	}
-	table := tokyoDataset.Table(tableIDs.New())
-	err = table.Create(context.Background(), &TableMetadata{
-		Schema: Schema{
-			{Name: "name", Type: StringFieldType},
-			{Name: "nums", Type: IntegerFieldType},
-		},
-		ExpirationTime: testTableExpiration,
-	})
-	if err != nil {
-		t.Fatal(err)
-	}
-	defer table.Delete(ctx)
-	loader := table.LoaderFrom(NewReaderSource(strings.NewReader("a,0\nb,1\nc,2\n")))
-	loader.Location = loc
-	job, err := loader.Run(ctx)
-	if err != nil {
-		t.Fatal("loader.Run", err)
-	}
-	if job.Location() != tokyo {
-		t.Fatalf("job location: got %s, want %s", job.Location(), tokyo)
-	}
-	_, err = client.JobFromID(ctx, job.ID())
-	if client.Location == "" && err == nil {
-		t.Error("JobFromID with Tokyo job, no client location: want error, got nil")
-	}
-	if client.Location != "" && err != nil {
-		t.Errorf("JobFromID with Tokyo job, with client location: want nil, got %v", err)
-	}
-	_, err = client.JobFromIDLocation(ctx, job.ID(), "US")
-	if err == nil {
-		t.Error("JobFromIDLocation with US: want error, got nil")
-	}
-	job2, err := client.JobFromIDLocation(ctx, job.ID(), loc)
-	if loc == tokyo && err != nil {
-		t.Errorf("loc=tokyo: %v", err)
-	}
-	if loc == "" && err == nil {
-		t.Error("loc empty: got nil, want error")
-	}
-	if job2 != nil && (job2.ID() != job.ID() || job2.Location() != tokyo) {
-		t.Errorf("got id %s loc %s, want id%s loc %s", job2.ID(), job2.Location(), job.ID(), tokyo)
-	}
-	if err := wait(ctx, job); err != nil {
-		t.Fatal(err)
-	}
-	// Cancel should succeed even if the job is done.
-	if err := job.Cancel(ctx); err != nil {
-		t.Fatal(err)
-	}
-
-	q := client.Query(fmt.Sprintf("SELECT * FROM %s.%s", table.DatasetID, table.TableID))
-	q.Location = loc
-	iter, err := q.Read(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	wantRows := [][]Value{
-		{"a", int64(0)},
-		{"b", int64(1)},
-		{"c", int64(2)},
-	}
-	checkRead(t, "location", iter, wantRows)
-
-	table2 := tokyoDataset.Table(tableIDs.New())
-	copier := table2.CopierFrom(table)
-	copier.Location = loc
-	if _, err := copier.Run(ctx); err != nil {
-		t.Fatal(err)
-	}
-	bucketName := testutil.ProjID()
-	objectName := fmt.Sprintf("bq-test-%s.csv", table.TableID)
-	uri := fmt.Sprintf("gs://%s/%s", bucketName, objectName)
-	defer storageClient.Bucket(bucketName).Object(objectName).Delete(ctx)
-	gr := NewGCSReference(uri)
-	gr.DestinationFormat = CSV
-	e := table.ExtractorTo(gr)
-	e.Location = loc
-	if _, err := e.Run(ctx); err != nil {
-		t.Fatal(err)
-	}
-}
-
-func TestIntegration_NumericErrors(t *testing.T) {
-	// Verify that the service returns an error for a big.Rat that's too large.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	schema := Schema{{Name: "n", Type: NumericFieldType}}
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-	tooBigRat := &big.Rat{}
-	if _, ok := tooBigRat.SetString("1e40"); !ok {
-		t.Fatal("big.Rat.SetString failed")
-	}
-	ins := table.Inserter()
-	err := ins.Put(ctx, []*ValuesSaver{{Schema: schema, Row: []Value{tooBigRat}}})
-	if err == nil {
-		t.Fatal("got nil, want error")
-	}
-}
-
-func TestIntegration_QueryErrors(t *testing.T) {
-	// Verify that a bad query returns an appropriate error.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	q := client.Query("blah blah broken")
-	_, err := q.Read(ctx)
-	const want = "invalidQuery"
-	if !strings.Contains(err.Error(), want) {
-		t.Fatalf("got %q, want substring %q", err, want)
-	}
-}
-
-func TestIntegration_Model(t *testing.T) {
-	// Create an ML model.
-	if client == nil {
-		t.Skip("Integration tests skipped")
-	}
-	ctx := context.Background()
-	schema := Schema{
-		{Name: "input", Type: IntegerFieldType},
-		{Name: "label", Type: IntegerFieldType},
-	}
-	table := newTable(t, schema)
-	defer table.Delete(ctx)
-
-	// Insert table data.
-	tableName := fmt.Sprintf("%s.%s", table.DatasetID, table.TableID)
-	sql := fmt.Sprintf(`INSERT %s (input, label)
-		                VALUES (1, 0), (2, 1), (3, 0), (4, 1)`,
-		tableName)
-	wantNumRows := 4
-
-	if err := runDML(ctx, sql); err != nil {
-		t.Fatal(err)
-	}
-
-	model := dataset.Table("my_model")
-	modelName := fmt.Sprintf("%s.%s", model.DatasetID, model.TableID)
-	sql = fmt.Sprintf(`CREATE MODEL %s OPTIONS (model_type='logistic_reg') AS SELECT input, label FROM %s`,
-		modelName, tableName)
-	if err := runDML(ctx, sql); err != nil {
-		t.Fatal(err)
-	}
-	defer model.Delete(ctx)
-
-	sql = fmt.Sprintf(`SELECT * FROM ml.PREDICT(MODEL %s, TABLE %s)`, modelName, tableName)
-	q := client.Query(sql)
-	ri, err := q.Read(ctx)
-	if err != nil {
-		t.Fatal(err)
-	}
-	rows, _, _, err := readAll(ri)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if got := len(rows); got != wantNumRows {
-		t.Fatalf("got %d rows in prediction table, want %d", got, wantNumRows)
-	}
-	iter := dataset.Tables(ctx)
-	seen := false
-	for {
-		tbl, err := iter.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			t.Fatal(err)
-		}
-		if tbl.TableID == "my_model" {
-			seen = true
-		}
-	}
-	if !seen {
-		t.Fatal("model not listed in dataset")
-	}
-	if err := model.Delete(ctx); err != nil {
-		t.Fatal(err)
-	}
-}
-
-// Creates a new, temporary table with a unique name and the given schema.
-func newTable(t *testing.T, s Schema) *Table {
-	table := dataset.Table(tableIDs.New())
-	err := table.Create(context.Background(), &TableMetadata{
-		Schema:         s,
-		ExpirationTime: testTableExpiration,
-	})
-	if err != nil {
-		t.Fatal(err)
-	}
-	return table
-}
-
-func checkRead(t *testing.T, msg string, it *RowIterator, want [][]Value) {
-	if msg2, ok := compareRead(it, want, false); !ok {
-		t.Errorf("%s: %s", msg, msg2)
-	}
-}
-
-func checkReadAndTotalRows(t *testing.T, msg string, it *RowIterator, want [][]Value) {
-	if msg2, ok := compareRead(it, want, true); !ok {
-		t.Errorf("%s: %s", msg, msg2)
-	}
-}
-
-func compareRead(it *RowIterator, want [][]Value, compareTotalRows bool) (msg string, ok bool) {
-	got, _, totalRows, err := readAll(it)
-	if err != nil {
-		return err.Error(), false
-	}
-	if len(got) != len(want) {
-		return fmt.Sprintf("got %d rows, want %d", len(got), len(want)), false
-	}
-	if compareTotalRows && len(got) != int(totalRows) {
-		return fmt.Sprintf("got %d rows, but totalRows = %d", len(got), totalRows), false
-	}
-	sort.Sort(byCol0(got))
-	for i, r := range got {
-		gotRow := []Value(r)
-		wantRow := want[i]
-		if !testutil.Equal(gotRow, wantRow) {
-			return fmt.Sprintf("#%d: got %#v, want %#v", i, gotRow, wantRow), false
-		}
-	}
-	return "", true
-}
-
-func readAll(it *RowIterator) ([][]Value, Schema, uint64, error) {
-	var (
-		rows      [][]Value
-		schema    Schema
-		totalRows uint64
-	)
-	for {
-		var vals []Value
-		err := it.Next(&vals)
-		if err == iterator.Done {
-			return rows, schema, totalRows, nil
-		}
-		if err != nil {
-			return nil, nil, 0, err
-		}
-		rows = append(rows, vals)
-		schema = it.Schema
-		totalRows = it.TotalRows
-	}
-}
-
-type byCol0 [][]Value
-
-func (b byCol0) Len() int      { return len(b) }
-func (b byCol0) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
-func (b byCol0) Less(i, j int) bool {
-	switch a := b[i][0].(type) {
-	case string:
-		return a < b[j][0].(string)
-	case civil.Date:
-		return a.Before(b[j][0].(civil.Date))
-	default:
-		panic("unknown type")
-	}
-}
-
-func hasStatusCode(err error, code int) bool {
-	if e, ok := err.(*googleapi.Error); ok && e.Code == code {
-		return true
-	}
-	return false
-}
-
-// wait polls the job until it is complete or an error is returned.
-func wait(ctx context.Context, job *Job) error {
-	status, err := job.Wait(ctx)
-	if err != nil {
-		return err
-	}
-	if status.Err() != nil {
-		return fmt.Errorf("job status error: %#v", status.Err())
-	}
-	if status.Statistics == nil {
-		return errors.New("nil Statistics")
-	}
-	if status.Statistics.EndTime.IsZero() {
-		return errors.New("EndTime is zero")
-	}
-	if status.Statistics.Details == nil {
-		return errors.New("nil Statistics.Details")
-	}
-	return nil
-}
-
-// waitForRow polls the table until it contains a row.
-// TODO(jba): use internal.Retry.
-func waitForRow(ctx context.Context, table *Table) error {
-	for {
-		it := table.Read(ctx)
-		var v []Value
-		err := it.Next(&v)
-		if err == nil {
-			return nil
-		}
-		if err != iterator.Done {
-			return err
-		}
-		time.Sleep(1 * time.Second)
-	}
-}
-
-func putError(err error) string {
-	pme, ok := err.(PutMultiError)
-	if !ok {
-		return err.Error()
-	}
-	var msgs []string
-	for _, err := range pme {
-		msgs = append(msgs, err.Error())
-	}
-	return strings.Join(msgs, "\n")
-}

+ 0 - 222
vendor/cloud.google.com/go/bigquery/iterator.go

@@ -1,222 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"fmt"
-	"reflect"
-
-	bq "google.golang.org/api/bigquery/v2"
-	"google.golang.org/api/iterator"
-)
-
-// Construct a RowIterator.
-// If pf is nil, there are no rows in the result set.
-func newRowIterator(ctx context.Context, t *Table, pf pageFetcher) *RowIterator {
-	it := &RowIterator{
-		ctx:   ctx,
-		table: t,
-		pf:    pf,
-	}
-	if pf != nil {
-		it.pageInfo, it.nextFunc = iterator.NewPageInfo(
-			it.fetch,
-			func() int { return len(it.rows) },
-			func() interface{} { r := it.rows; it.rows = nil; return r })
-	}
-	return it
-}
-
-// A RowIterator provides access to the result of a BigQuery lookup.
-type RowIterator struct {
-	ctx      context.Context
-	table    *Table
-	pf       pageFetcher
-	pageInfo *iterator.PageInfo
-	nextFunc func() error
-
-	// StartIndex can be set before the first call to Next. If PageInfo().Token
-	// is also set, StartIndex is ignored.
-	StartIndex uint64
-
-	// The schema of the table. Available after the first call to Next.
-	Schema Schema
-
-	// The total number of rows in the result. Available after the first call to Next.
-	// May be zero just after rows were inserted.
-	TotalRows uint64
-
-	rows         [][]Value
-	structLoader structLoader // used to populate a pointer to a struct
-}
-
-// Next loads the next row into dst. Its return value is iterator.Done if there
-// are no more results. Once Next returns iterator.Done, all subsequent calls
-// will return iterator.Done.
-//
-// dst may implement ValueLoader, or may be a *[]Value, *map[string]Value, or struct pointer.
-//
-// If dst is a *[]Value, it will be set to new []Value whose i'th element
-// will be populated with the i'th column of the row.
-//
-// If dst is a *map[string]Value, a new map will be created if dst is nil. Then
-// for each schema column name, the map key of that name will be set to the column's
-// value. STRUCT types (RECORD types or nested schemas) become nested maps.
-//
-// If dst is pointer to a struct, each column in the schema will be matched
-// with an exported field of the struct that has the same name, ignoring case.
-// Unmatched schema columns and struct fields will be ignored.
-//
-// Each BigQuery column type corresponds to one or more Go types; a matching struct
-// field must be of the correct type. The correspondences are:
-//
-//   STRING      string
-//   BOOL        bool
-//   INTEGER     int, int8, int16, int32, int64, uint8, uint16, uint32
-//   FLOAT       float32, float64
-//   BYTES       []byte
-//   TIMESTAMP   time.Time
-//   DATE        civil.Date
-//   TIME        civil.Time
-//   DATETIME    civil.DateTime
-//
-// A repeated field corresponds to a slice or array of the element type. A STRUCT
-// type (RECORD or nested schema) corresponds to a nested struct or struct pointer.
-// All calls to Next on the same iterator must use the same struct type.
-//
-// It is an error to attempt to read a BigQuery NULL value into a struct field,
-// unless the field is of type []byte or is one of the special Null types: NullInt64,
-// NullFloat64, NullBool, NullString, NullTimestamp, NullDate, NullTime or
-// NullDateTime. You can also use a *[]Value or *map[string]Value to read from a
-// table with NULLs.
-func (it *RowIterator) Next(dst interface{}) error {
-	if it.pf == nil { // There are no rows in the result set.
-		return iterator.Done
-	}
-	var vl ValueLoader
-	switch dst := dst.(type) {
-	case ValueLoader:
-		vl = dst
-	case *[]Value:
-		vl = (*valueList)(dst)
-	case *map[string]Value:
-		vl = (*valueMap)(dst)
-	default:
-		if !isStructPtr(dst) {
-			return fmt.Errorf("bigquery: cannot convert %T to ValueLoader (need pointer to []Value, map[string]Value, or struct)", dst)
-		}
-	}
-	if err := it.nextFunc(); err != nil {
-		return err
-	}
-	row := it.rows[0]
-	it.rows = it.rows[1:]
-
-	if vl == nil {
-		// This can only happen if dst is a pointer to a struct. We couldn't
-		// set vl above because we need the schema.
-		if err := it.structLoader.set(dst, it.Schema); err != nil {
-			return err
-		}
-		vl = &it.structLoader
-	}
-	return vl.Load(row, it.Schema)
-}
-
-func isStructPtr(x interface{}) bool {
-	t := reflect.TypeOf(x)
-	return t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct
-}
-
-// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
-func (it *RowIterator) PageInfo() *iterator.PageInfo { return it.pageInfo }
-
-func (it *RowIterator) fetch(pageSize int, pageToken string) (string, error) {
-	res, err := it.pf(it.ctx, it.table, it.Schema, it.StartIndex, int64(pageSize), pageToken)
-	if err != nil {
-		return "", err
-	}
-	it.rows = append(it.rows, res.rows...)
-	it.Schema = res.schema
-	it.TotalRows = res.totalRows
-	return res.pageToken, nil
-}
-
-// A pageFetcher returns a page of rows from a destination table.
-type pageFetcher func(ctx context.Context, _ *Table, _ Schema, startIndex uint64, pageSize int64, pageToken string) (*fetchPageResult, error)
-
-type fetchPageResult struct {
-	pageToken string
-	rows      [][]Value
-	totalRows uint64
-	schema    Schema
-}
-
-// fetchPage gets a page of rows from t.
-func fetchPage(ctx context.Context, t *Table, schema Schema, startIndex uint64, pageSize int64, pageToken string) (*fetchPageResult, error) {
-	// Fetch the table schema in the background, if necessary.
-	errc := make(chan error, 1)
-	if schema != nil {
-		errc <- nil
-	} else {
-		go func() {
-			var bqt *bq.Table
-			err := runWithRetry(ctx, func() (err error) {
-				bqt, err = t.c.bqs.Tables.Get(t.ProjectID, t.DatasetID, t.TableID).
-					Fields("schema").
-					Context(ctx).
-					Do()
-				return err
-			})
-			if err == nil && bqt.Schema != nil {
-				schema = bqToSchema(bqt.Schema)
-			}
-			errc <- err
-		}()
-	}
-	call := t.c.bqs.Tabledata.List(t.ProjectID, t.DatasetID, t.TableID)
-	setClientHeader(call.Header())
-	if pageToken != "" {
-		call.PageToken(pageToken)
-	} else {
-		call.StartIndex(startIndex)
-	}
-	if pageSize > 0 {
-		call.MaxResults(pageSize)
-	}
-	var res *bq.TableDataList
-	err := runWithRetry(ctx, func() (err error) {
-		res, err = call.Context(ctx).Do()
-		return err
-	})
-	if err != nil {
-		return nil, err
-	}
-	err = <-errc
-	if err != nil {
-		return nil, err
-	}
-	rows, err := convertRows(res.Rows, schema)
-	if err != nil {
-		return nil, err
-	}
-	return &fetchPageResult{
-		pageToken: res.PageToken,
-		rows:      rows,
-		totalRows: uint64(res.TotalRows),
-		schema:    schema,
-	}, nil
-}

+ 0 - 362
vendor/cloud.google.com/go/bigquery/iterator_test.go

@@ -1,362 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"testing"
-
-	"cloud.google.com/go/internal/testutil"
-	"google.golang.org/api/iterator"
-)
-
-type fetchResponse struct {
-	result *fetchPageResult // The result to return.
-	err    error            // The error to return.
-}
-
-// pageFetcherStub services fetch requests by returning data from an in-memory list of values.
-type pageFetcherStub struct {
-	fetchResponses map[string]fetchResponse
-	err            error
-}
-
-func (pf *pageFetcherStub) fetchPage(ctx context.Context, _ *Table, _ Schema, _ uint64, _ int64, pageToken string) (*fetchPageResult, error) {
-	call, ok := pf.fetchResponses[pageToken]
-	if !ok {
-		pf.err = fmt.Errorf("Unexpected page token: %q", pageToken)
-	}
-	return call.result, call.err
-}
-
-func TestIterator(t *testing.T) {
-	var (
-		iiSchema = Schema{
-			{Type: IntegerFieldType},
-			{Type: IntegerFieldType},
-		}
-		siSchema = Schema{
-			{Type: StringFieldType},
-			{Type: IntegerFieldType},
-		}
-	)
-	fetchFailure := errors.New("fetch failure")
-
-	testCases := []struct {
-		desc           string
-		pageToken      string
-		fetchResponses map[string]fetchResponse
-		want           [][]Value
-		wantErr        error
-		wantSchema     Schema
-		wantTotalRows  uint64
-	}{
-		{
-			desc: "Iteration over single empty page",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{},
-						schema:    Schema{},
-					},
-				},
-			},
-			want:       [][]Value{},
-			wantSchema: Schema{},
-		},
-		{
-			desc: "Iteration over single page",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{{1, 2}, {11, 12}},
-						schema:    iiSchema,
-						totalRows: 4,
-					},
-				},
-			},
-			want:          [][]Value{{1, 2}, {11, 12}},
-			wantSchema:    iiSchema,
-			wantTotalRows: 4,
-		},
-		{
-			desc: "Iteration over single page with different schema",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{{"1", 2}, {"11", 12}},
-						schema:    siSchema,
-					},
-				},
-			},
-			want:       [][]Value{{"1", 2}, {"11", 12}},
-			wantSchema: siSchema,
-		},
-		{
-			desc: "Iteration over two pages",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "a",
-						rows:      [][]Value{{1, 2}, {11, 12}},
-						schema:    iiSchema,
-						totalRows: 4,
-					},
-				},
-				"a": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{{101, 102}, {111, 112}},
-						schema:    iiSchema,
-						totalRows: 4,
-					},
-				},
-			},
-			want:          [][]Value{{1, 2}, {11, 12}, {101, 102}, {111, 112}},
-			wantSchema:    iiSchema,
-			wantTotalRows: 4,
-		},
-		{
-			desc: "Server response includes empty page",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "a",
-						rows:      [][]Value{{1, 2}, {11, 12}},
-						schema:    iiSchema,
-					},
-				},
-				"a": {
-					result: &fetchPageResult{
-						pageToken: "b",
-						rows:      [][]Value{},
-						schema:    iiSchema,
-					},
-				},
-				"b": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{{101, 102}, {111, 112}},
-						schema:    iiSchema,
-					},
-				},
-			},
-			want:       [][]Value{{1, 2}, {11, 12}, {101, 102}, {111, 112}},
-			wantSchema: iiSchema,
-		},
-		{
-			desc: "Fetch error",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "a",
-						rows:      [][]Value{{1, 2}, {11, 12}},
-						schema:    iiSchema,
-					},
-				},
-				"a": {
-					// We returns some data from this fetch, but also an error.
-					// So the end result should include only data from the previous fetch.
-					err: fetchFailure,
-					result: &fetchPageResult{
-						pageToken: "b",
-						rows:      [][]Value{{101, 102}, {111, 112}},
-						schema:    iiSchema,
-					},
-				},
-			},
-			want:       [][]Value{{1, 2}, {11, 12}},
-			wantErr:    fetchFailure,
-			wantSchema: iiSchema,
-		},
-
-		{
-			desc:      "Skip over an entire page",
-			pageToken: "a",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "a",
-						rows:      [][]Value{{1, 2}, {11, 12}},
-						schema:    iiSchema,
-					},
-				},
-				"a": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{{101, 102}, {111, 112}},
-						schema:    iiSchema,
-					},
-				},
-			},
-			want:       [][]Value{{101, 102}, {111, 112}},
-			wantSchema: iiSchema,
-		},
-
-		{
-			desc:      "Skip beyond all data",
-			pageToken: "b",
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "a",
-						rows:      [][]Value{{1, 2}, {11, 12}},
-						schema:    iiSchema,
-					},
-				},
-				"a": {
-					result: &fetchPageResult{
-						pageToken: "b",
-						rows:      [][]Value{{101, 102}, {111, 112}},
-						schema:    iiSchema,
-					},
-				},
-				"b": {
-					result: &fetchPageResult{},
-				},
-			},
-			// In this test case, Next will return false on its first call,
-			// so we won't even attempt to call Get.
-			want:       [][]Value{},
-			wantSchema: Schema{},
-		},
-	}
-
-	for _, tc := range testCases {
-		pf := &pageFetcherStub{
-			fetchResponses: tc.fetchResponses,
-		}
-		it := newRowIterator(context.Background(), nil, pf.fetchPage)
-		it.PageInfo().Token = tc.pageToken
-		values, schema, totalRows, err := consumeRowIterator(it)
-		if err != tc.wantErr {
-			t.Fatalf("%s: got %v, want %v", tc.desc, err, tc.wantErr)
-		}
-		if (len(values) != 0 || len(tc.want) != 0) && !testutil.Equal(values, tc.want) {
-			t.Errorf("%s: values:\ngot: %v\nwant:%v", tc.desc, values, tc.want)
-		}
-		if (len(schema) != 0 || len(tc.wantSchema) != 0) && !testutil.Equal(schema, tc.wantSchema) {
-			t.Errorf("%s: iterator.Schema:\ngot: %v\nwant: %v", tc.desc, schema, tc.wantSchema)
-		}
-		if totalRows != tc.wantTotalRows {
-			t.Errorf("%s: totalRows: got %d, want %d", tc.desc, totalRows, tc.wantTotalRows)
-		}
-	}
-}
-
-// consumeRowIterator reads the schema and all values from a RowIterator and returns them.
-func consumeRowIterator(it *RowIterator) ([][]Value, Schema, uint64, error) {
-	var (
-		got       [][]Value
-		schema    Schema
-		totalRows uint64
-	)
-	for {
-		var vls []Value
-		err := it.Next(&vls)
-		if err == iterator.Done {
-			return got, schema, totalRows, nil
-		}
-		if err != nil {
-			return got, schema, totalRows, err
-		}
-		got = append(got, vls)
-		schema = it.Schema
-		totalRows = it.TotalRows
-	}
-}
-
-func TestNextDuringErrorState(t *testing.T) {
-	pf := &pageFetcherStub{
-		fetchResponses: map[string]fetchResponse{
-			"": {err: errors.New("bang")},
-		},
-	}
-	it := newRowIterator(context.Background(), nil, pf.fetchPage)
-	var vals []Value
-	if err := it.Next(&vals); err == nil {
-		t.Errorf("Expected error after calling Next")
-	}
-	if err := it.Next(&vals); err == nil {
-		t.Errorf("Expected error calling Next again when iterator has a non-nil error.")
-	}
-}
-
-func TestNextAfterFinished(t *testing.T) {
-	testCases := []struct {
-		fetchResponses map[string]fetchResponse
-		want           [][]Value
-	}{
-		{
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{{1, 2}, {11, 12}},
-					},
-				},
-			},
-			want: [][]Value{{1, 2}, {11, 12}},
-		},
-		{
-			fetchResponses: map[string]fetchResponse{
-				"": {
-					result: &fetchPageResult{
-						pageToken: "",
-						rows:      [][]Value{},
-					},
-				},
-			},
-			want: [][]Value{},
-		},
-	}
-
-	for _, tc := range testCases {
-		pf := &pageFetcherStub{
-			fetchResponses: tc.fetchResponses,
-		}
-		it := newRowIterator(context.Background(), nil, pf.fetchPage)
-
-		values, _, _, err := consumeRowIterator(it)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if (len(values) != 0 || len(tc.want) != 0) && !testutil.Equal(values, tc.want) {
-			t.Errorf("values: got:\n%v\nwant:\n%v", values, tc.want)
-		}
-		// Try calling Get again.
-		var vals []Value
-		if err := it.Next(&vals); err != iterator.Done {
-			t.Errorf("Expected Done calling Next when there are no more values")
-		}
-	}
-}
-
-func TestIteratorNextTypes(t *testing.T) {
-	it := newRowIterator(context.Background(), nil, nil)
-	for _, v := range []interface{}{3, "s", []int{}, &[]int{},
-		map[string]Value{}, &map[string]interface{}{},
-		struct{}{},
-	} {
-		if err := it.Next(v); err == nil {
-			t.Errorf("%v: want error, got nil", v)
-		}
-	}
-}

+ 0 - 821
vendor/cloud.google.com/go/bigquery/job.go

@@ -1,821 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"time"
-
-	"cloud.google.com/go/internal"
-	"cloud.google.com/go/internal/trace"
-	gax "github.com/googleapis/gax-go/v2"
-	bq "google.golang.org/api/bigquery/v2"
-	"google.golang.org/api/googleapi"
-	"google.golang.org/api/iterator"
-)
-
-// A Job represents an operation which has been submitted to BigQuery for processing.
-type Job struct {
-	c          *Client
-	projectID  string
-	jobID      string
-	location   string
-	email      string
-	config     *bq.JobConfiguration
-	lastStatus *JobStatus
-}
-
-// JobFromID creates a Job which refers to an existing BigQuery job. The job
-// need not have been created by this package. For example, the job may have
-// been created in the BigQuery console.
-//
-// For jobs whose location is other than "US" or "EU", set Client.Location or use
-// JobFromIDLocation.
-func (c *Client) JobFromID(ctx context.Context, id string) (*Job, error) {
-	return c.JobFromIDLocation(ctx, id, c.Location)
-}
-
-// JobFromIDLocation creates a Job which refers to an existing BigQuery job. The job
-// need not have been created by this package (for example, it may have
-// been created in the BigQuery console), but it must exist in the specified location.
-func (c *Client) JobFromIDLocation(ctx context.Context, id, location string) (j *Job, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.JobFromIDLocation")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	bqjob, err := c.getJobInternal(ctx, id, location, "configuration", "jobReference", "status", "statistics")
-	if err != nil {
-		return nil, err
-	}
-	return bqToJob(bqjob, c)
-}
-
-// ID returns the job's ID.
-func (j *Job) ID() string {
-	return j.jobID
-}
-
-// Location returns the job's location.
-func (j *Job) Location() string {
-	return j.location
-}
-
-// Email returns the email of the job's creator.
-func (j *Job) Email() string {
-	return j.email
-}
-
-// State is one of a sequence of states that a Job progresses through as it is processed.
-type State int
-
-const (
-	// StateUnspecified is the default JobIterator state.
-	StateUnspecified State = iota
-	// Pending is a state that describes that the job is pending.
-	Pending
-	// Running is a state that describes that the job is running.
-	Running
-	// Done is a state that describes that the job is done.
-	Done
-)
-
-// JobStatus contains the current State of a job, and errors encountered while processing that job.
-type JobStatus struct {
-	State State
-
-	err error
-
-	// All errors encountered during the running of the job.
-	// Not all Errors are fatal, so errors here do not necessarily mean that the job has completed or was unsuccessful.
-	Errors []*Error
-
-	// Statistics about the job.
-	Statistics *JobStatistics
-}
-
-// JobConfig contains configuration information for a job. It is implemented by
-// *CopyConfig, *ExtractConfig, *LoadConfig and *QueryConfig.
-type JobConfig interface {
-	isJobConfig()
-}
-
-func (*CopyConfig) isJobConfig()    {}
-func (*ExtractConfig) isJobConfig() {}
-func (*LoadConfig) isJobConfig()    {}
-func (*QueryConfig) isJobConfig()   {}
-
-// Config returns the configuration information for j.
-func (j *Job) Config() (JobConfig, error) {
-	return bqToJobConfig(j.config, j.c)
-}
-
-func bqToJobConfig(q *bq.JobConfiguration, c *Client) (JobConfig, error) {
-	switch {
-	case q == nil:
-		return nil, nil
-	case q.Copy != nil:
-		return bqToCopyConfig(q, c), nil
-	case q.Extract != nil:
-		return bqToExtractConfig(q, c), nil
-	case q.Load != nil:
-		return bqToLoadConfig(q, c), nil
-	case q.Query != nil:
-		return bqToQueryConfig(q, c)
-	default:
-		return nil, nil
-	}
-}
-
-// JobIDConfig  describes how to create an ID for a job.
-type JobIDConfig struct {
-	// JobID is the ID to use for the job. If empty, a random job ID will be generated.
-	JobID string
-
-	// If AddJobIDSuffix is true, then a random string will be appended to JobID.
-	AddJobIDSuffix bool
-
-	// Location is the location for the job.
-	Location string
-}
-
-// createJobRef creates a JobReference.
-func (j *JobIDConfig) createJobRef(c *Client) *bq.JobReference {
-	// We don't check whether projectID is empty; the server will return an
-	// error when it encounters the resulting JobReference.
-	loc := j.Location
-	if loc == "" { // Use Client.Location as a default.
-		loc = c.Location
-	}
-	jr := &bq.JobReference{ProjectId: c.projectID, Location: loc}
-	if j.JobID == "" {
-		jr.JobId = randomIDFn()
-	} else if j.AddJobIDSuffix {
-		jr.JobId = j.JobID + "-" + randomIDFn()
-	} else {
-		jr.JobId = j.JobID
-	}
-	return jr
-}
-
-// Done reports whether the job has completed.
-// After Done returns true, the Err method will return an error if the job completed unsuccessfully.
-func (s *JobStatus) Done() bool {
-	return s.State == Done
-}
-
-// Err returns the error that caused the job to complete unsuccessfully (if any).
-func (s *JobStatus) Err() error {
-	return s.err
-}
-
-// Status retrieves the current status of the job from BigQuery. It fails if the Status could not be determined.
-func (j *Job) Status(ctx context.Context) (js *JobStatus, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Job.Status")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	bqjob, err := j.c.getJobInternal(ctx, j.jobID, j.location, "status", "statistics")
-	if err != nil {
-		return nil, err
-	}
-	if err := j.setStatus(bqjob.Status); err != nil {
-		return nil, err
-	}
-	j.setStatistics(bqjob.Statistics, j.c)
-	return j.lastStatus, nil
-}
-
-// LastStatus returns the most recently retrieved status of the job. The status is
-// retrieved when a new job is created, or when JobFromID or Job.Status is called.
-// Call Job.Status to get the most up-to-date information about a job.
-func (j *Job) LastStatus() *JobStatus {
-	return j.lastStatus
-}
-
-// Cancel requests that a job be cancelled. This method returns without waiting for
-// cancellation to take effect. To check whether the job has terminated, use Job.Status.
-// Cancelled jobs may still incur costs.
-func (j *Job) Cancel(ctx context.Context) error {
-	// Jobs.Cancel returns a job entity, but the only relevant piece of
-	// data it may contain (the status of the job) is unreliable.  From the
-	// docs: "This call will return immediately, and the client will need
-	// to poll for the job status to see if the cancel completed
-	// successfully".  So it would be misleading to return a status.
-	call := j.c.bqs.Jobs.Cancel(j.projectID, j.jobID).
-		Location(j.location).
-		Fields(). // We don't need any of the response data.
-		Context(ctx)
-	setClientHeader(call.Header())
-	return runWithRetry(ctx, func() error {
-		_, err := call.Do()
-		return err
-	})
-}
-
-// Wait blocks until the job or the context is done. It returns the final status
-// of the job.
-// If an error occurs while retrieving the status, Wait returns that error. But
-// Wait returns nil if the status was retrieved successfully, even if
-// status.Err() != nil. So callers must check both errors. See the example.
-func (j *Job) Wait(ctx context.Context) (js *JobStatus, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Job.Wait")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	if j.isQuery() {
-		// We can avoid polling for query jobs.
-		if _, _, err := j.waitForQuery(ctx, j.projectID); err != nil {
-			return nil, err
-		}
-		// Note: extra RPC even if you just want to wait for the query to finish.
-		js, err := j.Status(ctx)
-		if err != nil {
-			return nil, err
-		}
-		return js, nil
-	}
-	// Non-query jobs must poll.
-	err = internal.Retry(ctx, gax.Backoff{}, func() (stop bool, err error) {
-		js, err = j.Status(ctx)
-		if err != nil {
-			return true, err
-		}
-		if js.Done() {
-			return true, nil
-		}
-		return false, nil
-	})
-	if err != nil {
-		return nil, err
-	}
-	return js, nil
-}
-
-// Read fetches the results of a query job.
-// If j is not a query job, Read returns an error.
-func (j *Job) Read(ctx context.Context) (ri *RowIterator, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Job.Read")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	return j.read(ctx, j.waitForQuery, fetchPage)
-}
-
-func (j *Job) read(ctx context.Context, waitForQuery func(context.Context, string) (Schema, uint64, error), pf pageFetcher) (*RowIterator, error) {
-	if !j.isQuery() {
-		return nil, errors.New("bigquery: cannot read from a non-query job")
-	}
-	destTable := j.config.Query.DestinationTable
-	// The destination table should only be nil if there was a query error.
-	projectID := j.projectID
-	if destTable != nil && projectID != destTable.ProjectId {
-		return nil, fmt.Errorf("bigquery: job project ID is %q, but destination table's is %q", projectID, destTable.ProjectId)
-	}
-	schema, totalRows, err := waitForQuery(ctx, projectID)
-	if err != nil {
-		return nil, err
-	}
-	if destTable == nil {
-		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
-	return it, nil
-}
-
-// waitForQuery waits for the query job to complete and returns its schema. It also
-// returns the total number of rows in the result set.
-func (j *Job) waitForQuery(ctx context.Context, projectID string) (Schema, uint64, error) {
-	// Use GetQueryResults only to wait for completion, not to read results.
-	call := j.c.bqs.Jobs.GetQueryResults(projectID, j.jobID).Location(j.location).Context(ctx).MaxResults(0)
-	setClientHeader(call.Header())
-	backoff := gax.Backoff{
-		Initial:    1 * time.Second,
-		Multiplier: 2,
-		Max:        60 * time.Second,
-	}
-	var res *bq.GetQueryResultsResponse
-	err := internal.Retry(ctx, backoff, func() (stop bool, err error) {
-		res, err = call.Do()
-		if err != nil {
-			return !retryableError(err), err
-		}
-		if !res.JobComplete { // GetQueryResults may return early without error; retry.
-			return false, nil
-		}
-		return true, nil
-	})
-	if err != nil {
-		return nil, 0, err
-	}
-	return bqToSchema(res.Schema), res.TotalRows, nil
-}
-
-// JobStatistics contains statistics about a job.
-type JobStatistics struct {
-	CreationTime        time.Time
-	StartTime           time.Time
-	EndTime             time.Time
-	TotalBytesProcessed int64
-
-	Details Statistics
-}
-
-// Statistics is one of ExtractStatistics, LoadStatistics or QueryStatistics.
-type Statistics interface {
-	implementsStatistics()
-}
-
-// ExtractStatistics contains statistics about an extract job.
-type ExtractStatistics struct {
-	// The number of files per destination URI or URI pattern specified in the
-	// extract configuration. These values will be in the same order as the
-	// URIs specified in the 'destinationUris' field.
-	DestinationURIFileCounts []int64
-}
-
-// LoadStatistics contains statistics about a load job.
-type LoadStatistics struct {
-	// The number of bytes of source data in a load job.
-	InputFileBytes int64
-
-	// The number of source files in a load job.
-	InputFiles int64
-
-	// Size of the loaded data in bytes. Note that while a load job is in the
-	// running state, this value may change.
-	OutputBytes int64
-
-	// The number of rows imported in a load job. Note that while an import job is
-	// in the running state, this value may change.
-	OutputRows int64
-}
-
-// QueryStatistics contains statistics about a query job.
-type QueryStatistics struct {
-	// Billing tier for the job.
-	BillingTier int64
-
-	// Whether the query result was fetched from the query cache.
-	CacheHit bool
-
-	// The type of query statement, if valid.
-	StatementType string
-
-	// Total bytes billed for the job.
-	TotalBytesBilled int64
-
-	// Total bytes processed for the job.
-	TotalBytesProcessed int64
-
-	// Describes execution plan for the query.
-	QueryPlan []*ExplainQueryStage
-
-	// The number of rows affected by a DML statement. Present only for DML
-	// statements INSERT, UPDATE or DELETE.
-	NumDMLAffectedRows int64
-
-	// Describes a timeline of job execution.
-	Timeline []*QueryTimelineSample
-
-	// ReferencedTables: [Output-only, Experimental] Referenced tables for
-	// the job. Queries that reference more than 50 tables will not have a
-	// complete list.
-	ReferencedTables []*Table
-
-	// The schema of the results. Present only for successful dry run of
-	// non-legacy SQL queries.
-	Schema Schema
-
-	// Slot-milliseconds consumed by this query job.
-	SlotMillis int64
-
-	// Standard SQL: list of undeclared query parameter names detected during a
-	// dry run validation.
-	UndeclaredQueryParameterNames []string
-
-	// DDL target table.
-	DDLTargetTable *Table
-
-	// DDL Operation performed on the target table.  Used to report how the
-	// query impacted the DDL target table.
-	DDLOperationPerformed string
-}
-
-// ExplainQueryStage describes one stage of a query.
-type ExplainQueryStage struct {
-	// CompletedParallelInputs: Number of parallel input segments completed.
-	CompletedParallelInputs int64
-
-	// ComputeAvg: Duration the average shard spent on CPU-bound tasks.
-	ComputeAvg time.Duration
-
-	// ComputeMax: Duration the slowest shard spent on CPU-bound tasks.
-	ComputeMax time.Duration
-
-	// Relative amount of the total time the average shard spent on CPU-bound tasks.
-	ComputeRatioAvg float64
-
-	// Relative amount of the total time the slowest shard spent on CPU-bound tasks.
-	ComputeRatioMax float64
-
-	// EndTime: Stage end time.
-	EndTime time.Time
-
-	// Unique ID for stage within plan.
-	ID int64
-
-	// InputStages: IDs for stages that are inputs to this stage.
-	InputStages []int64
-
-	// Human-readable name for stage.
-	Name string
-
-	// ParallelInputs: Number of parallel input segments to be processed.
-	ParallelInputs int64
-
-	// ReadAvg: Duration the average shard spent reading input.
-	ReadAvg time.Duration
-
-	// ReadMax: Duration the slowest shard spent reading input.
-	ReadMax time.Duration
-
-	// Relative amount of the total time the average shard spent reading input.
-	ReadRatioAvg float64
-
-	// Relative amount of the total time the slowest shard spent reading input.
-	ReadRatioMax float64
-
-	// Number of records read into the stage.
-	RecordsRead int64
-
-	// Number of records written by the stage.
-	RecordsWritten int64
-
-	// ShuffleOutputBytes: Total number of bytes written to shuffle.
-	ShuffleOutputBytes int64
-
-	// ShuffleOutputBytesSpilled: Total number of bytes written to shuffle
-	// and spilled to disk.
-	ShuffleOutputBytesSpilled int64
-
-	// StartTime: Stage start time.
-	StartTime time.Time
-
-	// Current status for the stage.
-	Status string
-
-	// List of operations within the stage in dependency order (approximately
-	// chronological).
-	Steps []*ExplainQueryStep
-
-	// WaitAvg: Duration the average shard spent waiting to be scheduled.
-	WaitAvg time.Duration
-
-	// WaitMax: Duration the slowest shard spent waiting to be scheduled.
-	WaitMax time.Duration
-
-	// Relative amount of the total time the average shard spent waiting to be scheduled.
-	WaitRatioAvg float64
-
-	// Relative amount of the total time the slowest shard spent waiting to be scheduled.
-	WaitRatioMax float64
-
-	// WriteAvg: Duration the average shard spent on writing output.
-	WriteAvg time.Duration
-
-	// WriteMax: Duration the slowest shard spent on writing output.
-	WriteMax time.Duration
-
-	// Relative amount of the total time the average shard spent on writing output.
-	WriteRatioAvg float64
-
-	// Relative amount of the total time the slowest shard spent on writing output.
-	WriteRatioMax float64
-}
-
-// ExplainQueryStep describes one step of a query stage.
-type ExplainQueryStep struct {
-	// Machine-readable operation type.
-	Kind string
-
-	// Human-readable stage descriptions.
-	Substeps []string
-}
-
-// QueryTimelineSample represents a sample of execution statistics at a point in time.
-type QueryTimelineSample struct {
-
-	// Total number of units currently being processed by workers, represented as largest value since last sample.
-	ActiveUnits int64
-
-	// Total parallel units of work completed by this query.
-	CompletedUnits int64
-
-	// Time elapsed since start of query execution.
-	Elapsed time.Duration
-
-	// Total parallel units of work remaining for the active stages.
-	PendingUnits int64
-
-	// Cumulative slot-milliseconds consumed by the query.
-	SlotMillis int64
-}
-
-func (*ExtractStatistics) implementsStatistics() {}
-func (*LoadStatistics) implementsStatistics()    {}
-func (*QueryStatistics) implementsStatistics()   {}
-
-// Jobs lists jobs within a project.
-func (c *Client) Jobs(ctx context.Context) *JobIterator {
-	it := &JobIterator{
-		ctx:       ctx,
-		c:         c,
-		ProjectID: c.projectID,
-	}
-	it.pageInfo, it.nextFunc = iterator.NewPageInfo(
-		it.fetch,
-		func() int { return len(it.items) },
-		func() interface{} { b := it.items; it.items = nil; return b })
-	return it
-}
-
-// JobIterator iterates over jobs in a project.
-type JobIterator struct {
-	ProjectID       string    // Project ID of the jobs to list. Default is the client's project.
-	AllUsers        bool      // Whether to list jobs owned by all users in the project, or just the current caller.
-	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.
-
-	ctx      context.Context
-	c        *Client
-	pageInfo *iterator.PageInfo
-	nextFunc func() error
-	items    []*Job
-}
-
-// PageInfo is a getter for the JobIterator's PageInfo.
-func (it *JobIterator) PageInfo() *iterator.PageInfo { return it.pageInfo }
-
-// Next returns the next Job. 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 *JobIterator) Next() (*Job, error) {
-	if err := it.nextFunc(); err != nil {
-		return nil, err
-	}
-	item := it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-func (it *JobIterator) fetch(pageSize int, pageToken string) (string, error) {
-	var st string
-	switch it.State {
-	case StateUnspecified:
-		st = ""
-	case Pending:
-		st = "pending"
-	case Running:
-		st = "running"
-	case Done:
-		st = "done"
-	default:
-		return "", fmt.Errorf("bigquery: invalid value for JobIterator.State: %d", it.State)
-	}
-
-	req := it.c.bqs.Jobs.List(it.ProjectID).
-		Context(it.ctx).
-		PageToken(pageToken).
-		Projection("full").
-		AllUsers(it.AllUsers)
-	if st != "" {
-		req.StateFilter(st)
-	}
-	if !it.MinCreationTime.IsZero() {
-		req.MinCreationTime(uint64(it.MinCreationTime.UnixNano() / 1e6))
-	}
-	if !it.MaxCreationTime.IsZero() {
-		req.MaxCreationTime(uint64(it.MaxCreationTime.UnixNano() / 1e6))
-	}
-	setClientHeader(req.Header())
-	if pageSize > 0 {
-		req.MaxResults(int64(pageSize))
-	}
-	res, err := req.Do()
-	if err != nil {
-		return "", err
-	}
-	for _, j := range res.Jobs {
-		job, err := convertListedJob(j, it.c)
-		if err != nil {
-			return "", err
-		}
-		it.items = append(it.items, job)
-	}
-	return res.NextPageToken, nil
-}
-
-func convertListedJob(j *bq.JobListJobs, c *Client) (*Job, error) {
-	return bqToJob2(j.JobReference, j.Configuration, j.Status, j.Statistics, j.UserEmail, c)
-}
-
-func (c *Client) getJobInternal(ctx context.Context, jobID, location string, fields ...googleapi.Field) (*bq.Job, error) {
-	var job *bq.Job
-	call := c.bqs.Jobs.Get(c.projectID, jobID).Context(ctx)
-	if location != "" {
-		call = call.Location(location)
-	}
-	if len(fields) > 0 {
-		call = call.Fields(fields...)
-	}
-	setClientHeader(call.Header())
-	err := runWithRetry(ctx, func() (err error) {
-		job, err = call.Do()
-		return err
-	})
-	if err != nil {
-		return nil, err
-	}
-	return job, nil
-}
-
-func bqToJob(q *bq.Job, c *Client) (*Job, error) {
-	return bqToJob2(q.JobReference, q.Configuration, q.Status, q.Statistics, q.UserEmail, c)
-}
-
-func bqToJob2(qr *bq.JobReference, qc *bq.JobConfiguration, qs *bq.JobStatus, qt *bq.JobStatistics, email string, c *Client) (*Job, error) {
-	j := &Job{
-		projectID: qr.ProjectId,
-		jobID:     qr.JobId,
-		location:  qr.Location,
-		c:         c,
-		email:     email,
-	}
-	j.setConfig(qc)
-	if err := j.setStatus(qs); err != nil {
-		return nil, err
-	}
-	j.setStatistics(qt, c)
-	return j, nil
-}
-
-func (j *Job) setConfig(config *bq.JobConfiguration) {
-	if config == nil {
-		return
-	}
-	j.config = config
-}
-
-func (j *Job) isQuery() bool {
-	return j.config != nil && j.config.Query != nil
-}
-
-var stateMap = map[string]State{"PENDING": Pending, "RUNNING": Running, "DONE": Done}
-
-func (j *Job) setStatus(qs *bq.JobStatus) error {
-	if qs == nil {
-		return nil
-	}
-	state, ok := stateMap[qs.State]
-	if !ok {
-		return fmt.Errorf("unexpected job state: %v", qs.State)
-	}
-	j.lastStatus = &JobStatus{
-		State: state,
-		err:   nil,
-	}
-	if err := bqToError(qs.ErrorResult); state == Done && err != nil {
-		j.lastStatus.err = err
-	}
-	for _, ep := range qs.Errors {
-		j.lastStatus.Errors = append(j.lastStatus.Errors, bqToError(ep))
-	}
-	return nil
-}
-
-func (j *Job) setStatistics(s *bq.JobStatistics, c *Client) {
-	if s == nil || j.lastStatus == nil {
-		return
-	}
-	js := &JobStatistics{
-		CreationTime:        unixMillisToTime(s.CreationTime),
-		StartTime:           unixMillisToTime(s.StartTime),
-		EndTime:             unixMillisToTime(s.EndTime),
-		TotalBytesProcessed: s.TotalBytesProcessed,
-	}
-	switch {
-	case s.Extract != nil:
-		js.Details = &ExtractStatistics{
-			DestinationURIFileCounts: []int64(s.Extract.DestinationUriFileCounts),
-		}
-	case s.Load != nil:
-		js.Details = &LoadStatistics{
-			InputFileBytes: s.Load.InputFileBytes,
-			InputFiles:     s.Load.InputFiles,
-			OutputBytes:    s.Load.OutputBytes,
-			OutputRows:     s.Load.OutputRows,
-		}
-	case s.Query != nil:
-		var names []string
-		for _, qp := range s.Query.UndeclaredQueryParameters {
-			names = append(names, qp.Name)
-		}
-		var tables []*Table
-		for _, tr := range s.Query.ReferencedTables {
-			tables = append(tables, bqToTable(tr, c))
-		}
-		js.Details = &QueryStatistics{
-			BillingTier:                   s.Query.BillingTier,
-			CacheHit:                      s.Query.CacheHit,
-			DDLTargetTable:                bqToTable(s.Query.DdlTargetTable, c),
-			DDLOperationPerformed:         s.Query.DdlOperationPerformed,
-			StatementType:                 s.Query.StatementType,
-			TotalBytesBilled:              s.Query.TotalBytesBilled,
-			TotalBytesProcessed:           s.Query.TotalBytesProcessed,
-			NumDMLAffectedRows:            s.Query.NumDmlAffectedRows,
-			QueryPlan:                     queryPlanFromProto(s.Query.QueryPlan),
-			Schema:                        bqToSchema(s.Query.Schema),
-			SlotMillis:                    s.Query.TotalSlotMs,
-			Timeline:                      timelineFromProto(s.Query.Timeline),
-			ReferencedTables:              tables,
-			UndeclaredQueryParameterNames: names,
-		}
-	}
-	j.lastStatus.Statistics = js
-}
-
-func queryPlanFromProto(stages []*bq.ExplainQueryStage) []*ExplainQueryStage {
-	var res []*ExplainQueryStage
-	for _, s := range stages {
-		var steps []*ExplainQueryStep
-		for _, p := range s.Steps {
-			steps = append(steps, &ExplainQueryStep{
-				Kind:     p.Kind,
-				Substeps: p.Substeps,
-			})
-		}
-		res = append(res, &ExplainQueryStage{
-			CompletedParallelInputs:   s.CompletedParallelInputs,
-			ComputeAvg:                time.Duration(s.ComputeMsAvg) * time.Millisecond,
-			ComputeMax:                time.Duration(s.ComputeMsMax) * time.Millisecond,
-			ComputeRatioAvg:           s.ComputeRatioAvg,
-			ComputeRatioMax:           s.ComputeRatioMax,
-			EndTime:                   time.Unix(0, s.EndMs*1e6),
-			ID:                        s.Id,
-			InputStages:               s.InputStages,
-			Name:                      s.Name,
-			ParallelInputs:            s.ParallelInputs,
-			ReadAvg:                   time.Duration(s.ReadMsAvg) * time.Millisecond,
-			ReadMax:                   time.Duration(s.ReadMsMax) * time.Millisecond,
-			ReadRatioAvg:              s.ReadRatioAvg,
-			ReadRatioMax:              s.ReadRatioMax,
-			RecordsRead:               s.RecordsRead,
-			RecordsWritten:            s.RecordsWritten,
-			ShuffleOutputBytes:        s.ShuffleOutputBytes,
-			ShuffleOutputBytesSpilled: s.ShuffleOutputBytesSpilled,
-			StartTime:                 time.Unix(0, s.StartMs*1e6),
-			Status:                    s.Status,
-			Steps:                     steps,
-			WaitAvg:                   time.Duration(s.WaitMsAvg) * time.Millisecond,
-			WaitMax:                   time.Duration(s.WaitMsMax) * time.Millisecond,
-			WaitRatioAvg:              s.WaitRatioAvg,
-			WaitRatioMax:              s.WaitRatioMax,
-			WriteAvg:                  time.Duration(s.WriteMsAvg) * time.Millisecond,
-			WriteMax:                  time.Duration(s.WriteMsMax) * time.Millisecond,
-			WriteRatioAvg:             s.WriteRatioAvg,
-			WriteRatioMax:             s.WriteRatioMax,
-		})
-	}
-	return res
-}
-
-func timelineFromProto(timeline []*bq.QueryTimelineSample) []*QueryTimelineSample {
-	var res []*QueryTimelineSample
-	for _, s := range timeline {
-		res = append(res, &QueryTimelineSample{
-			ActiveUnits:    s.ActiveUnits,
-			CompletedUnits: s.CompletedUnits,
-			Elapsed:        time.Duration(s.ElapsedMs) * time.Millisecond,
-			PendingUnits:   s.PendingUnits,
-			SlotMillis:     s.TotalSlotMs,
-		})
-	}
-	return res
-}

+ 0 - 95
vendor/cloud.google.com/go/bigquery/job_test.go

@@ -1,95 +0,0 @@
-// Copyright 2017 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"testing"
-
-	"cloud.google.com/go/internal/testutil"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func TestCreateJobRef(t *testing.T) {
-	defer fixRandomID("RANDOM")()
-	cNoLoc := &Client{projectID: "projectID"}
-	cLoc := &Client{projectID: "projectID", Location: "defaultLoc"}
-	for _, test := range []struct {
-		in     JobIDConfig
-		client *Client
-		want   *bq.JobReference
-	}{
-		{
-			in:   JobIDConfig{JobID: "foo"},
-			want: &bq.JobReference{JobId: "foo"},
-		},
-		{
-			in:   JobIDConfig{},
-			want: &bq.JobReference{JobId: "RANDOM"},
-		},
-		{
-			in:   JobIDConfig{AddJobIDSuffix: true},
-			want: &bq.JobReference{JobId: "RANDOM"},
-		},
-		{
-			in:   JobIDConfig{JobID: "foo", AddJobIDSuffix: true},
-			want: &bq.JobReference{JobId: "foo-RANDOM"},
-		},
-		{
-			in:   JobIDConfig{JobID: "foo", Location: "loc"},
-			want: &bq.JobReference{JobId: "foo", Location: "loc"},
-		},
-		{
-			in:     JobIDConfig{JobID: "foo"},
-			client: cLoc,
-			want:   &bq.JobReference{JobId: "foo", Location: "defaultLoc"},
-		},
-		{
-			in:     JobIDConfig{JobID: "foo", Location: "loc"},
-			client: cLoc,
-			want:   &bq.JobReference{JobId: "foo", Location: "loc"},
-		},
-	} {
-		client := test.client
-		if client == nil {
-			client = cNoLoc
-		}
-		got := test.in.createJobRef(client)
-		test.want.ProjectId = "projectID"
-		if !testutil.Equal(got, test.want) {
-			t.Errorf("%+v: got %+v, want %+v", test.in, got, test.want)
-		}
-	}
-}
-
-func fixRandomID(s string) func() {
-	prev := randomIDFn
-	randomIDFn = func() string { return s }
-	return func() { randomIDFn = prev }
-}
-
-func checkJob(t *testing.T, i int, got, want *bq.Job) {
-	if got.JobReference == nil {
-		t.Errorf("#%d: empty job  reference", i)
-		return
-	}
-	if got.JobReference.JobId == "" {
-		t.Errorf("#%d: empty job ID", i)
-		return
-	}
-	d := testutil.Diff(got, want)
-	if d != "" {
-		t.Errorf("#%d: (got=-, want=+) %s", i, d)
-	}
-}

+ 0 - 146
vendor/cloud.google.com/go/bigquery/load.go

@@ -1,146 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"io"
-
-	"cloud.google.com/go/internal/trace"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// LoadConfig holds the configuration for a load job.
-type LoadConfig struct {
-	// Src is the source from which data will be loaded.
-	Src LoadSource
-
-	// Dst is the table into which the data will be loaded.
-	Dst *Table
-
-	// CreateDisposition specifies the circumstances under which the destination table will be created.
-	// The default is CreateIfNeeded.
-	CreateDisposition TableCreateDisposition
-
-	// WriteDisposition specifies how existing data in the destination table is treated.
-	// The default is WriteAppend.
-	WriteDisposition TableWriteDisposition
-
-	// The labels associated with this job.
-	Labels map[string]string
-
-	// If non-nil, the destination table is partitioned by time.
-	TimePartitioning *TimePartitioning
-
-	// Clustering specifies the data clustering configuration for the destination table.
-	Clustering *Clustering
-
-	// Custom encryption configuration (e.g., Cloud KMS keys).
-	DestinationEncryptionConfig *EncryptionConfig
-
-	// Allows the schema of the destination table to be updated as a side effect of
-	// the load job.
-	SchemaUpdateOptions []string
-}
-
-func (l *LoadConfig) toBQ() (*bq.JobConfiguration, io.Reader) {
-	config := &bq.JobConfiguration{
-		Labels: l.Labels,
-		Load: &bq.JobConfigurationLoad{
-			CreateDisposition:                  string(l.CreateDisposition),
-			WriteDisposition:                   string(l.WriteDisposition),
-			DestinationTable:                   l.Dst.toBQ(),
-			TimePartitioning:                   l.TimePartitioning.toBQ(),
-			Clustering:                         l.Clustering.toBQ(),
-			DestinationEncryptionConfiguration: l.DestinationEncryptionConfig.toBQ(),
-			SchemaUpdateOptions:                l.SchemaUpdateOptions,
-		},
-	}
-	media := l.Src.populateLoadConfig(config.Load)
-	return config, media
-}
-
-func bqToLoadConfig(q *bq.JobConfiguration, c *Client) *LoadConfig {
-	lc := &LoadConfig{
-		Labels:                      q.Labels,
-		CreateDisposition:           TableCreateDisposition(q.Load.CreateDisposition),
-		WriteDisposition:            TableWriteDisposition(q.Load.WriteDisposition),
-		Dst:                         bqToTable(q.Load.DestinationTable, c),
-		TimePartitioning:            bqToTimePartitioning(q.Load.TimePartitioning),
-		Clustering:                  bqToClustering(q.Load.Clustering),
-		DestinationEncryptionConfig: bqToEncryptionConfig(q.Load.DestinationEncryptionConfiguration),
-		SchemaUpdateOptions:         q.Load.SchemaUpdateOptions,
-	}
-	var fc *FileConfig
-	if len(q.Load.SourceUris) == 0 {
-		s := NewReaderSource(nil)
-		fc = &s.FileConfig
-		lc.Src = s
-	} else {
-		s := NewGCSReference(q.Load.SourceUris...)
-		fc = &s.FileConfig
-		lc.Src = s
-	}
-	bqPopulateFileConfig(q.Load, fc)
-	return lc
-}
-
-// A Loader loads data from Google Cloud Storage into a BigQuery table.
-type Loader struct {
-	JobIDConfig
-	LoadConfig
-	c *Client
-}
-
-// A LoadSource represents a source of data that can be loaded into
-// a BigQuery table.
-//
-// This package defines two LoadSources: GCSReference, for Google Cloud Storage
-// objects, and ReaderSource, for data read from an io.Reader.
-type LoadSource interface {
-	// populates config, returns media
-	populateLoadConfig(*bq.JobConfigurationLoad) io.Reader
-}
-
-// LoaderFrom returns a Loader which can be used to load data into a BigQuery table.
-// The returned Loader may optionally be further configured before its Run method is called.
-// See GCSReference and ReaderSource for additional configuration options that
-// affect loading.
-func (t *Table) LoaderFrom(src LoadSource) *Loader {
-	return &Loader{
-		c: t.c,
-		LoadConfig: LoadConfig{
-			Src: src,
-			Dst: t,
-		},
-	}
-}
-
-// Run initiates a load job.
-func (l *Loader) Run(ctx context.Context) (j *Job, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Load.Run")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	job, media := l.newJob()
-	return l.c.insertJob(ctx, job, media)
-}
-
-func (l *Loader) newJob() (*bq.Job, io.Reader) {
-	config, media := l.LoadConfig.toBQ()
-	return &bq.Job{
-		JobReference:  l.JobIDConfig.createJobRef(l.c),
-		Configuration: config,
-	}, media
-}

+ 0 - 263
vendor/cloud.google.com/go/bigquery/load_test.go

@@ -1,263 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"strings"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	"github.com/google/go-cmp/cmp/cmpopts"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func defaultLoadJob() *bq.Job {
-	return &bq.Job{
-		JobReference: &bq.JobReference{JobId: "RANDOM", ProjectId: "client-project-id"},
-		Configuration: &bq.JobConfiguration{
-			Load: &bq.JobConfigurationLoad{
-				DestinationTable: &bq.TableReference{
-					ProjectId: "client-project-id",
-					DatasetId: "dataset-id",
-					TableId:   "table-id",
-				},
-				SourceUris: []string{"uri"},
-			},
-		},
-	}
-}
-
-func stringFieldSchema() *FieldSchema {
-	return &FieldSchema{Name: "fieldname", Type: StringFieldType}
-}
-
-func nestedFieldSchema() *FieldSchema {
-	return &FieldSchema{
-		Name:   "nested",
-		Type:   RecordFieldType,
-		Schema: Schema{stringFieldSchema()},
-	}
-}
-
-func bqStringFieldSchema() *bq.TableFieldSchema {
-	return &bq.TableFieldSchema{
-		Name: "fieldname",
-		Type: "STRING",
-	}
-}
-
-func bqNestedFieldSchema() *bq.TableFieldSchema {
-	return &bq.TableFieldSchema{
-		Name:   "nested",
-		Type:   "RECORD",
-		Fields: []*bq.TableFieldSchema{bqStringFieldSchema()},
-	}
-}
-
-func TestLoad(t *testing.T) {
-	defer fixRandomID("RANDOM")()
-	c := &Client{projectID: "client-project-id"}
-
-	testCases := []struct {
-		dst      *Table
-		src      LoadSource
-		jobID    string
-		location string
-		config   LoadConfig
-		want     *bq.Job
-	}{
-		{
-			dst:  c.Dataset("dataset-id").Table("table-id"),
-			src:  NewGCSReference("uri"),
-			want: defaultLoadJob(),
-		},
-		{
-			dst:      c.Dataset("dataset-id").Table("table-id"),
-			src:      NewGCSReference("uri"),
-			location: "loc",
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				j.JobReference.Location = "loc"
-				return j
-			}(),
-		},
-		{
-			dst:   c.Dataset("dataset-id").Table("table-id"),
-			jobID: "ajob",
-			config: LoadConfig{
-				CreateDisposition:           CreateNever,
-				WriteDisposition:            WriteTruncate,
-				Labels:                      map[string]string{"a": "b"},
-				TimePartitioning:            &TimePartitioning{Expiration: 1234 * time.Millisecond},
-				Clustering:                  &Clustering{Fields: []string{"cfield1"}},
-				DestinationEncryptionConfig: &EncryptionConfig{KMSKeyName: "keyName"},
-				SchemaUpdateOptions:         []string{"ALLOW_FIELD_ADDITION"},
-			},
-			src: NewGCSReference("uri"),
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				j.Configuration.Labels = map[string]string{"a": "b"}
-				j.Configuration.Load.CreateDisposition = "CREATE_NEVER"
-				j.Configuration.Load.WriteDisposition = "WRITE_TRUNCATE"
-				j.Configuration.Load.TimePartitioning = &bq.TimePartitioning{
-					Type:         "DAY",
-					ExpirationMs: 1234,
-				}
-				j.Configuration.Load.Clustering = &bq.Clustering{
-					Fields: []string{"cfield1"},
-				}
-				j.Configuration.Load.DestinationEncryptionConfiguration = &bq.EncryptionConfiguration{KmsKeyName: "keyName"}
-				j.JobReference = &bq.JobReference{
-					JobId:     "ajob",
-					ProjectId: "client-project-id",
-				}
-				j.Configuration.Load.SchemaUpdateOptions = []string{"ALLOW_FIELD_ADDITION"}
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: func() *GCSReference {
-				g := NewGCSReference("uri")
-				g.MaxBadRecords = 1
-				g.AllowJaggedRows = true
-				g.AllowQuotedNewlines = true
-				g.IgnoreUnknownValues = true
-				return g
-			}(),
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				j.Configuration.Load.MaxBadRecords = 1
-				j.Configuration.Load.AllowJaggedRows = true
-				j.Configuration.Load.AllowQuotedNewlines = true
-				j.Configuration.Load.IgnoreUnknownValues = true
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: func() *GCSReference {
-				g := NewGCSReference("uri")
-				g.Schema = Schema{
-					stringFieldSchema(),
-					nestedFieldSchema(),
-				}
-				return g
-			}(),
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				j.Configuration.Load.Schema = &bq.TableSchema{
-					Fields: []*bq.TableFieldSchema{
-						bqStringFieldSchema(),
-						bqNestedFieldSchema(),
-					}}
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: func() *GCSReference {
-				g := NewGCSReference("uri")
-				g.SkipLeadingRows = 1
-				g.SourceFormat = JSON
-				g.Encoding = UTF_8
-				g.FieldDelimiter = "\t"
-				g.Quote = "-"
-				return g
-			}(),
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				j.Configuration.Load.SkipLeadingRows = 1
-				j.Configuration.Load.SourceFormat = "NEWLINE_DELIMITED_JSON"
-				j.Configuration.Load.Encoding = "UTF-8"
-				j.Configuration.Load.FieldDelimiter = "\t"
-				hyphen := "-"
-				j.Configuration.Load.Quote = &hyphen
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: NewGCSReference("uri"),
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				// Quote is left unset in GCSReference, so should be nil here.
-				j.Configuration.Load.Quote = nil
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: func() *GCSReference {
-				g := NewGCSReference("uri")
-				g.ForceZeroQuote = true
-				return g
-			}(),
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				empty := ""
-				j.Configuration.Load.Quote = &empty
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: func() *ReaderSource {
-				r := NewReaderSource(strings.NewReader("foo"))
-				r.SkipLeadingRows = 1
-				r.SourceFormat = JSON
-				r.Encoding = UTF_8
-				r.FieldDelimiter = "\t"
-				r.Quote = "-"
-				return r
-			}(),
-			want: func() *bq.Job {
-				j := defaultLoadJob()
-				j.Configuration.Load.SourceUris = nil
-				j.Configuration.Load.SkipLeadingRows = 1
-				j.Configuration.Load.SourceFormat = "NEWLINE_DELIMITED_JSON"
-				j.Configuration.Load.Encoding = "UTF-8"
-				j.Configuration.Load.FieldDelimiter = "\t"
-				hyphen := "-"
-				j.Configuration.Load.Quote = &hyphen
-				return j
-			}(),
-		},
-	}
-
-	for i, tc := range testCases {
-		loader := tc.dst.LoaderFrom(tc.src)
-		loader.JobID = tc.jobID
-		loader.Location = tc.location
-		tc.config.Src = tc.src
-		tc.config.Dst = tc.dst
-		loader.LoadConfig = tc.config
-		got, _ := loader.newJob()
-		checkJob(t, i, got, tc.want)
-
-		jc, err := bqToJobConfig(got.Configuration, c)
-		if err != nil {
-			t.Fatalf("#%d: %v", i, err)
-		}
-		diff := testutil.Diff(jc.(*LoadConfig), &loader.LoadConfig,
-			cmp.AllowUnexported(Table{}, Client{}),
-			cmpopts.IgnoreUnexported(ReaderSource{}))
-		if diff != "" {
-			t.Errorf("#%d: (got=-, want=+:\n%s", i, diff)
-		}
-	}
-}

+ 0 - 320
vendor/cloud.google.com/go/bigquery/nulls.go

@@ -1,320 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"bytes"
-	"encoding/json"
-	"fmt"
-	"reflect"
-	"strconv"
-	"time"
-
-	"cloud.google.com/go/civil"
-)
-
-// NullInt64 represents a BigQuery INT64 that may be NULL.
-type NullInt64 struct {
-	Int64 int64
-	Valid bool // Valid is true if Int64 is not NULL.
-}
-
-func (n NullInt64) String() string { return nullstr(n.Valid, n.Int64) }
-
-// NullString represents a BigQuery STRING that may be NULL.
-type NullString struct {
-	StringVal string
-	Valid     bool // Valid is true if StringVal is not NULL.
-}
-
-func (n NullString) String() string { return nullstr(n.Valid, n.StringVal) }
-
-// NullFloat64 represents a BigQuery FLOAT64 that may be NULL.
-type NullFloat64 struct {
-	Float64 float64
-	Valid   bool // Valid is true if Float64 is not NULL.
-}
-
-func (n NullFloat64) String() string { return nullstr(n.Valid, n.Float64) }
-
-// NullBool represents a BigQuery BOOL that may be NULL.
-type NullBool struct {
-	Bool  bool
-	Valid bool // Valid is true if Bool is not NULL.
-}
-
-func (n NullBool) String() string { return nullstr(n.Valid, n.Bool) }
-
-// NullTimestamp represents a BigQuery TIMESTAMP that may be null.
-type NullTimestamp struct {
-	Timestamp time.Time
-	Valid     bool // Valid is true if Time is not NULL.
-}
-
-func (n NullTimestamp) String() string { return nullstr(n.Valid, n.Timestamp) }
-
-// NullDate represents a BigQuery DATE that may be null.
-type NullDate struct {
-	Date  civil.Date
-	Valid bool // Valid is true if Date is not NULL.
-}
-
-func (n NullDate) String() string { return nullstr(n.Valid, n.Date) }
-
-// NullTime represents a BigQuery TIME that may be null.
-type NullTime struct {
-	Time  civil.Time
-	Valid bool // Valid is true if Time is not NULL.
-}
-
-func (n NullTime) String() string {
-	if !n.Valid {
-		return "<null>"
-	}
-	return CivilTimeString(n.Time)
-}
-
-// NullDateTime represents a BigQuery DATETIME that may be null.
-type NullDateTime struct {
-	DateTime civil.DateTime
-	Valid    bool // Valid is true if DateTime is not NULL.
-}
-
-func (n NullDateTime) String() string {
-	if !n.Valid {
-		return "<null>"
-	}
-	return CivilDateTimeString(n.DateTime)
-}
-
-// MarshalJSON converts the NullInt64 to JSON.
-func (n NullInt64) MarshalJSON() ([]byte, error) { return nulljson(n.Valid, n.Int64) }
-
-// MarshalJSON converts the NullFloat64 to JSON.
-func (n NullFloat64) MarshalJSON() ([]byte, error) { return nulljson(n.Valid, n.Float64) }
-
-// MarshalJSON converts the NullBool to JSON.
-func (n NullBool) MarshalJSON() ([]byte, error) { return nulljson(n.Valid, n.Bool) }
-
-// MarshalJSON converts the NullString to JSON.
-func (n NullString) MarshalJSON() ([]byte, error) { return nulljson(n.Valid, n.StringVal) }
-
-// MarshalJSON converts the NullTimestamp to JSON.
-func (n NullTimestamp) MarshalJSON() ([]byte, error) { return nulljson(n.Valid, n.Timestamp) }
-
-// MarshalJSON converts the NullDate to JSON.
-func (n NullDate) MarshalJSON() ([]byte, error) { return nulljson(n.Valid, n.Date) }
-
-// MarshalJSON converts the NullTime to JSON.
-func (n NullTime) MarshalJSON() ([]byte, error) {
-	if !n.Valid {
-		return jsonNull, nil
-	}
-	return []byte(`"` + CivilTimeString(n.Time) + `"`), nil
-}
-
-// MarshalJSON converts the NullDateTime to JSON.
-func (n NullDateTime) MarshalJSON() ([]byte, error) {
-	if !n.Valid {
-		return jsonNull, nil
-	}
-	return []byte(`"` + CivilDateTimeString(n.DateTime) + `"`), nil
-}
-
-func nullstr(valid bool, v interface{}) string {
-	if !valid {
-		return "NULL"
-	}
-	return fmt.Sprint(v)
-}
-
-var jsonNull = []byte("null")
-
-func nulljson(valid bool, v interface{}) ([]byte, error) {
-	if !valid {
-		return jsonNull, nil
-	}
-	return json.Marshal(v)
-}
-
-// UnmarshalJSON converts JSON into a NullInt64.
-func (n *NullInt64) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.Int64 = 0
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	if err := json.Unmarshal(b, &n.Int64); err != nil {
-		return err
-	}
-	n.Valid = true
-	return nil
-}
-
-// UnmarshalJSON converts JSON into a NullFloat64.
-func (n *NullFloat64) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.Float64 = 0
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	if err := json.Unmarshal(b, &n.Float64); err != nil {
-		return err
-	}
-	n.Valid = true
-	return nil
-}
-
-// UnmarshalJSON converts JSON into a NullBool.
-func (n *NullBool) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.Bool = false
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	if err := json.Unmarshal(b, &n.Bool); err != nil {
-		return err
-	}
-	n.Valid = true
-	return nil
-}
-
-// UnmarshalJSON converts JSON into a NullString.
-func (n *NullString) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.StringVal = ""
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	if err := json.Unmarshal(b, &n.StringVal); err != nil {
-		return err
-	}
-	n.Valid = true
-	return nil
-}
-
-// UnmarshalJSON converts JSON into a NullTimestamp.
-func (n *NullTimestamp) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.Timestamp = time.Time{}
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	if err := json.Unmarshal(b, &n.Timestamp); err != nil {
-		return err
-	}
-	n.Valid = true
-	return nil
-}
-
-// UnmarshalJSON converts JSON into a NullDate.
-func (n *NullDate) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.Date = civil.Date{}
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	if err := json.Unmarshal(b, &n.Date); err != nil {
-		return err
-	}
-	n.Valid = true
-	return nil
-}
-
-// UnmarshalJSON converts JSON into a NullTime.
-func (n *NullTime) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.Time = civil.Time{}
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	s, err := strconv.Unquote(string(b))
-	if err != nil {
-		return err
-	}
-
-	t, err := civil.ParseTime(s)
-	if err != nil {
-		return err
-	}
-	n.Time = t
-
-	n.Valid = true
-	return nil
-}
-
-// UnmarshalJSON converts JSON into a NullDateTime.
-func (n *NullDateTime) UnmarshalJSON(b []byte) error {
-	n.Valid = false
-	n.DateTime = civil.DateTime{}
-	if bytes.Equal(b, jsonNull) {
-		return nil
-	}
-
-	s, err := strconv.Unquote(string(b))
-	if err != nil {
-		return err
-	}
-
-	dt, err := parseCivilDateTime(s)
-	if err != nil {
-		return err
-	}
-	n.DateTime = dt
-
-	n.Valid = true
-	return nil
-}
-
-var (
-	typeOfNullInt64     = reflect.TypeOf(NullInt64{})
-	typeOfNullFloat64   = reflect.TypeOf(NullFloat64{})
-	typeOfNullBool      = reflect.TypeOf(NullBool{})
-	typeOfNullString    = reflect.TypeOf(NullString{})
-	typeOfNullTimestamp = reflect.TypeOf(NullTimestamp{})
-	typeOfNullDate      = reflect.TypeOf(NullDate{})
-	typeOfNullTime      = reflect.TypeOf(NullTime{})
-	typeOfNullDateTime  = reflect.TypeOf(NullDateTime{})
-)
-
-func nullableFieldType(t reflect.Type) FieldType {
-	switch t {
-	case typeOfNullInt64:
-		return IntegerFieldType
-	case typeOfNullFloat64:
-		return FloatFieldType
-	case typeOfNullBool:
-		return BooleanFieldType
-	case typeOfNullString:
-		return StringFieldType
-	case typeOfNullTimestamp:
-		return TimestampFieldType
-	case typeOfNullDate:
-		return DateFieldType
-	case typeOfNullTime:
-		return TimeFieldType
-	case typeOfNullDateTime:
-		return DateTimeFieldType
-	default:
-		return ""
-	}
-}

+ 0 - 73
vendor/cloud.google.com/go/bigquery/nulls_test.go

@@ -1,73 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"encoding/json"
-	"reflect"
-	"testing"
-
-	"cloud.google.com/go/civil"
-	"cloud.google.com/go/internal/testutil"
-)
-
-var (
-	nullsTestTime     = civil.Time{Hour: 7, Minute: 50, Second: 22, Nanosecond: 1000}
-	nullsTestDateTime = civil.DateTime{Date: civil.Date{Year: 2016, Month: 11, Day: 5}, Time: nullsTestTime}
-)
-
-func TestNullsJSON(t *testing.T) {
-	for _, test := range []struct {
-		in   interface{}
-		want string
-	}{
-		{&NullInt64{Valid: true, Int64: 3}, `3`},
-		{&NullFloat64{Valid: true, Float64: 3.14}, `3.14`},
-		{&NullBool{Valid: true, Bool: true}, `true`},
-		{&NullString{Valid: true, StringVal: "foo"}, `"foo"`},
-		{&NullTimestamp{Valid: true, Timestamp: testTimestamp}, `"2016-11-05T07:50:22.000000008Z"`},
-		{&NullDate{Valid: true, Date: testDate}, `"2016-11-05"`},
-		{&NullTime{Valid: true, Time: nullsTestTime}, `"07:50:22.000001"`},
-		{&NullDateTime{Valid: true, DateTime: nullsTestDateTime}, `"2016-11-05 07:50:22.000001"`},
-
-		{&NullInt64{}, `null`},
-		{&NullFloat64{}, `null`},
-		{&NullBool{}, `null`},
-		{&NullString{}, `null`},
-		{&NullTimestamp{}, `null`},
-		{&NullDate{}, `null`},
-		{&NullTime{}, `null`},
-		{&NullDateTime{}, `null`},
-	} {
-		bytes, err := json.Marshal(test.in)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if got, want := string(bytes), test.want; got != want {
-			t.Errorf("%#v: got %s, want %s", test.in, got, want)
-		}
-
-		typ := reflect.Indirect(reflect.ValueOf(test.in)).Type()
-		value := reflect.New(typ).Interface()
-		err = json.Unmarshal(bytes, value)
-		if err != nil {
-			t.Fatal(err)
-		}
-
-		if !testutil.Equal(value, test.in) {
-			t.Errorf("%#v: got %#v, want %#v", test.in, value, test.in)
-		}
-	}
-}

+ 0 - 38
vendor/cloud.google.com/go/bigquery/oc_test.go

@@ -1,38 +0,0 @@
-// Copyright 2018 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
-//
-//     http://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.
-
-package bigquery
-
-import (
-	"context"
-	"testing"
-
-	"cloud.google.com/go/internal/testutil"
-)
-
-func TestOCTracing(t *testing.T) {
-	ctx := context.Background()
-	client := getClient(t)
-	defer client.Close()
-
-	te := testutil.NewTestExporter()
-	defer te.Unregister()
-
-	q := client.Query("select *")
-	q.Run(ctx) // Doesn't matter if we get an error; span should be created either way
-
-	if len(te.Spans) == 0 {
-		t.Fatalf("Expected some spans to be created, but got %d", 0)
-	}
-}

+ 0 - 360
vendor/cloud.google.com/go/bigquery/params.go

@@ -1,360 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"encoding/base64"
-	"errors"
-	"fmt"
-	"math/big"
-	"reflect"
-	"regexp"
-	"time"
-
-	"cloud.google.com/go/civil"
-	"cloud.google.com/go/internal/fields"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-var (
-	// See https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp-type.
-	timestampFormat = "2006-01-02 15:04:05.999999-07:00"
-
-	// See https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#schema.fields.name
-	validFieldName = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]{0,127}$")
-)
-
-const nullableTagOption = "nullable"
-
-func bqTagParser(t reflect.StructTag) (name string, keep bool, other interface{}, err error) {
-	name, keep, opts, err := fields.ParseStandardTag("bigquery", t)
-	if err != nil {
-		return "", false, nil, err
-	}
-	if name != "" && !validFieldName.MatchString(name) {
-		return "", false, nil, errInvalidFieldName
-	}
-	for _, opt := range opts {
-		if opt != nullableTagOption {
-			return "", false, nil, fmt.Errorf(
-				"bigquery: invalid tag option %q. The only valid option is %q",
-				opt, nullableTagOption)
-		}
-	}
-	return name, keep, opts, nil
-}
-
-var fieldCache = fields.NewCache(bqTagParser, nil, nil)
-
-var (
-	int64ParamType     = &bq.QueryParameterType{Type: "INT64"}
-	float64ParamType   = &bq.QueryParameterType{Type: "FLOAT64"}
-	boolParamType      = &bq.QueryParameterType{Type: "BOOL"}
-	stringParamType    = &bq.QueryParameterType{Type: "STRING"}
-	bytesParamType     = &bq.QueryParameterType{Type: "BYTES"}
-	dateParamType      = &bq.QueryParameterType{Type: "DATE"}
-	timeParamType      = &bq.QueryParameterType{Type: "TIME"}
-	dateTimeParamType  = &bq.QueryParameterType{Type: "DATETIME"}
-	timestampParamType = &bq.QueryParameterType{Type: "TIMESTAMP"}
-	numericParamType   = &bq.QueryParameterType{Type: "NUMERIC"}
-)
-
-var (
-	typeOfDate     = reflect.TypeOf(civil.Date{})
-	typeOfTime     = reflect.TypeOf(civil.Time{})
-	typeOfDateTime = reflect.TypeOf(civil.DateTime{})
-	typeOfGoTime   = reflect.TypeOf(time.Time{})
-	typeOfRat      = reflect.TypeOf(&big.Rat{})
-)
-
-// A QueryParameter is a parameter to a query.
-type QueryParameter struct {
-	// Name is used for named parameter mode.
-	// It must match the name in the query case-insensitively.
-	Name string
-
-	// Value is the value of the parameter.
-	//
-	// When you create a QueryParameter to send to BigQuery, the following Go types
-	// are supported, with their corresponding Bigquery types:
-	// int, int8, int16, int32, int64, uint8, uint16, uint32: INT64
-	//   Note that uint, uint64 and uintptr are not supported, because
-	//   they may contain values that cannot fit into a 64-bit signed integer.
-	// float32, float64: FLOAT64
-	// bool: BOOL
-	// string: STRING
-	// []byte: BYTES
-	// time.Time: TIMESTAMP
-	// *big.Rat: NUMERIC
-	// Arrays and slices of the above.
-	// Structs of the above. Only the exported fields are used.
-	//
-	// When a QueryParameter is returned inside a QueryConfig from a call to
-	// Job.Config:
-	// Integers are of type int64.
-	// Floating-point values are of type float64.
-	// Arrays are of type []interface{}, regardless of the array element type.
-	// Structs are of type map[string]interface{}.
-	Value interface{}
-}
-
-func (p QueryParameter) toBQ() (*bq.QueryParameter, error) {
-	pv, err := paramValue(reflect.ValueOf(p.Value))
-	if err != nil {
-		return nil, err
-	}
-	pt, err := paramType(reflect.TypeOf(p.Value))
-	if err != nil {
-		return nil, err
-	}
-	return &bq.QueryParameter{
-		Name:           p.Name,
-		ParameterValue: &pv,
-		ParameterType:  pt,
-	}, nil
-}
-
-func paramType(t reflect.Type) (*bq.QueryParameterType, error) {
-	if t == nil {
-		return nil, errors.New("bigquery: nil parameter")
-	}
-	switch t {
-	case typeOfDate:
-		return dateParamType, nil
-	case typeOfTime:
-		return timeParamType, nil
-	case typeOfDateTime:
-		return dateTimeParamType, nil
-	case typeOfGoTime:
-		return timestampParamType, nil
-	case typeOfRat:
-		return numericParamType, nil
-	}
-	switch t.Kind() {
-	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint8, reflect.Uint16, reflect.Uint32:
-		return int64ParamType, nil
-
-	case reflect.Float32, reflect.Float64:
-		return float64ParamType, nil
-
-	case reflect.Bool:
-		return boolParamType, nil
-
-	case reflect.String:
-		return stringParamType, nil
-
-	case reflect.Slice:
-		if t.Elem().Kind() == reflect.Uint8 {
-			return bytesParamType, nil
-		}
-		fallthrough
-
-	case reflect.Array:
-		et, err := paramType(t.Elem())
-		if err != nil {
-			return nil, err
-		}
-		return &bq.QueryParameterType{Type: "ARRAY", ArrayType: et}, nil
-
-	case reflect.Ptr:
-		if t.Elem().Kind() != reflect.Struct {
-			break
-		}
-		t = t.Elem()
-		fallthrough
-
-	case reflect.Struct:
-		var fts []*bq.QueryParameterTypeStructTypes
-		fields, err := fieldCache.Fields(t)
-		if err != nil {
-			return nil, err
-		}
-		for _, f := range fields {
-			pt, err := paramType(f.Type)
-			if err != nil {
-				return nil, err
-			}
-			fts = append(fts, &bq.QueryParameterTypeStructTypes{
-				Name: f.Name,
-				Type: pt,
-			})
-		}
-		return &bq.QueryParameterType{Type: "STRUCT", StructTypes: fts}, nil
-	}
-	return nil, fmt.Errorf("bigquery: Go type %s cannot be represented as a parameter type", t)
-}
-
-func paramValue(v reflect.Value) (bq.QueryParameterValue, error) {
-	var res bq.QueryParameterValue
-	if !v.IsValid() {
-		return res, errors.New("bigquery: nil parameter")
-	}
-	t := v.Type()
-	switch t {
-	case typeOfDate:
-		res.Value = v.Interface().(civil.Date).String()
-		return res, nil
-
-	case typeOfTime:
-		// civil.Time has nanosecond resolution, but BigQuery TIME only microsecond.
-		// (If we send nanoseconds, then when we try to read the result we get "query job
-		// missing destination table").
-		res.Value = CivilTimeString(v.Interface().(civil.Time))
-		return res, nil
-
-	case typeOfDateTime:
-		res.Value = CivilDateTimeString(v.Interface().(civil.DateTime))
-		return res, nil
-
-	case typeOfGoTime:
-		res.Value = v.Interface().(time.Time).Format(timestampFormat)
-		return res, nil
-
-	case typeOfRat:
-		res.Value = NumericString(v.Interface().(*big.Rat))
-		return res, nil
-	}
-	switch t.Kind() {
-	case reflect.Slice:
-		if t.Elem().Kind() == reflect.Uint8 {
-			res.Value = base64.StdEncoding.EncodeToString(v.Interface().([]byte))
-			return res, nil
-		}
-		fallthrough
-
-	case reflect.Array:
-		var vals []*bq.QueryParameterValue
-		for i := 0; i < v.Len(); i++ {
-			val, err := paramValue(v.Index(i))
-			if err != nil {
-				return bq.QueryParameterValue{}, err
-			}
-			vals = append(vals, &val)
-		}
-		return bq.QueryParameterValue{ArrayValues: vals}, nil
-
-	case reflect.Ptr:
-		if t.Elem().Kind() != reflect.Struct {
-			return res, fmt.Errorf("bigquery: Go type %s cannot be represented as a parameter value", t)
-		}
-		t = t.Elem()
-		v = v.Elem()
-		if !v.IsValid() {
-			// nil pointer becomes empty value
-			return res, nil
-		}
-		fallthrough
-
-	case reflect.Struct:
-		fields, err := fieldCache.Fields(t)
-		if err != nil {
-			return bq.QueryParameterValue{}, err
-		}
-		res.StructValues = map[string]bq.QueryParameterValue{}
-		for _, f := range fields {
-			fv := v.FieldByIndex(f.Index)
-			fp, err := paramValue(fv)
-			if err != nil {
-				return bq.QueryParameterValue{}, err
-			}
-			res.StructValues[f.Name] = fp
-		}
-		return res, nil
-	}
-	// None of the above: assume a scalar type. (If it's not a valid type,
-	// paramType will catch the error.)
-	res.Value = fmt.Sprint(v.Interface())
-	// Ensure empty string values are sent.
-	if res.Value == "" {
-		res.ForceSendFields = append(res.ForceSendFields, "Value")
-	}
-	return res, nil
-}
-
-func bqToQueryParameter(q *bq.QueryParameter) (QueryParameter, error) {
-	p := QueryParameter{Name: q.Name}
-	val, err := convertParamValue(q.ParameterValue, q.ParameterType)
-	if err != nil {
-		return QueryParameter{}, err
-	}
-	p.Value = val
-	return p, nil
-}
-
-var paramTypeToFieldType = map[string]FieldType{
-	int64ParamType.Type:   IntegerFieldType,
-	float64ParamType.Type: FloatFieldType,
-	boolParamType.Type:    BooleanFieldType,
-	stringParamType.Type:  StringFieldType,
-	bytesParamType.Type:   BytesFieldType,
-	dateParamType.Type:    DateFieldType,
-	timeParamType.Type:    TimeFieldType,
-	numericParamType.Type: NumericFieldType,
-}
-
-// Convert a parameter value from the service to a Go value. This is similar to, but
-// not quite the same as, converting data values.
-func convertParamValue(qval *bq.QueryParameterValue, qtype *bq.QueryParameterType) (interface{}, error) {
-	switch qtype.Type {
-	case "ARRAY":
-		if qval == nil {
-			return []interface{}(nil), nil
-		}
-		return convertParamArray(qval.ArrayValues, qtype.ArrayType)
-	case "STRUCT":
-		if qval == nil {
-			return map[string]interface{}(nil), nil
-		}
-		return convertParamStruct(qval.StructValues, qtype.StructTypes)
-	case "TIMESTAMP":
-		return time.Parse(timestampFormat, qval.Value)
-	case "DATETIME":
-		return parseCivilDateTime(qval.Value)
-	default:
-		return convertBasicType(qval.Value, paramTypeToFieldType[qtype.Type])
-	}
-}
-
-// convertParamArray converts a query parameter array value to a Go value. It
-// always returns a []interface{}.
-func convertParamArray(elVals []*bq.QueryParameterValue, elType *bq.QueryParameterType) ([]interface{}, error) {
-	var vals []interface{}
-	for _, el := range elVals {
-		val, err := convertParamValue(el, elType)
-		if err != nil {
-			return nil, err
-		}
-		vals = append(vals, val)
-	}
-	return vals, nil
-}
-
-// convertParamStruct converts a query parameter struct value into a Go value. It
-// always returns a map[string]interface{}.
-func convertParamStruct(sVals map[string]bq.QueryParameterValue, sTypes []*bq.QueryParameterTypeStructTypes) (map[string]interface{}, error) {
-	vals := map[string]interface{}{}
-	for _, st := range sTypes {
-		if sv, ok := sVals[st.Name]; ok {
-			val, err := convertParamValue(&sv, st.Type)
-			if err != nil {
-				return nil, err
-			}
-			vals[st.Name] = val
-		} else {
-			vals[st.Name] = nil
-		}
-	}
-	return vals, nil
-}

+ 0 - 385
vendor/cloud.google.com/go/bigquery/params_test.go

@@ -1,385 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"math"
-	"math/big"
-	"reflect"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/civil"
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-var scalarTests = []struct {
-	val      interface{}            // The Go value
-	wantVal  string                 // paramValue's desired output
-	wantType *bq.QueryParameterType // paramType's desired output
-}{
-	{int64(0), "0", int64ParamType},
-	{3.14, "3.14", float64ParamType},
-	{3.14159e-87, "3.14159e-87", float64ParamType},
-	{true, "true", boolParamType},
-	{"string", "string", stringParamType},
-	{"\u65e5\u672c\u8a9e\n", "\u65e5\u672c\u8a9e\n", stringParamType},
-	{math.NaN(), "NaN", float64ParamType},
-	{[]byte("foo"), "Zm9v", bytesParamType}, // base64 encoding of "foo"
-	{time.Date(2016, 3, 20, 4, 22, 9, 5000, time.FixedZone("neg1-2", -3720)),
-		"2016-03-20 04:22:09.000005-01:02",
-		timestampParamType},
-	{civil.Date{Year: 2016, Month: 3, Day: 20}, "2016-03-20", dateParamType},
-	{civil.Time{Hour: 4, Minute: 5, Second: 6, Nanosecond: 789000000}, "04:05:06.789000", timeParamType},
-	{civil.DateTime{Date: civil.Date{Year: 2016, Month: 3, Day: 20}, Time: civil.Time{Hour: 4, Minute: 5, Second: 6, Nanosecond: 789000000}},
-		"2016-03-20 04:05:06.789000",
-		dateTimeParamType},
-	{big.NewRat(12345, 1000), "12.345000000", numericParamType},
-}
-
-type (
-	S1 struct {
-		A int
-		B *S2
-		C bool
-	}
-	S2 struct {
-		D string
-	}
-)
-
-var (
-	s1 = S1{
-		A: 1,
-		B: &S2{D: "s"},
-		C: true,
-	}
-
-	s1ParamType = &bq.QueryParameterType{
-		Type: "STRUCT",
-		StructTypes: []*bq.QueryParameterTypeStructTypes{
-			{Name: "A", Type: int64ParamType},
-			{Name: "B", Type: &bq.QueryParameterType{
-				Type: "STRUCT",
-				StructTypes: []*bq.QueryParameterTypeStructTypes{
-					{Name: "D", Type: stringParamType},
-				},
-			}},
-			{Name: "C", Type: boolParamType},
-		},
-	}
-
-	s1ParamValue = bq.QueryParameterValue{
-		StructValues: map[string]bq.QueryParameterValue{
-			"A": sval("1"),
-			"B": {
-				StructValues: map[string]bq.QueryParameterValue{
-					"D": sval("s"),
-				},
-			},
-			"C": sval("true"),
-		},
-	}
-
-	s1ParamReturnValue = map[string]interface{}{
-		"A": int64(1),
-		"B": map[string]interface{}{"D": "s"},
-		"C": true,
-	}
-)
-
-func sval(s string) bq.QueryParameterValue {
-	return bq.QueryParameterValue{Value: s}
-}
-
-func TestParamValueScalar(t *testing.T) {
-	for _, test := range scalarTests {
-		got, err := paramValue(reflect.ValueOf(test.val))
-		if err != nil {
-			t.Errorf("%v: got %v, want nil", test.val, err)
-			continue
-		}
-		want := sval(test.wantVal)
-		if !testutil.Equal(got, want) {
-			t.Errorf("%v:\ngot  %+v\nwant %+v", test.val, got, want)
-		}
-	}
-}
-
-func TestParamValueArray(t *testing.T) {
-	qpv := bq.QueryParameterValue{ArrayValues: []*bq.QueryParameterValue{
-		{Value: "1"},
-		{Value: "2"},
-	},
-	}
-	for _, test := range []struct {
-		val  interface{}
-		want bq.QueryParameterValue
-	}{
-		{[]int(nil), bq.QueryParameterValue{}},
-		{[]int{}, bq.QueryParameterValue{}},
-		{[]int{1, 2}, qpv},
-		{[2]int{1, 2}, qpv},
-	} {
-		got, err := paramValue(reflect.ValueOf(test.val))
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(got, test.want) {
-			t.Errorf("%#v:\ngot  %+v\nwant %+v", test.val, got, test.want)
-		}
-	}
-}
-
-func TestParamValueStruct(t *testing.T) {
-	got, err := paramValue(reflect.ValueOf(s1))
-	if err != nil {
-		t.Fatal(err)
-	}
-	if !testutil.Equal(got, s1ParamValue) {
-		t.Errorf("got  %+v\nwant %+v", got, s1ParamValue)
-	}
-}
-
-func TestParamValueErrors(t *testing.T) {
-	// paramValue lets a few invalid types through, but paramType catches them.
-	// Since we never call one without the other that's fine.
-	for _, val := range []interface{}{nil, new([]int)} {
-		_, err := paramValue(reflect.ValueOf(val))
-		if err == nil {
-			t.Errorf("%v (%T): got nil, want error", val, val)
-		}
-	}
-}
-
-func TestParamType(t *testing.T) {
-	for _, test := range scalarTests {
-		got, err := paramType(reflect.TypeOf(test.val))
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(got, test.wantType) {
-			t.Errorf("%v (%T): got %v, want %v", test.val, test.val, got, test.wantType)
-		}
-	}
-	for _, test := range []struct {
-		val  interface{}
-		want *bq.QueryParameterType
-	}{
-		{uint32(32767), int64ParamType},
-		{[]byte("foo"), bytesParamType},
-		{[]int{}, &bq.QueryParameterType{Type: "ARRAY", ArrayType: int64ParamType}},
-		{[3]bool{}, &bq.QueryParameterType{Type: "ARRAY", ArrayType: boolParamType}},
-		{S1{}, s1ParamType},
-	} {
-		got, err := paramType(reflect.TypeOf(test.val))
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(got, test.want) {
-			t.Errorf("%v (%T): got %v, want %v", test.val, test.val, got, test.want)
-		}
-	}
-}
-
-func TestParamTypeErrors(t *testing.T) {
-	for _, val := range []interface{}{
-		nil, uint(0), new([]int), make(chan int),
-	} {
-		_, err := paramType(reflect.TypeOf(val))
-		if err == nil {
-			t.Errorf("%v (%T): got nil, want error", val, val)
-		}
-	}
-}
-
-func TestConvertParamValue(t *testing.T) {
-	// Scalars.
-	for _, test := range scalarTests {
-		pval, err := paramValue(reflect.ValueOf(test.val))
-		if err != nil {
-			t.Fatal(err)
-		}
-		ptype, err := paramType(reflect.TypeOf(test.val))
-		if err != nil {
-			t.Fatal(err)
-		}
-		got, err := convertParamValue(&pval, ptype)
-		if err != nil {
-			t.Fatalf("convertParamValue(%+v, %+v): %v", pval, ptype, err)
-		}
-		if !testutil.Equal(got, test.val) {
-			t.Errorf("%#v: got %#v", test.val, got)
-		}
-	}
-	// Arrays.
-	for _, test := range []struct {
-		pval *bq.QueryParameterValue
-		want []interface{}
-	}{
-		{
-			&bq.QueryParameterValue{},
-			nil,
-		},
-		{
-			&bq.QueryParameterValue{
-				ArrayValues: []*bq.QueryParameterValue{{Value: "1"}, {Value: "2"}},
-			},
-			[]interface{}{int64(1), int64(2)},
-		},
-	} {
-		ptype := &bq.QueryParameterType{Type: "ARRAY", ArrayType: int64ParamType}
-		got, err := convertParamValue(test.pval, ptype)
-		if err != nil {
-			t.Fatalf("%+v: %v", test.pval, err)
-		}
-		if !testutil.Equal(got, test.want) {
-			t.Errorf("%+v: got %+v, want %+v", test.pval, got, test.want)
-		}
-	}
-	// Structs.
-	got, err := convertParamValue(&s1ParamValue, s1ParamType)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if !testutil.Equal(got, s1ParamReturnValue) {
-		t.Errorf("got %+v, want %+v", got, s1ParamReturnValue)
-	}
-}
-
-func TestIntegration_ScalarParam(t *testing.T) {
-	roundToMicros := cmp.Transformer("RoundToMicros",
-		func(t time.Time) time.Time { return t.Round(time.Microsecond) })
-	c := getClient(t)
-	for _, test := range scalarTests {
-		gotData, gotParam, err := paramRoundTrip(c, test.val)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(gotData, test.val, roundToMicros) {
-			t.Errorf("\ngot  %#v (%T)\nwant %#v (%T)", gotData, gotData, test.val, test.val)
-		}
-		if !testutil.Equal(gotParam, test.val, roundToMicros) {
-			t.Errorf("\ngot  %#v (%T)\nwant %#v (%T)", gotParam, gotParam, test.val, test.val)
-		}
-	}
-}
-
-func TestIntegration_OtherParam(t *testing.T) {
-	c := getClient(t)
-	for _, test := range []struct {
-		val       interface{}
-		wantData  interface{}
-		wantParam interface{}
-	}{
-		{[]int(nil), []Value(nil), []interface{}(nil)},
-		{[]int{}, []Value(nil), []interface{}(nil)},
-		{
-			[]int{1, 2},
-			[]Value{int64(1), int64(2)},
-			[]interface{}{int64(1), int64(2)},
-		},
-		{
-			[3]int{1, 2, 3},
-			[]Value{int64(1), int64(2), int64(3)},
-			[]interface{}{int64(1), int64(2), int64(3)},
-		},
-		{
-			S1{},
-			[]Value{int64(0), nil, false},
-			map[string]interface{}{
-				"A": int64(0),
-				"B": nil,
-				"C": false,
-			},
-		},
-		{
-			s1,
-			[]Value{int64(1), []Value{"s"}, true},
-			s1ParamReturnValue,
-		},
-	} {
-		gotData, gotParam, err := paramRoundTrip(c, test.val)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !testutil.Equal(gotData, test.wantData) {
-			t.Errorf("%#v:\ngot  %#v (%T)\nwant %#v (%T)",
-				test.val, gotData, gotData, test.wantData, test.wantData)
-		}
-		if !testutil.Equal(gotParam, test.wantParam) {
-			t.Errorf("%#v:\ngot  %#v (%T)\nwant %#v (%T)",
-				test.val, gotParam, gotParam, test.wantParam, test.wantParam)
-		}
-	}
-}
-
-// paramRoundTrip passes x as a query parameter to BigQuery. It returns
-// the resulting data value from running the query and the parameter value from
-// the returned job configuration.
-func paramRoundTrip(c *Client, x interface{}) (data Value, param interface{}, err error) {
-	ctx := context.Background()
-	q := c.Query("select ?")
-	q.Parameters = []QueryParameter{{Value: x}}
-	job, err := q.Run(ctx)
-	if err != nil {
-		return nil, nil, err
-	}
-	it, err := job.Read(ctx)
-	if err != nil {
-		return nil, nil, err
-	}
-	var val []Value
-	err = it.Next(&val)
-	if err != nil {
-		return nil, nil, err
-	}
-	if len(val) != 1 {
-		return nil, nil, errors.New("wrong number of values")
-	}
-	conf, err := job.Config()
-	if err != nil {
-		return nil, nil, err
-	}
-	return val[0], conf.(*QueryConfig).Parameters[0].Value, nil
-}
-
-func TestQueryParameter_toBQ(t *testing.T) {
-	tests := []struct {
-		in   QueryParameter
-		want []string
-	}{
-		{
-			in:   QueryParameter{Name: "name", Value: ""},
-			want: []string{"Value"},
-		},
-	}
-
-	for _, test := range tests {
-		q, err := test.in.toBQ()
-		if err != nil {
-			t.Fatalf("expected no error, got %v", err)
-		}
-
-		got := q.ParameterValue.ForceSendFields
-		if !cmp.Equal(test.want, got) {
-			t.Fatalf("want %v, got %v", test.want, got)
-		}
-	}
-}

+ 0 - 328
vendor/cloud.google.com/go/bigquery/query.go

@@ -1,328 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-
-	"cloud.google.com/go/internal/trace"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// QueryConfig holds the configuration for a query job.
-type QueryConfig struct {
-	// Dst is the table into which the results of the query will be written.
-	// If this field is nil, a temporary table will be created.
-	Dst *Table
-
-	// The query to execute. See https://cloud.google.com/bigquery/query-reference for details.
-	Q string
-
-	// DefaultProjectID and DefaultDatasetID specify the dataset to use for unqualified table names in the query.
-	// If DefaultProjectID is set, DefaultDatasetID must also be set.
-	DefaultProjectID string
-	DefaultDatasetID string
-
-	// TableDefinitions describes data sources outside of BigQuery.
-	// The map keys may be used as table names in the query string.
-	//
-	// When a QueryConfig is returned from Job.Config, the map values
-	// are always of type *ExternalDataConfig.
-	TableDefinitions map[string]ExternalData
-
-	// CreateDisposition specifies the circumstances under which the destination table will be created.
-	// The default is CreateIfNeeded.
-	CreateDisposition TableCreateDisposition
-
-	// WriteDisposition specifies how existing data in the destination table is treated.
-	// The default is WriteEmpty.
-	WriteDisposition TableWriteDisposition
-
-	// DisableQueryCache prevents results being fetched from the query cache.
-	// If this field is false, results are fetched from the cache if they are available.
-	// The query cache is a best-effort cache that is flushed whenever tables in the query are modified.
-	// Cached results are only available when TableID is unspecified in the query's destination Table.
-	// For more information, see https://cloud.google.com/bigquery/querying-data#querycaching
-	DisableQueryCache bool
-
-	// DisableFlattenedResults prevents results being flattened.
-	// If this field is false, results from nested and repeated fields are flattened.
-	// DisableFlattenedResults implies AllowLargeResults
-	// For more information, see https://cloud.google.com/bigquery/docs/data#nested
-	DisableFlattenedResults bool
-
-	// AllowLargeResults allows the query to produce arbitrarily large result tables.
-	// The destination must be a table.
-	// When using this option, queries will take longer to execute, even if the result set is small.
-	// For additional limitations, see https://cloud.google.com/bigquery/querying-data#largequeryresults
-	AllowLargeResults bool
-
-	// Priority specifies the priority with which to schedule the query.
-	// The default priority is InteractivePriority.
-	// For more information, see https://cloud.google.com/bigquery/querying-data#batchqueries
-	Priority QueryPriority
-
-	// MaxBillingTier sets the maximum billing tier for a Query.
-	// Queries that have resource usage beyond this tier will fail (without
-	// incurring a charge). If this field is zero, the project default will be used.
-	MaxBillingTier int
-
-	// MaxBytesBilled limits the number of bytes billed for
-	// this job.  Queries that would exceed this limit will fail (without incurring
-	// a charge).
-	// If this field is less than 1, the project default will be
-	// used.
-	MaxBytesBilled int64
-
-	// UseStandardSQL causes the query to use standard SQL. The default.
-	// Deprecated: use UseLegacySQL.
-	UseStandardSQL bool
-
-	// UseLegacySQL causes the query to use legacy SQL.
-	UseLegacySQL bool
-
-	// Parameters is a list of query parameters. The presence of parameters
-	// implies the use of standard SQL.
-	// If the query uses positional syntax ("?"), then no parameter may have a name.
-	// If the query uses named syntax ("@p"), then all parameters must have names.
-	// It is illegal to mix positional and named syntax.
-	Parameters []QueryParameter
-
-	// TimePartitioning specifies time-based partitioning
-	// for the destination table.
-	TimePartitioning *TimePartitioning
-
-	// Clustering specifies the data clustering configuration for the destination table.
-	Clustering *Clustering
-
-	// The labels associated with this job.
-	Labels map[string]string
-
-	// If true, don't actually run this job. A valid query will return a mostly
-	// empty response with some processing statistics, while an invalid query will
-	// return the same error it would if it wasn't a dry run.
-	//
-	// Query.Read will fail with dry-run queries. Call Query.Run instead, and then
-	// call LastStatus on the returned job to get statistics. Calling Status on a
-	// dry-run job will fail.
-	DryRun bool
-
-	// Custom encryption configuration (e.g., Cloud KMS keys).
-	DestinationEncryptionConfig *EncryptionConfig
-
-	// Allows the schema of the destination table to be updated as a side effect of
-	// the query job.
-	SchemaUpdateOptions []string
-}
-
-func (qc *QueryConfig) toBQ() (*bq.JobConfiguration, error) {
-	qconf := &bq.JobConfigurationQuery{
-		Query:                              qc.Q,
-		CreateDisposition:                  string(qc.CreateDisposition),
-		WriteDisposition:                   string(qc.WriteDisposition),
-		AllowLargeResults:                  qc.AllowLargeResults,
-		Priority:                           string(qc.Priority),
-		MaximumBytesBilled:                 qc.MaxBytesBilled,
-		TimePartitioning:                   qc.TimePartitioning.toBQ(),
-		Clustering:                         qc.Clustering.toBQ(),
-		DestinationEncryptionConfiguration: qc.DestinationEncryptionConfig.toBQ(),
-		SchemaUpdateOptions:                qc.SchemaUpdateOptions,
-	}
-	if len(qc.TableDefinitions) > 0 {
-		qconf.TableDefinitions = make(map[string]bq.ExternalDataConfiguration)
-	}
-	for name, data := range qc.TableDefinitions {
-		qconf.TableDefinitions[name] = data.toBQ()
-	}
-	if qc.DefaultProjectID != "" || qc.DefaultDatasetID != "" {
-		qconf.DefaultDataset = &bq.DatasetReference{
-			DatasetId: qc.DefaultDatasetID,
-			ProjectId: qc.DefaultProjectID,
-		}
-	}
-	if tier := int64(qc.MaxBillingTier); tier > 0 {
-		qconf.MaximumBillingTier = &tier
-	}
-	f := false
-	if qc.DisableQueryCache {
-		qconf.UseQueryCache = &f
-	}
-	if qc.DisableFlattenedResults {
-		qconf.FlattenResults = &f
-		// DisableFlattenResults implies AllowLargeResults.
-		qconf.AllowLargeResults = true
-	}
-	if qc.UseStandardSQL && qc.UseLegacySQL {
-		return nil, errors.New("bigquery: cannot provide both UseStandardSQL and UseLegacySQL")
-	}
-	if len(qc.Parameters) > 0 && qc.UseLegacySQL {
-		return nil, errors.New("bigquery: cannot provide both Parameters (implying standard SQL) and UseLegacySQL")
-	}
-	ptrue := true
-	pfalse := false
-	if qc.UseLegacySQL {
-		qconf.UseLegacySql = &ptrue
-	} else {
-		qconf.UseLegacySql = &pfalse
-	}
-	if qc.Dst != nil && !qc.Dst.implicitTable() {
-		qconf.DestinationTable = qc.Dst.toBQ()
-	}
-	for _, p := range qc.Parameters {
-		qp, err := p.toBQ()
-		if err != nil {
-			return nil, err
-		}
-		qconf.QueryParameters = append(qconf.QueryParameters, qp)
-	}
-	return &bq.JobConfiguration{
-		Labels: qc.Labels,
-		DryRun: qc.DryRun,
-		Query:  qconf,
-	}, nil
-}
-
-func bqToQueryConfig(q *bq.JobConfiguration, c *Client) (*QueryConfig, error) {
-	qq := q.Query
-	qc := &QueryConfig{
-		Labels:                      q.Labels,
-		DryRun:                      q.DryRun,
-		Q:                           qq.Query,
-		CreateDisposition:           TableCreateDisposition(qq.CreateDisposition),
-		WriteDisposition:            TableWriteDisposition(qq.WriteDisposition),
-		AllowLargeResults:           qq.AllowLargeResults,
-		Priority:                    QueryPriority(qq.Priority),
-		MaxBytesBilled:              qq.MaximumBytesBilled,
-		UseLegacySQL:                qq.UseLegacySql == nil || *qq.UseLegacySql,
-		TimePartitioning:            bqToTimePartitioning(qq.TimePartitioning),
-		Clustering:                  bqToClustering(qq.Clustering),
-		DestinationEncryptionConfig: bqToEncryptionConfig(qq.DestinationEncryptionConfiguration),
-		SchemaUpdateOptions:         qq.SchemaUpdateOptions,
-	}
-	qc.UseStandardSQL = !qc.UseLegacySQL
-
-	if len(qq.TableDefinitions) > 0 {
-		qc.TableDefinitions = make(map[string]ExternalData)
-	}
-	for name, qedc := range qq.TableDefinitions {
-		edc, err := bqToExternalDataConfig(&qedc)
-		if err != nil {
-			return nil, err
-		}
-		qc.TableDefinitions[name] = edc
-	}
-	if qq.DefaultDataset != nil {
-		qc.DefaultProjectID = qq.DefaultDataset.ProjectId
-		qc.DefaultDatasetID = qq.DefaultDataset.DatasetId
-	}
-	if qq.MaximumBillingTier != nil {
-		qc.MaxBillingTier = int(*qq.MaximumBillingTier)
-	}
-	if qq.UseQueryCache != nil && !*qq.UseQueryCache {
-		qc.DisableQueryCache = true
-	}
-	if qq.FlattenResults != nil && !*qq.FlattenResults {
-		qc.DisableFlattenedResults = true
-	}
-	if qq.DestinationTable != nil {
-		qc.Dst = bqToTable(qq.DestinationTable, c)
-	}
-	for _, qp := range qq.QueryParameters {
-		p, err := bqToQueryParameter(qp)
-		if err != nil {
-			return nil, err
-		}
-		qc.Parameters = append(qc.Parameters, p)
-	}
-	return qc, nil
-}
-
-// QueryPriority specifies a priority with which a query is to be executed.
-type QueryPriority string
-
-const (
-	// BatchPriority specifies that the query should be scheduled with the
-	// batch priority.  BigQuery queues each batch query on your behalf, and
-	// starts the query as soon as idle resources are available, usually within
-	// a few minutes. If BigQuery hasn't started the query within 24 hours,
-	// BigQuery changes the job priority to interactive. Batch queries don't
-	// count towards your concurrent rate limit, which can make it easier to
-	// start many queries at once.
-	//
-	// More information can be found at https://cloud.google.com/bigquery/docs/running-queries#batchqueries.
-	BatchPriority QueryPriority = "BATCH"
-	// InteractivePriority specifies that the query should be scheduled with
-	// interactive priority, which means that the query is executed as soon as
-	// possible. Interactive queries count towards your concurrent rate limit
-	// and your daily limit. It is the default priority with which queries get
-	// executed.
-	//
-	// More information can be found at https://cloud.google.com/bigquery/docs/running-queries#queries.
-	InteractivePriority QueryPriority = "INTERACTIVE"
-)
-
-// A Query queries data from a BigQuery table. Use Client.Query to create a Query.
-type Query struct {
-	JobIDConfig
-	QueryConfig
-	client *Client
-}
-
-// Query creates a query with string q.
-// The returned Query may optionally be further configured before its Run method is called.
-func (c *Client) Query(q string) *Query {
-	return &Query{
-		client:      c,
-		QueryConfig: QueryConfig{Q: q},
-	}
-}
-
-// Run initiates a query job.
-func (q *Query) Run(ctx context.Context) (j *Job, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Query.Run")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	job, err := q.newJob()
-	if err != nil {
-		return nil, err
-	}
-	j, err = q.client.insertJob(ctx, job, nil)
-	if err != nil {
-		return nil, err
-	}
-	return j, nil
-}
-
-func (q *Query) newJob() (*bq.Job, error) {
-	config, err := q.QueryConfig.toBQ()
-	if err != nil {
-		return nil, err
-	}
-	return &bq.Job{
-		JobReference:  q.JobIDConfig.createJobRef(q.client),
-		Configuration: config,
-	}, nil
-}
-
-// Read submits a query for execution and returns the results via a RowIterator.
-// It is a shorthand for Query.Run followed by Job.Read.
-func (q *Query) Read(ctx context.Context) (*RowIterator, error) {
-	job, err := q.Run(ctx)
-	if err != nil {
-		return nil, err
-	}
-	return job.Read(ctx)
-}

+ 0 - 408
vendor/cloud.google.com/go/bigquery/query_test.go

@@ -1,408 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"testing"
-	"time"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func defaultQueryJob() *bq.Job {
-	pfalse := false
-	return &bq.Job{
-		JobReference: &bq.JobReference{JobId: "RANDOM", ProjectId: "client-project-id"},
-		Configuration: &bq.JobConfiguration{
-			Query: &bq.JobConfigurationQuery{
-				DestinationTable: &bq.TableReference{
-					ProjectId: "client-project-id",
-					DatasetId: "dataset-id",
-					TableId:   "table-id",
-				},
-				Query: "query string",
-				DefaultDataset: &bq.DatasetReference{
-					ProjectId: "def-project-id",
-					DatasetId: "def-dataset-id",
-				},
-				UseLegacySql: &pfalse,
-			},
-		},
-	}
-}
-
-var defaultQuery = &QueryConfig{
-	Q:                "query string",
-	DefaultProjectID: "def-project-id",
-	DefaultDatasetID: "def-dataset-id",
-}
-
-func TestQuery(t *testing.T) {
-	defer fixRandomID("RANDOM")()
-	c := &Client{
-		projectID: "client-project-id",
-	}
-	testCases := []struct {
-		dst         *Table
-		src         *QueryConfig
-		jobIDConfig JobIDConfig
-		want        *bq.Job
-	}{
-		{
-			dst:  c.Dataset("dataset-id").Table("table-id"),
-			src:  defaultQuery,
-			want: defaultQueryJob(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:      "query string",
-				Labels: map[string]string{"a": "b"},
-				DryRun: true,
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				j.Configuration.Labels = map[string]string{"a": "b"}
-				j.Configuration.DryRun = true
-				j.Configuration.Query.DefaultDataset = nil
-				return j
-			}(),
-		},
-		{
-			dst:         c.Dataset("dataset-id").Table("table-id"),
-			jobIDConfig: JobIDConfig{JobID: "jobID", AddJobIDSuffix: true},
-			src:         &QueryConfig{Q: "query string"},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				j.Configuration.Query.DefaultDataset = nil
-				j.JobReference.JobId = "jobID-RANDOM"
-				return j
-			}(),
-		},
-		{
-			dst: &Table{},
-			src: defaultQuery,
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				j.Configuration.Query.DestinationTable = nil
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q: "query string",
-				TableDefinitions: map[string]ExternalData{
-					"atable": func() *GCSReference {
-						g := NewGCSReference("uri")
-						g.AllowJaggedRows = true
-						g.AllowQuotedNewlines = true
-						g.Compression = Gzip
-						g.Encoding = UTF_8
-						g.FieldDelimiter = ";"
-						g.IgnoreUnknownValues = true
-						g.MaxBadRecords = 1
-						g.Quote = "'"
-						g.SkipLeadingRows = 2
-						g.Schema = Schema{{Name: "name", Type: StringFieldType}}
-						return g
-					}(),
-				},
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				j.Configuration.Query.DefaultDataset = nil
-				td := make(map[string]bq.ExternalDataConfiguration)
-				quote := "'"
-				td["atable"] = bq.ExternalDataConfiguration{
-					Compression:         "GZIP",
-					IgnoreUnknownValues: true,
-					MaxBadRecords:       1,
-					SourceFormat:        "CSV", // must be explicitly set.
-					SourceUris:          []string{"uri"},
-					CsvOptions: &bq.CsvOptions{
-						AllowJaggedRows:     true,
-						AllowQuotedNewlines: true,
-						Encoding:            "UTF-8",
-						FieldDelimiter:      ";",
-						SkipLeadingRows:     2,
-						Quote:               &quote,
-					},
-					Schema: &bq.TableSchema{
-						Fields: []*bq.TableFieldSchema{
-							{Name: "name", Type: "STRING"},
-						},
-					},
-				}
-				j.Configuration.Query.TableDefinitions = td
-				return j
-			}(),
-		},
-		{
-			dst: &Table{
-				ProjectID: "project-id",
-				DatasetID: "dataset-id",
-				TableID:   "table-id",
-			},
-			src: &QueryConfig{
-				Q:                 "query string",
-				DefaultProjectID:  "def-project-id",
-				DefaultDatasetID:  "def-dataset-id",
-				CreateDisposition: CreateNever,
-				WriteDisposition:  WriteTruncate,
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				j.Configuration.Query.DestinationTable.ProjectId = "project-id"
-				j.Configuration.Query.WriteDisposition = "WRITE_TRUNCATE"
-				j.Configuration.Query.CreateDisposition = "CREATE_NEVER"
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:                 "query string",
-				DefaultProjectID:  "def-project-id",
-				DefaultDatasetID:  "def-dataset-id",
-				DisableQueryCache: true,
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				f := false
-				j.Configuration.Query.UseQueryCache = &f
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:                 "query string",
-				DefaultProjectID:  "def-project-id",
-				DefaultDatasetID:  "def-dataset-id",
-				AllowLargeResults: true,
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				j.Configuration.Query.AllowLargeResults = true
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:                       "query string",
-				DefaultProjectID:        "def-project-id",
-				DefaultDatasetID:        "def-dataset-id",
-				DisableFlattenedResults: true,
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				f := false
-				j.Configuration.Query.FlattenResults = &f
-				j.Configuration.Query.AllowLargeResults = true
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:                "query string",
-				DefaultProjectID: "def-project-id",
-				DefaultDatasetID: "def-dataset-id",
-				Priority:         QueryPriority("low"),
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				j.Configuration.Query.Priority = "low"
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:                "query string",
-				DefaultProjectID: "def-project-id",
-				DefaultDatasetID: "def-dataset-id",
-				MaxBillingTier:   3,
-				MaxBytesBilled:   5,
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				tier := int64(3)
-				j.Configuration.Query.MaximumBillingTier = &tier
-				j.Configuration.Query.MaximumBytesBilled = 5
-				return j
-			}(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:                "query string",
-				DefaultProjectID: "def-project-id",
-				DefaultDatasetID: "def-dataset-id",
-				UseStandardSQL:   true,
-			},
-			want: defaultQueryJob(),
-		},
-		{
-			dst: c.Dataset("dataset-id").Table("table-id"),
-			src: &QueryConfig{
-				Q:                "query string",
-				DefaultProjectID: "def-project-id",
-				DefaultDatasetID: "def-dataset-id",
-				UseLegacySQL:     true,
-			},
-			want: func() *bq.Job {
-				j := defaultQueryJob()
-				ptrue := true
-				j.Configuration.Query.UseLegacySql = &ptrue
-				j.Configuration.Query.ForceSendFields = nil
-				return j
-			}(),
-		},
-	}
-	for i, tc := range testCases {
-		query := c.Query("")
-		query.JobIDConfig = tc.jobIDConfig
-		query.QueryConfig = *tc.src
-		query.Dst = tc.dst
-		got, err := query.newJob()
-		if err != nil {
-			t.Errorf("#%d: err calling query: %v", i, err)
-			continue
-		}
-		checkJob(t, i, got, tc.want)
-
-		// Round-trip.
-		jc, err := bqToJobConfig(got.Configuration, c)
-		if err != nil {
-			t.Fatalf("#%d: %v", i, err)
-		}
-		wantConfig := query.QueryConfig
-		// We set AllowLargeResults to true when DisableFlattenedResults is true.
-		if wantConfig.DisableFlattenedResults {
-			wantConfig.AllowLargeResults = true
-		}
-		// A QueryConfig with neither UseXXXSQL field set is equivalent
-		// to one where UseStandardSQL = true.
-		if !wantConfig.UseLegacySQL && !wantConfig.UseStandardSQL {
-			wantConfig.UseStandardSQL = true
-		}
-		// Treat nil and empty tables the same, and ignore the client.
-		tableEqual := func(t1, t2 *Table) bool {
-			if t1 == nil {
-				t1 = &Table{}
-			}
-			if t2 == nil {
-				t2 = &Table{}
-			}
-			return t1.ProjectID == t2.ProjectID && t1.DatasetID == t2.DatasetID && t1.TableID == t2.TableID
-		}
-		// A table definition that is a GCSReference round-trips as an ExternalDataConfig.
-		// TODO(jba): see if there is a way to express this with a transformer.
-		gcsRefToEDC := func(g *GCSReference) *ExternalDataConfig {
-			q := g.toBQ()
-			e, _ := bqToExternalDataConfig(&q)
-			return e
-		}
-		externalDataEqual := func(e1, e2 ExternalData) bool {
-			if r, ok := e1.(*GCSReference); ok {
-				e1 = gcsRefToEDC(r)
-			}
-			if r, ok := e2.(*GCSReference); ok {
-				e2 = gcsRefToEDC(r)
-			}
-			return cmp.Equal(e1, e2)
-		}
-		diff := testutil.Diff(jc.(*QueryConfig), &wantConfig,
-			cmp.Comparer(tableEqual),
-			cmp.Comparer(externalDataEqual),
-		)
-		if diff != "" {
-			t.Errorf("#%d: (got=-, want=+:\n%s", i, diff)
-		}
-	}
-}
-
-func TestConfiguringQuery(t *testing.T) {
-	c := &Client{
-		projectID: "project-id",
-	}
-
-	query := c.Query("q")
-	query.JobID = "ajob"
-	query.DefaultProjectID = "def-project-id"
-	query.DefaultDatasetID = "def-dataset-id"
-	query.TimePartitioning = &TimePartitioning{Expiration: 1234 * time.Second, Field: "f"}
-	query.Clustering = &Clustering{
-		Fields: []string{"cfield1"},
-	}
-	query.DestinationEncryptionConfig = &EncryptionConfig{KMSKeyName: "keyName"}
-	query.SchemaUpdateOptions = []string{"ALLOW_FIELD_ADDITION"}
-
-	// Note: Other configuration fields are tested in other tests above.
-	// A lot of that can be consolidated once Client.Copy is gone.
-
-	pfalse := false
-	want := &bq.Job{
-		Configuration: &bq.JobConfiguration{
-			Query: &bq.JobConfigurationQuery{
-				Query: "q",
-				DefaultDataset: &bq.DatasetReference{
-					ProjectId: "def-project-id",
-					DatasetId: "def-dataset-id",
-				},
-				UseLegacySql:                       &pfalse,
-				TimePartitioning:                   &bq.TimePartitioning{ExpirationMs: 1234000, Field: "f", Type: "DAY"},
-				Clustering:                         &bq.Clustering{Fields: []string{"cfield1"}},
-				DestinationEncryptionConfiguration: &bq.EncryptionConfiguration{KmsKeyName: "keyName"},
-				SchemaUpdateOptions:                []string{"ALLOW_FIELD_ADDITION"},
-			},
-		},
-		JobReference: &bq.JobReference{
-			JobId:     "ajob",
-			ProjectId: "project-id",
-		},
-	}
-
-	got, err := query.newJob()
-	if err != nil {
-		t.Fatalf("err calling Query.newJob: %v", err)
-	}
-	if diff := testutil.Diff(got, want); diff != "" {
-		t.Errorf("querying: -got +want:\n%s", diff)
-	}
-}
-
-func TestQueryLegacySQL(t *testing.T) {
-	c := &Client{projectID: "project-id"}
-	q := c.Query("q")
-	q.UseStandardSQL = true
-	q.UseLegacySQL = true
-	_, err := q.newJob()
-	if err == nil {
-		t.Error("UseStandardSQL and UseLegacySQL: got nil, want error")
-	}
-	q = c.Query("q")
-	q.Parameters = []QueryParameter{{Name: "p", Value: 3}}
-	q.UseLegacySQL = true
-	_, err = q.newJob()
-	if err == nil {
-		t.Error("Parameters and UseLegacySQL: got nil, want error")
-	}
-}

+ 0 - 56
vendor/cloud.google.com/go/bigquery/random.go

@@ -1,56 +0,0 @@
-// Copyright 2018 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"math/rand"
-	"os"
-	"sync"
-	"time"
-)
-
-// Support for random values (typically job IDs and insert IDs).
-
-const alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
-
-var (
-	rngMu sync.Mutex
-	rng   = rand.New(rand.NewSource(time.Now().UnixNano() ^ int64(os.Getpid())))
-)
-
-// For testing.
-var randomIDFn = randomID
-
-// As of August 2017, the BigQuery service uses 27 alphanumeric characters for
-// suffixes.
-const randomIDLen = 27
-
-func randomID() string {
-	// This is used for both job IDs and insert IDs.
-	var b [randomIDLen]byte
-	rngMu.Lock()
-	for i := 0; i < len(b); i++ {
-		b[i] = alphanum[rng.Intn(len(alphanum))]
-	}
-	rngMu.Unlock()
-	return string(b[:])
-}
-
-// Seed seeds this package's random number generator, used for generating job and
-// insert IDs. Use Seed to obtain repeatable, deterministic behavior from bigquery
-// clients. Seed should be called before any clients are created.
-func Seed(s int64) {
-	rng = rand.New(rand.NewSource(s))
-}

+ 0 - 233
vendor/cloud.google.com/go/bigquery/read_test.go

@@ -1,233 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"testing"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	bq "google.golang.org/api/bigquery/v2"
-	"google.golang.org/api/iterator"
-)
-
-type pageFetcherArgs struct {
-	table      *Table
-	schema     Schema
-	startIndex uint64
-	pageSize   int64
-	pageToken  string
-}
-
-// pageFetcherReadStub services read requests by returning data from an in-memory list of values.
-type pageFetcherReadStub struct {
-	// values and pageTokens are used as sources of data to return in response to calls to readTabledata or readQuery.
-	values     [][][]Value       // contains pages / rows / columns.
-	pageTokens map[string]string // maps incoming page token to returned page token.
-
-	// arguments are recorded for later inspection.
-	calls []pageFetcherArgs
-}
-
-func (s *pageFetcherReadStub) fetchPage(ctx context.Context, t *Table, schema Schema, startIndex uint64, pageSize int64, pageToken string) (*fetchPageResult, error) {
-	s.calls = append(s.calls,
-		pageFetcherArgs{t, schema, startIndex, pageSize, pageToken})
-	result := &fetchPageResult{
-		pageToken: s.pageTokens[pageToken],
-		rows:      s.values[0],
-	}
-	s.values = s.values[1:]
-	return result, nil
-}
-
-func waitForQueryStub(context.Context, string) (Schema, uint64, error) {
-	return nil, 1, nil
-}
-
-func TestRead(t *testing.T) {
-	// The data for the service stub to return is populated for each test case in the testCases for loop.
-	ctx := context.Background()
-	c := &Client{projectID: "project-id"}
-	pf := &pageFetcherReadStub{}
-	queryJob := &Job{
-		projectID: "project-id",
-		jobID:     "job-id",
-		c:         c,
-		config: &bq.JobConfiguration{
-			Query: &bq.JobConfigurationQuery{
-				DestinationTable: &bq.TableReference{
-					ProjectId: "project-id",
-					DatasetId: "dataset-id",
-					TableId:   "table-id",
-				},
-			},
-		},
-	}
-
-	for _, readFunc := range []func() *RowIterator{
-		func() *RowIterator {
-			return c.Dataset("dataset-id").Table("table-id").read(ctx, pf.fetchPage)
-		},
-		func() *RowIterator {
-			it, err := queryJob.read(ctx, waitForQueryStub, pf.fetchPage)
-			if err != nil {
-				t.Fatal(err)
-			}
-			return it
-		},
-	} {
-		testCases := []struct {
-			data       [][][]Value
-			pageTokens map[string]string
-			want       [][]Value
-		}{
-			{
-				data:       [][][]Value{{{1, 2}, {11, 12}}, {{30, 40}, {31, 41}}},
-				pageTokens: map[string]string{"": "a", "a": ""},
-				want:       [][]Value{{1, 2}, {11, 12}, {30, 40}, {31, 41}},
-			},
-			{
-				data:       [][][]Value{{{1, 2}, {11, 12}}, {{30, 40}, {31, 41}}},
-				pageTokens: map[string]string{"": ""}, // no more pages after first one.
-				want:       [][]Value{{1, 2}, {11, 12}},
-			},
-		}
-		for _, tc := range testCases {
-			pf.values = tc.data
-			pf.pageTokens = tc.pageTokens
-			if got, ok := collectValues(t, readFunc()); ok {
-				if !testutil.Equal(got, tc.want) {
-					t.Errorf("reading: got:\n%v\nwant:\n%v", got, tc.want)
-				}
-			}
-		}
-	}
-}
-
-func collectValues(t *testing.T, it *RowIterator) ([][]Value, bool) {
-	var got [][]Value
-	for {
-		var vals []Value
-		err := it.Next(&vals)
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			t.Errorf("err calling Next: %v", err)
-			return nil, false
-		}
-		got = append(got, vals)
-	}
-	return got, true
-}
-
-func TestNoMoreValues(t *testing.T) {
-	c := &Client{projectID: "project-id"}
-	pf := &pageFetcherReadStub{
-		values: [][][]Value{{{1, 2}, {11, 12}}},
-	}
-	it := c.Dataset("dataset-id").Table("table-id").read(context.Background(), pf.fetchPage)
-	var vals []Value
-	// We expect to retrieve two values and then fail on the next attempt.
-	if err := it.Next(&vals); err != nil {
-		t.Fatalf("Next: got: %v: want: nil", err)
-	}
-	if err := it.Next(&vals); err != nil {
-		t.Fatalf("Next: got: %v: want: nil", err)
-	}
-	if err := it.Next(&vals); err != iterator.Done {
-		t.Fatalf("Next: got: %v: want: iterator.Done", err)
-	}
-}
-
-var errBang = errors.New("bang")
-
-func errorFetchPage(context.Context, *Table, Schema, uint64, int64, string) (*fetchPageResult, error) {
-	return nil, errBang
-}
-
-func TestReadError(t *testing.T) {
-	// test that service read errors are propagated back to the caller.
-	c := &Client{projectID: "project-id"}
-	it := c.Dataset("dataset-id").Table("table-id").read(context.Background(), errorFetchPage)
-	var vals []Value
-	if err := it.Next(&vals); err != errBang {
-		t.Fatalf("Get: got: %v: want: %v", err, errBang)
-	}
-}
-
-func TestReadTabledataOptions(t *testing.T) {
-	// test that read options are propagated.
-	s := &pageFetcherReadStub{
-		values: [][][]Value{{{1, 2}}},
-	}
-	c := &Client{projectID: "project-id"}
-	tr := c.Dataset("dataset-id").Table("table-id")
-	it := tr.read(context.Background(), s.fetchPage)
-	it.PageInfo().MaxSize = 5
-	var vals []Value
-	if err := it.Next(&vals); err != nil {
-		t.Fatal(err)
-	}
-	want := []pageFetcherArgs{{
-		table:     tr,
-		pageSize:  5,
-		pageToken: "",
-	}}
-	if diff := testutil.Diff(s.calls, want, cmp.AllowUnexported(pageFetcherArgs{}, pageFetcherReadStub{}, Table{}, Client{})); diff != "" {
-		t.Errorf("reading (got=-, want=+):\n%s", diff)
-	}
-}
-
-func TestReadQueryOptions(t *testing.T) {
-	// test that read options are propagated.
-	c := &Client{projectID: "project-id"}
-	pf := &pageFetcherReadStub{
-		values: [][][]Value{{{1, 2}}},
-	}
-	tr := &bq.TableReference{
-		ProjectId: "project-id",
-		DatasetId: "dataset-id",
-		TableId:   "table-id",
-	}
-	queryJob := &Job{
-		projectID: "project-id",
-		jobID:     "job-id",
-		c:         c,
-		config: &bq.JobConfiguration{
-			Query: &bq.JobConfigurationQuery{DestinationTable: tr},
-		},
-	}
-	it, err := queryJob.read(context.Background(), waitForQueryStub, pf.fetchPage)
-	if err != nil {
-		t.Fatalf("err calling Read: %v", err)
-	}
-	it.PageInfo().MaxSize = 5
-	var vals []Value
-	if err := it.Next(&vals); err != nil {
-		t.Fatalf("Next: got: %v: want: nil", err)
-	}
-
-	want := []pageFetcherArgs{{
-		table:     bqToTable(tr, c),
-		pageSize:  5,
-		pageToken: "",
-	}}
-	if !testutil.Equal(pf.calls, want, cmp.AllowUnexported(pageFetcherArgs{}, Table{}, Client{})) {
-		t.Errorf("reading: got:\n%v\nwant:\n%v", pf.calls, want)
-	}
-}

+ 0 - 488
vendor/cloud.google.com/go/bigquery/schema.go

@@ -1,488 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"reflect"
-	"sync"
-
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// Schema describes the fields in a table or query result.
-type Schema []*FieldSchema
-
-// FieldSchema describes a single field.
-type FieldSchema struct {
-	// The field name.
-	// Must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_),
-	// and must start with a letter or underscore.
-	// The maximum length is 128 characters.
-	Name string
-
-	// A description of the field. The maximum length is 16,384 characters.
-	Description string
-
-	// Whether the field may contain multiple values.
-	Repeated bool
-	// Whether the field is required.  Ignored if Repeated is true.
-	Required bool
-
-	// The field data type.  If Type is Record, then this field contains a nested schema,
-	// which is described by Schema.
-	Type FieldType
-	// Describes the nested schema if Type is set to Record.
-	Schema Schema
-}
-
-func (fs *FieldSchema) toBQ() *bq.TableFieldSchema {
-	tfs := &bq.TableFieldSchema{
-		Description: fs.Description,
-		Name:        fs.Name,
-		Type:        string(fs.Type),
-	}
-
-	if fs.Repeated {
-		tfs.Mode = "REPEATED"
-	} else if fs.Required {
-		tfs.Mode = "REQUIRED"
-	} // else leave as default, which is interpreted as NULLABLE.
-
-	for _, f := range fs.Schema {
-		tfs.Fields = append(tfs.Fields, f.toBQ())
-	}
-
-	return tfs
-}
-
-func (s Schema) toBQ() *bq.TableSchema {
-	var fields []*bq.TableFieldSchema
-	for _, f := range s {
-		fields = append(fields, f.toBQ())
-	}
-	return &bq.TableSchema{Fields: fields}
-}
-
-func bqToFieldSchema(tfs *bq.TableFieldSchema) *FieldSchema {
-	fs := &FieldSchema{
-		Description: tfs.Description,
-		Name:        tfs.Name,
-		Repeated:    tfs.Mode == "REPEATED",
-		Required:    tfs.Mode == "REQUIRED",
-		Type:        FieldType(tfs.Type),
-	}
-
-	for _, f := range tfs.Fields {
-		fs.Schema = append(fs.Schema, bqToFieldSchema(f))
-	}
-	return fs
-}
-
-func bqToSchema(ts *bq.TableSchema) Schema {
-	if ts == nil {
-		return nil
-	}
-	var s Schema
-	for _, f := range ts.Fields {
-		s = append(s, bqToFieldSchema(f))
-	}
-	return s
-}
-
-// FieldType is the type of field.
-type FieldType string
-
-const (
-	// StringFieldType is a string field type.
-	StringFieldType FieldType = "STRING"
-	// BytesFieldType is a bytes field type.
-	BytesFieldType FieldType = "BYTES"
-	// IntegerFieldType is a integer field type.
-	IntegerFieldType FieldType = "INTEGER"
-	// FloatFieldType is a float field type.
-	FloatFieldType FieldType = "FLOAT"
-	// BooleanFieldType is a boolean field type.
-	BooleanFieldType FieldType = "BOOLEAN"
-	// TimestampFieldType is a timestamp field type.
-	TimestampFieldType FieldType = "TIMESTAMP"
-	// RecordFieldType is a record field type. It is typically used to create columns with repeated or nested data.
-	RecordFieldType FieldType = "RECORD"
-	// DateFieldType is a date field type.
-	DateFieldType FieldType = "DATE"
-	// TimeFieldType is a time field type.
-	TimeFieldType FieldType = "TIME"
-	// DateTimeFieldType is a datetime field type.
-	DateTimeFieldType FieldType = "DATETIME"
-	// NumericFieldType is a numeric field type. Numeric types include integer types, floating point types and the
-	// NUMERIC data type.
-	NumericFieldType FieldType = "NUMERIC"
-)
-
-var (
-	errNoStruct             = errors.New("bigquery: can only infer schema from struct or pointer to struct")
-	errUnsupportedFieldType = errors.New("bigquery: unsupported type of field in struct")
-	errInvalidFieldName     = errors.New("bigquery: invalid name of field in struct")
-	errBadNullable          = errors.New(`bigquery: use "nullable" only for []byte and struct pointers; for all other types, use a NullXXX type`)
-	errEmptyJSONSchema      = errors.New("bigquery: empty JSON schema")
-	fieldTypes              = map[FieldType]bool{
-		StringFieldType:    true,
-		BytesFieldType:     true,
-		IntegerFieldType:   true,
-		FloatFieldType:     true,
-		BooleanFieldType:   true,
-		TimestampFieldType: true,
-		RecordFieldType:    true,
-		DateFieldType:      true,
-		TimeFieldType:      true,
-		DateTimeFieldType:  true,
-		NumericFieldType:   true,
-	}
-)
-
-var typeOfByteSlice = reflect.TypeOf([]byte{})
-
-// InferSchema tries to derive a BigQuery schema from the supplied struct value.
-// Each exported struct field is mapped to a field in the schema.
-//
-// The following BigQuery types are inferred from the corresponding Go types.
-// (This is the same mapping as that used for RowIterator.Next.) Fields inferred
-// from these types are marked required (non-nullable).
-//
-//   STRING      string
-//   BOOL        bool
-//   INTEGER     int, int8, int16, int32, int64, uint8, uint16, uint32
-//   FLOAT       float32, float64
-//   BYTES       []byte
-//   TIMESTAMP   time.Time
-//   DATE        civil.Date
-//   TIME        civil.Time
-//   DATETIME    civil.DateTime
-//   NUMERIC     *big.Rat
-//
-// The big.Rat type supports numbers of arbitrary size and precision. Values
-// will be rounded to 9 digits after the decimal point before being transmitted
-// to BigQuery. See https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#numeric-type
-// for more on NUMERIC.
-//
-// A Go slice or array type is inferred to be a BigQuery repeated field of the
-// element type. The element type must be one of the above listed types.
-//
-// Nullable fields are inferred from the NullXXX types, declared in this package:
-//
-//   STRING      NullString
-//   BOOL        NullBool
-//   INTEGER     NullInt64
-//   FLOAT       NullFloat64
-//   TIMESTAMP   NullTimestamp
-//   DATE        NullDate
-//   TIME        NullTime
-//   DATETIME    NullDateTime
-//
-// For a nullable BYTES field, use the type []byte and tag the field "nullable" (see below).
-// For a nullable NUMERIC field, use the type *big.Rat and tag the field "nullable".
-//
-// A struct field that is of struct type is inferred to be a required field of type
-// RECORD with a schema inferred recursively. For backwards compatibility, a field of
-// type pointer to struct is also inferred to be required. To get a nullable RECORD
-// field, use the "nullable" tag (see below).
-//
-// InferSchema returns an error if any of the examined fields is of type uint,
-// uint64, uintptr, map, interface, complex64, complex128, func, or chan. Future
-// versions may handle these cases without error.
-//
-// Recursively defined structs are also disallowed.
-//
-// Struct fields may be tagged in a way similar to the encoding/json package.
-// A tag of the form
-//     bigquery:"name"
-// uses "name" instead of the struct field name as the BigQuery field name.
-// A tag of the form
-//     bigquery:"-"
-// omits the field from the inferred schema.
-// The "nullable" option marks the field as nullable (not required). It is only
-// needed for []byte, *big.Rat and pointer-to-struct fields, and cannot appear on other
-// fields. In this example, the Go name of the field is retained:
-//     bigquery:",nullable"
-func InferSchema(st interface{}) (Schema, error) {
-	return inferSchemaReflectCached(reflect.TypeOf(st))
-}
-
-var schemaCache sync.Map
-
-type cacheVal struct {
-	schema Schema
-	err    error
-}
-
-func inferSchemaReflectCached(t reflect.Type) (Schema, error) {
-	var cv cacheVal
-	v, ok := schemaCache.Load(t)
-	if ok {
-		cv = v.(cacheVal)
-	} else {
-		s, err := inferSchemaReflect(t)
-		cv = cacheVal{s, err}
-		schemaCache.Store(t, cv)
-	}
-	return cv.schema, cv.err
-}
-
-func inferSchemaReflect(t reflect.Type) (Schema, error) {
-	rec, err := hasRecursiveType(t, nil)
-	if err != nil {
-		return nil, err
-	}
-	if rec {
-		return nil, fmt.Errorf("bigquery: schema inference for recursive type %s", t)
-	}
-	return inferStruct(t)
-}
-
-func inferStruct(t reflect.Type) (Schema, error) {
-	switch t.Kind() {
-	case reflect.Ptr:
-		if t.Elem().Kind() != reflect.Struct {
-			return nil, errNoStruct
-		}
-		t = t.Elem()
-		fallthrough
-
-	case reflect.Struct:
-		return inferFields(t)
-	default:
-		return nil, errNoStruct
-	}
-}
-
-// inferFieldSchema infers the FieldSchema for a Go type
-func inferFieldSchema(rt reflect.Type, nullable bool) (*FieldSchema, error) {
-	// Only []byte and struct pointers can be tagged nullable.
-	if nullable && !(rt == typeOfByteSlice || rt.Kind() == reflect.Ptr && rt.Elem().Kind() == reflect.Struct) {
-		return nil, errBadNullable
-	}
-	switch rt {
-	case typeOfByteSlice:
-		return &FieldSchema{Required: !nullable, Type: BytesFieldType}, nil
-	case typeOfGoTime:
-		return &FieldSchema{Required: true, Type: TimestampFieldType}, nil
-	case typeOfDate:
-		return &FieldSchema{Required: true, Type: DateFieldType}, nil
-	case typeOfTime:
-		return &FieldSchema{Required: true, Type: TimeFieldType}, nil
-	case typeOfDateTime:
-		return &FieldSchema{Required: true, Type: DateTimeFieldType}, nil
-	case typeOfRat:
-		return &FieldSchema{Required: !nullable, Type: NumericFieldType}, nil
-	}
-	if ft := nullableFieldType(rt); ft != "" {
-		return &FieldSchema{Required: false, Type: ft}, nil
-	}
-	if isSupportedIntType(rt) || isSupportedUintType(rt) {
-		return &FieldSchema{Required: true, Type: IntegerFieldType}, nil
-	}
-	switch rt.Kind() {
-	case reflect.Slice, reflect.Array:
-		et := rt.Elem()
-		if et != typeOfByteSlice && (et.Kind() == reflect.Slice || et.Kind() == reflect.Array) {
-			// Multi dimensional slices/arrays are not supported by BigQuery
-			return nil, errUnsupportedFieldType
-		}
-		if nullableFieldType(et) != "" {
-			// Repeated nullable types are not supported by BigQuery.
-			return nil, errUnsupportedFieldType
-		}
-		f, err := inferFieldSchema(et, false)
-		if err != nil {
-			return nil, err
-		}
-		f.Repeated = true
-		f.Required = false
-		return f, nil
-	case reflect.Ptr:
-		if rt.Elem().Kind() != reflect.Struct {
-			return nil, errUnsupportedFieldType
-		}
-		fallthrough
-	case reflect.Struct:
-		nested, err := inferStruct(rt)
-		if err != nil {
-			return nil, err
-		}
-		return &FieldSchema{Required: !nullable, Type: RecordFieldType, Schema: nested}, nil
-	case reflect.String:
-		return &FieldSchema{Required: !nullable, Type: StringFieldType}, nil
-	case reflect.Bool:
-		return &FieldSchema{Required: !nullable, Type: BooleanFieldType}, nil
-	case reflect.Float32, reflect.Float64:
-		return &FieldSchema{Required: !nullable, Type: FloatFieldType}, nil
-	default:
-		return nil, errUnsupportedFieldType
-	}
-}
-
-// inferFields extracts all exported field types from struct type.
-func inferFields(rt reflect.Type) (Schema, error) {
-	var s Schema
-	fields, err := fieldCache.Fields(rt)
-	if err != nil {
-		return nil, err
-	}
-	for _, field := range fields {
-		var nullable bool
-		for _, opt := range field.ParsedTag.([]string) {
-			if opt == nullableTagOption {
-				nullable = true
-				break
-			}
-		}
-		f, err := inferFieldSchema(field.Type, nullable)
-		if err != nil {
-			return nil, err
-		}
-		f.Name = field.Name
-		s = append(s, f)
-	}
-	return s, nil
-}
-
-// isSupportedIntType reports whether t is an int type that can be properly
-// represented by the BigQuery INTEGER/INT64 type.
-func isSupportedIntType(t reflect.Type) bool {
-	switch t.Kind() {
-	case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
-		return true
-	default:
-		return false
-	}
-}
-
-// isSupportedIntType reports whether t is a uint type that can be properly
-// represented by the BigQuery INTEGER/INT64 type.
-func isSupportedUintType(t reflect.Type) bool {
-	switch t.Kind() {
-	case reflect.Uint8, reflect.Uint16, reflect.Uint32:
-		return true
-	default:
-		return false
-	}
-}
-
-// typeList is a linked list of reflect.Types.
-type typeList struct {
-	t    reflect.Type
-	next *typeList
-}
-
-func (l *typeList) has(t reflect.Type) bool {
-	for l != nil {
-		if l.t == t {
-			return true
-		}
-		l = l.next
-	}
-	return false
-}
-
-// hasRecursiveType reports whether t or any type inside t refers to itself, directly or indirectly,
-// via exported fields. (Schema inference ignores unexported fields.)
-func hasRecursiveType(t reflect.Type, seen *typeList) (bool, error) {
-	for t.Kind() == reflect.Ptr || t.Kind() == reflect.Slice || t.Kind() == reflect.Array {
-		t = t.Elem()
-	}
-	if t.Kind() != reflect.Struct {
-		return false, nil
-	}
-	if seen.has(t) {
-		return true, nil
-	}
-	fields, err := fieldCache.Fields(t)
-	if err != nil {
-		return false, err
-	}
-	seen = &typeList{t, seen}
-	// Because seen is a linked list, additions to it from one field's
-	// recursive call will not affect the value for subsequent fields' calls.
-	for _, field := range fields {
-		ok, err := hasRecursiveType(field.Type, seen)
-		if err != nil {
-			return false, err
-		}
-		if ok {
-			return true, nil
-		}
-	}
-	return false, nil
-}
-
-// bigQuerySchemaJSONField is an individual field in a JSON BigQuery table schema definition
-// (as generated by https://github.com/GoogleCloudPlatform/protoc-gen-bq-schema).
-type bigQueryJSONField struct {
-	Description string              `json:"description"`
-	Fields      []bigQueryJSONField `json:"fields"`
-	Mode        string              `json:"mode"`
-	Name        string              `json:"name"`
-	Type        string              `json:"type"`
-}
-
-// convertSchemaFromJSON generates a Schema:
-func convertSchemaFromJSON(fs []bigQueryJSONField) (Schema, error) {
-	convertedSchema := Schema{}
-	for _, f := range fs {
-		convertedFieldSchema := &FieldSchema{
-			Description: f.Description,
-			Name:        f.Name,
-			Required:    f.Mode == "REQUIRED",
-			Repeated:    f.Mode == "REPEATED",
-		}
-		if len(f.Fields) > 0 {
-			convertedNestedFieldSchema, err := convertSchemaFromJSON(f.Fields)
-			if err != nil {
-				return nil, err
-			}
-			convertedFieldSchema.Schema = convertedNestedFieldSchema
-		}
-
-		// Check that the field-type (string) maps to a known FieldType:
-		if _, ok := fieldTypes[FieldType(f.Type)]; !ok {
-			return nil, fmt.Errorf("unknown field type (%v)", f.Type)
-		}
-		convertedFieldSchema.Type = FieldType(f.Type)
-
-		convertedSchema = append(convertedSchema, convertedFieldSchema)
-	}
-	return convertedSchema, nil
-}
-
-// SchemaFromJSON takes a JSON BigQuery table schema definition
-// (as generated by https://github.com/GoogleCloudPlatform/protoc-gen-bq-schema)
-// and returns a fully-populated Schema.
-func SchemaFromJSON(schemaJSON []byte) (Schema, error) {
-
-	var bigQuerySchema []bigQueryJSONField
-
-	// Make sure we actually have some content:
-	if len(schemaJSON) == 0 {
-		return nil, errEmptyJSONSchema
-	}
-
-	if err := json.Unmarshal(schemaJSON, &bigQuerySchema); err != nil {
-		return nil, err
-	}
-
-	return convertSchemaFromJSON(bigQuerySchema)
-}

+ 0 - 1052
vendor/cloud.google.com/go/bigquery/schema_test.go

@@ -1,1052 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"fmt"
-	"math/big"
-	"reflect"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/civil"
-	"cloud.google.com/go/internal/pretty"
-	"cloud.google.com/go/internal/testutil"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func (fs *FieldSchema) GoString() string {
-	if fs == nil {
-		return "<nil>"
-	}
-
-	return fmt.Sprintf("{Name:%s Description:%s Repeated:%t Required:%t Type:%s Schema:%s}",
-		fs.Name,
-		fs.Description,
-		fs.Repeated,
-		fs.Required,
-		fs.Type,
-		fmt.Sprintf("%#v", fs.Schema),
-	)
-}
-
-func bqTableFieldSchema(desc, name, typ, mode string) *bq.TableFieldSchema {
-	return &bq.TableFieldSchema{
-		Description: desc,
-		Name:        name,
-		Mode:        mode,
-		Type:        typ,
-	}
-}
-
-func fieldSchema(desc, name, typ string, repeated, required bool) *FieldSchema {
-	return &FieldSchema{
-		Description: desc,
-		Name:        name,
-		Repeated:    repeated,
-		Required:    required,
-		Type:        FieldType(typ),
-	}
-}
-
-func TestSchemaConversion(t *testing.T) {
-	testCases := []struct {
-		schema   Schema
-		bqSchema *bq.TableSchema
-	}{
-		{
-			// required
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "name", "STRING", "REQUIRED"),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "name", "STRING", false, true),
-			},
-		},
-		{
-			// repeated
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "name", "STRING", "REPEATED"),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "name", "STRING", true, false),
-			},
-		},
-		{
-			// nullable, string
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "name", "STRING", ""),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "name", "STRING", false, false),
-			},
-		},
-		{
-			// integer
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "name", "INTEGER", ""),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "name", "INTEGER", false, false),
-			},
-		},
-		{
-			// float
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "name", "FLOAT", ""),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "name", "FLOAT", false, false),
-			},
-		},
-		{
-			// boolean
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "name", "BOOLEAN", ""),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "name", "BOOLEAN", false, false),
-			},
-		},
-		{
-			// timestamp
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "name", "TIMESTAMP", ""),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "name", "TIMESTAMP", false, false),
-			},
-		},
-		{
-			// civil times
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "f1", "TIME", ""),
-					bqTableFieldSchema("desc", "f2", "DATE", ""),
-					bqTableFieldSchema("desc", "f3", "DATETIME", ""),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "f1", "TIME", false, false),
-				fieldSchema("desc", "f2", "DATE", false, false),
-				fieldSchema("desc", "f3", "DATETIME", false, false),
-			},
-		},
-		{
-			// numeric
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					bqTableFieldSchema("desc", "n", "NUMERIC", ""),
-				},
-			},
-			schema: Schema{
-				fieldSchema("desc", "n", "NUMERIC", false, false),
-			},
-		},
-		{
-			// nested
-			bqSchema: &bq.TableSchema{
-				Fields: []*bq.TableFieldSchema{
-					{
-						Description: "An outer schema wrapping a nested schema",
-						Name:        "outer",
-						Mode:        "REQUIRED",
-						Type:        "RECORD",
-						Fields: []*bq.TableFieldSchema{
-							bqTableFieldSchema("inner field", "inner", "STRING", ""),
-						},
-					},
-				},
-			},
-			schema: Schema{
-				&FieldSchema{
-					Description: "An outer schema wrapping a nested schema",
-					Name:        "outer",
-					Required:    true,
-					Type:        "RECORD",
-					Schema: Schema{
-						{
-							Description: "inner field",
-							Name:        "inner",
-							Type:        "STRING",
-						},
-					},
-				},
-			},
-		},
-	}
-	for _, tc := range testCases {
-		bqSchema := tc.schema.toBQ()
-		if !testutil.Equal(bqSchema, tc.bqSchema) {
-			t.Errorf("converting to TableSchema: got:\n%v\nwant:\n%v",
-				pretty.Value(bqSchema), pretty.Value(tc.bqSchema))
-		}
-		schema := bqToSchema(tc.bqSchema)
-		if !testutil.Equal(schema, tc.schema) {
-			t.Errorf("converting to Schema: got:\n%v\nwant:\n%v", schema, tc.schema)
-		}
-	}
-}
-
-type allStrings struct {
-	String    string
-	ByteSlice []byte
-}
-
-type allSignedIntegers struct {
-	Int64 int64
-	Int32 int32
-	Int16 int16
-	Int8  int8
-	Int   int
-}
-
-type allUnsignedIntegers struct {
-	Uint32 uint32
-	Uint16 uint16
-	Uint8  uint8
-}
-
-type allFloat struct {
-	Float64 float64
-	Float32 float32
-	// NOTE: Complex32 and Complex64 are unsupported by BigQuery
-}
-
-type allBoolean struct {
-	Bool bool
-}
-
-type allTime struct {
-	Timestamp time.Time
-	Time      civil.Time
-	Date      civil.Date
-	DateTime  civil.DateTime
-}
-
-type allNumeric struct {
-	Numeric *big.Rat
-}
-
-func reqField(name, typ string) *FieldSchema {
-	return &FieldSchema{
-		Name:     name,
-		Type:     FieldType(typ),
-		Required: true,
-	}
-}
-
-func optField(name, typ string) *FieldSchema {
-	return &FieldSchema{
-		Name:     name,
-		Type:     FieldType(typ),
-		Required: false,
-	}
-}
-
-func TestSimpleInference(t *testing.T) {
-	testCases := []struct {
-		in   interface{}
-		want Schema
-	}{
-		{
-			in: allSignedIntegers{},
-			want: Schema{
-				reqField("Int64", "INTEGER"),
-				reqField("Int32", "INTEGER"),
-				reqField("Int16", "INTEGER"),
-				reqField("Int8", "INTEGER"),
-				reqField("Int", "INTEGER"),
-			},
-		},
-		{
-			in: allUnsignedIntegers{},
-			want: Schema{
-				reqField("Uint32", "INTEGER"),
-				reqField("Uint16", "INTEGER"),
-				reqField("Uint8", "INTEGER"),
-			},
-		},
-		{
-			in: allFloat{},
-			want: Schema{
-				reqField("Float64", "FLOAT"),
-				reqField("Float32", "FLOAT"),
-			},
-		},
-		{
-			in: allBoolean{},
-			want: Schema{
-				reqField("Bool", "BOOLEAN"),
-			},
-		},
-		{
-			in: &allBoolean{},
-			want: Schema{
-				reqField("Bool", "BOOLEAN"),
-			},
-		},
-		{
-			in: allTime{},
-			want: Schema{
-				reqField("Timestamp", "TIMESTAMP"),
-				reqField("Time", "TIME"),
-				reqField("Date", "DATE"),
-				reqField("DateTime", "DATETIME"),
-			},
-		},
-		{
-			in: &allNumeric{},
-			want: Schema{
-				reqField("Numeric", "NUMERIC"),
-			},
-		},
-		{
-			in: allStrings{},
-			want: Schema{
-				reqField("String", "STRING"),
-				reqField("ByteSlice", "BYTES"),
-			},
-		},
-	}
-	for _, tc := range testCases {
-		got, err := InferSchema(tc.in)
-		if err != nil {
-			t.Fatalf("%T: error inferring TableSchema: %v", tc.in, err)
-		}
-		if !testutil.Equal(got, tc.want) {
-			t.Errorf("%T: inferring TableSchema: got:\n%#v\nwant:\n%#v", tc.in,
-				pretty.Value(got), pretty.Value(tc.want))
-		}
-	}
-}
-
-type containsNested struct {
-	NotNested int
-	Nested    struct {
-		Inside int
-	}
-}
-
-type containsDoubleNested struct {
-	NotNested int
-	Nested    struct {
-		InsideNested struct {
-			Inside int
-		}
-	}
-}
-
-type ptrNested struct {
-	Ptr *struct{ Inside int }
-}
-
-type dup struct { // more than one field of the same struct type
-	A, B allBoolean
-}
-
-func TestNestedInference(t *testing.T) {
-	testCases := []struct {
-		in   interface{}
-		want Schema
-	}{
-		{
-			in: containsNested{},
-			want: Schema{
-				reqField("NotNested", "INTEGER"),
-				&FieldSchema{
-					Name:     "Nested",
-					Required: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("Inside", "INTEGER")},
-				},
-			},
-		},
-		{
-			in: containsDoubleNested{},
-			want: Schema{
-				reqField("NotNested", "INTEGER"),
-				&FieldSchema{
-					Name:     "Nested",
-					Required: true,
-					Type:     "RECORD",
-					Schema: Schema{
-						{
-							Name:     "InsideNested",
-							Required: true,
-							Type:     "RECORD",
-							Schema:   Schema{reqField("Inside", "INTEGER")},
-						},
-					},
-				},
-			},
-		},
-		{
-			in: ptrNested{},
-			want: Schema{
-				&FieldSchema{
-					Name:     "Ptr",
-					Required: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("Inside", "INTEGER")},
-				},
-			},
-		},
-		{
-			in: dup{},
-			want: Schema{
-				&FieldSchema{
-					Name:     "A",
-					Required: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("Bool", "BOOLEAN")},
-				},
-				&FieldSchema{
-					Name:     "B",
-					Required: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("Bool", "BOOLEAN")},
-				},
-			},
-		},
-	}
-
-	for _, tc := range testCases {
-		got, err := InferSchema(tc.in)
-		if err != nil {
-			t.Fatalf("%T: error inferring TableSchema: %v", tc.in, err)
-		}
-		if !testutil.Equal(got, tc.want) {
-			t.Errorf("%T: inferring TableSchema: got:\n%#v\nwant:\n%#v", tc.in,
-				pretty.Value(got), pretty.Value(tc.want))
-		}
-	}
-}
-
-type repeated struct {
-	NotRepeated       []byte
-	RepeatedByteSlice [][]byte
-	Slice             []int
-	Array             [5]bool
-}
-
-type nestedRepeated struct {
-	NotRepeated int
-	Repeated    []struct {
-		Inside int
-	}
-	RepeatedPtr []*struct{ Inside int }
-}
-
-func repField(name, typ string) *FieldSchema {
-	return &FieldSchema{
-		Name:     name,
-		Type:     FieldType(typ),
-		Repeated: true,
-	}
-}
-
-func TestRepeatedInference(t *testing.T) {
-	testCases := []struct {
-		in   interface{}
-		want Schema
-	}{
-		{
-			in: repeated{},
-			want: Schema{
-				reqField("NotRepeated", "BYTES"),
-				repField("RepeatedByteSlice", "BYTES"),
-				repField("Slice", "INTEGER"),
-				repField("Array", "BOOLEAN"),
-			},
-		},
-		{
-			in: nestedRepeated{},
-			want: Schema{
-				reqField("NotRepeated", "INTEGER"),
-				{
-					Name:     "Repeated",
-					Repeated: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("Inside", "INTEGER")},
-				},
-				{
-					Name:     "RepeatedPtr",
-					Repeated: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("Inside", "INTEGER")},
-				},
-			},
-		},
-	}
-
-	for i, tc := range testCases {
-		got, err := InferSchema(tc.in)
-		if err != nil {
-			t.Fatalf("%d: error inferring TableSchema: %v", i, err)
-		}
-		if !testutil.Equal(got, tc.want) {
-			t.Errorf("%d: inferring TableSchema: got:\n%#v\nwant:\n%#v", i,
-				pretty.Value(got), pretty.Value(tc.want))
-		}
-	}
-}
-
-type allNulls struct {
-	A NullInt64
-	B NullFloat64
-	C NullBool
-	D NullString
-	E NullTimestamp
-	F NullTime
-	G NullDate
-	H NullDateTime
-}
-
-func TestNullInference(t *testing.T) {
-	got, err := InferSchema(allNulls{})
-	if err != nil {
-		t.Fatal(err)
-	}
-	want := Schema{
-		optField("A", "INTEGER"),
-		optField("B", "FLOAT"),
-		optField("C", "BOOLEAN"),
-		optField("D", "STRING"),
-		optField("E", "TIMESTAMP"),
-		optField("F", "TIME"),
-		optField("G", "DATE"),
-		optField("H", "DATETIME"),
-	}
-	if diff := testutil.Diff(got, want); diff != "" {
-		t.Error(diff)
-	}
-}
-
-type Embedded struct {
-	Embedded int
-}
-
-type embedded struct {
-	Embedded2 int
-}
-
-type nestedEmbedded struct {
-	Embedded
-	embedded
-}
-
-func TestEmbeddedInference(t *testing.T) {
-	got, err := InferSchema(nestedEmbedded{})
-	if err != nil {
-		t.Fatal(err)
-	}
-	want := Schema{
-		reqField("Embedded", "INTEGER"),
-		reqField("Embedded2", "INTEGER"),
-	}
-	if !testutil.Equal(got, want) {
-		t.Errorf("got %v, want %v", pretty.Value(got), pretty.Value(want))
-	}
-}
-
-func TestRecursiveInference(t *testing.T) {
-	type List struct {
-		Val  int
-		Next *List
-	}
-
-	_, err := InferSchema(List{})
-	if err == nil {
-		t.Fatal("got nil, want error")
-	}
-}
-
-type withTags struct {
-	NoTag         int
-	ExcludeTag    int      `bigquery:"-"`
-	SimpleTag     int      `bigquery:"simple_tag"`
-	UnderscoreTag int      `bigquery:"_id"`
-	MixedCase     int      `bigquery:"MIXEDcase"`
-	Nullable      []byte   `bigquery:",nullable"`
-	NullNumeric   *big.Rat `bigquery:",nullable"`
-}
-
-type withTagsNested struct {
-	Nested          withTags `bigquery:"nested"`
-	NestedAnonymous struct {
-		ExcludeTag int `bigquery:"-"`
-		Inside     int `bigquery:"inside"`
-	} `bigquery:"anon"`
-	PNested         *struct{ X int } // not nullable, for backwards compatibility
-	PNestedNullable *struct{ X int } `bigquery:",nullable"`
-}
-
-type withTagsRepeated struct {
-	Repeated          []withTags `bigquery:"repeated"`
-	RepeatedAnonymous []struct {
-		ExcludeTag int `bigquery:"-"`
-		Inside     int `bigquery:"inside"`
-	} `bigquery:"anon"`
-}
-
-type withTagsEmbedded struct {
-	withTags
-}
-
-var withTagsSchema = Schema{
-	reqField("NoTag", "INTEGER"),
-	reqField("simple_tag", "INTEGER"),
-	reqField("_id", "INTEGER"),
-	reqField("MIXEDcase", "INTEGER"),
-	optField("Nullable", "BYTES"),
-	optField("NullNumeric", "NUMERIC"),
-}
-
-func TestTagInference(t *testing.T) {
-	testCases := []struct {
-		in   interface{}
-		want Schema
-	}{
-		{
-			in:   withTags{},
-			want: withTagsSchema,
-		},
-		{
-			in: withTagsNested{},
-			want: Schema{
-				&FieldSchema{
-					Name:     "nested",
-					Required: true,
-					Type:     "RECORD",
-					Schema:   withTagsSchema,
-				},
-				&FieldSchema{
-					Name:     "anon",
-					Required: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("inside", "INTEGER")},
-				},
-				&FieldSchema{
-					Name:     "PNested",
-					Required: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("X", "INTEGER")},
-				},
-				&FieldSchema{
-					Name:     "PNestedNullable",
-					Required: false,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("X", "INTEGER")},
-				},
-			},
-		},
-		{
-			in: withTagsRepeated{},
-			want: Schema{
-				&FieldSchema{
-					Name:     "repeated",
-					Repeated: true,
-					Type:     "RECORD",
-					Schema:   withTagsSchema,
-				},
-				&FieldSchema{
-					Name:     "anon",
-					Repeated: true,
-					Type:     "RECORD",
-					Schema:   Schema{reqField("inside", "INTEGER")},
-				},
-			},
-		},
-		{
-			in:   withTagsEmbedded{},
-			want: withTagsSchema,
-		},
-	}
-	for i, tc := range testCases {
-		got, err := InferSchema(tc.in)
-		if err != nil {
-			t.Fatalf("%d: error inferring TableSchema: %v", i, err)
-		}
-		if !testutil.Equal(got, tc.want) {
-			t.Errorf("%d: inferring TableSchema: got:\n%#v\nwant:\n%#v", i,
-				pretty.Value(got), pretty.Value(tc.want))
-		}
-	}
-}
-
-func TestTagInferenceErrors(t *testing.T) {
-	testCases := []struct {
-		in  interface{}
-		err error
-	}{
-		{
-			in: struct {
-				LongTag int `bigquery:"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy"`
-			}{},
-			err: errInvalidFieldName,
-		},
-		{
-			in: struct {
-				UnsupporedStartChar int `bigquery:"øab"`
-			}{},
-			err: errInvalidFieldName,
-		},
-		{
-			in: struct {
-				UnsupportedEndChar int `bigquery:"abø"`
-			}{},
-			err: errInvalidFieldName,
-		},
-		{
-			in: struct {
-				UnsupportedMiddleChar int `bigquery:"aøb"`
-			}{},
-			err: errInvalidFieldName,
-		},
-		{
-			in: struct {
-				StartInt int `bigquery:"1abc"`
-			}{},
-			err: errInvalidFieldName,
-		},
-		{
-			in: struct {
-				Hyphens int `bigquery:"a-b"`
-			}{},
-			err: errInvalidFieldName,
-		},
-	}
-	for i, tc := range testCases {
-		want := tc.err
-		_, got := InferSchema(tc.in)
-		if got != want {
-			t.Errorf("%d: inferring TableSchema: got:\n%#v\nwant:\n%#v", i, got, want)
-		}
-	}
-
-	_, err := InferSchema(struct {
-		X int `bigquery:",optional"`
-	}{})
-	if err == nil {
-		t.Error("got nil, want error")
-	}
-}
-
-func TestSchemaErrors(t *testing.T) {
-	testCases := []struct {
-		in  interface{}
-		err error
-	}{
-		{
-			in:  []byte{},
-			err: errNoStruct,
-		},
-		{
-			in:  new(int),
-			err: errNoStruct,
-		},
-		{
-			in:  struct{ Uint uint }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ Uint64 uint64 }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ Uintptr uintptr }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ Complex complex64 }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ Map map[string]int }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ Chan chan bool }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ Ptr *int }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ Interface interface{} }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ MultiDimensional [][]int }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ MultiDimensional [][][]byte }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ SliceOfPointer []*int }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ SliceOfNull []NullInt64 }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ ChanSlice []chan bool }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ NestedChan struct{ Chan []chan bool } }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in: struct {
-				X int `bigquery:",nullable"`
-			}{},
-			err: errBadNullable,
-		},
-		{
-			in: struct {
-				X bool `bigquery:",nullable"`
-			}{},
-			err: errBadNullable,
-		},
-		{
-			in: struct {
-				X struct{ N int } `bigquery:",nullable"`
-			}{},
-			err: errBadNullable,
-		},
-		{
-			in: struct {
-				X []int `bigquery:",nullable"`
-			}{},
-			err: errBadNullable,
-		},
-		{
-			in:  struct{ X *[]byte }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ X *[]int }{},
-			err: errUnsupportedFieldType,
-		},
-		{
-			in:  struct{ X *int }{},
-			err: errUnsupportedFieldType,
-		},
-	}
-	for _, tc := range testCases {
-		want := tc.err
-		_, got := InferSchema(tc.in)
-		if got != want {
-			t.Errorf("%#v: got:\n%#v\nwant:\n%#v", tc.in, got, want)
-		}
-	}
-}
-
-func TestHasRecursiveType(t *testing.T) {
-	type (
-		nonStruct int
-		nonRec    struct{ A string }
-		dup       struct{ A, B nonRec }
-		rec       struct {
-			A int
-			B *rec
-		}
-		recUnexported struct {
-			A int
-		}
-		hasRec struct {
-			A int
-			R *rec
-		}
-		recSlicePointer struct {
-			A []*recSlicePointer
-		}
-	)
-	for _, test := range []struct {
-		in   interface{}
-		want bool
-	}{
-		{nonStruct(0), false},
-		{nonRec{}, false},
-		{dup{}, false},
-		{rec{}, true},
-		{recUnexported{}, false},
-		{hasRec{}, true},
-		{&recSlicePointer{}, true},
-	} {
-		got, err := hasRecursiveType(reflect.TypeOf(test.in), nil)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if got != test.want {
-			t.Errorf("%T: got %t, want %t", test.in, got, test.want)
-		}
-	}
-}
-
-func TestSchemaFromJSON(t *testing.T) {
-	testCasesExpectingSuccess := []struct {
-		bqSchemaJSON   []byte
-		description    string
-		expectedSchema Schema
-	}{
-		{
-			description: "Flat table with a mixture of NULLABLE and REQUIRED fields",
-			bqSchemaJSON: []byte(`
-[
-	{"name":"flat_string","type":"STRING","mode":"NULLABLE","description":"Flat nullable string"},
-	{"name":"flat_bytes","type":"BYTES","mode":"REQUIRED","description":"Flat required BYTES"},
-	{"name":"flat_integer","type":"INTEGER","mode":"NULLABLE","description":"Flat nullable INTEGER"},
-	{"name":"flat_float","type":"FLOAT","mode":"REQUIRED","description":"Flat required FLOAT"},
-	{"name":"flat_boolean","type":"BOOLEAN","mode":"NULLABLE","description":"Flat nullable BOOLEAN"},
-	{"name":"flat_timestamp","type":"TIMESTAMP","mode":"REQUIRED","description":"Flat required TIMESTAMP"},
-	{"name":"flat_date","type":"DATE","mode":"NULLABLE","description":"Flat required DATE"},
-	{"name":"flat_time","type":"TIME","mode":"REQUIRED","description":"Flat nullable TIME"},
-	{"name":"flat_datetime","type":"DATETIME","mode":"NULLABLE","description":"Flat required DATETIME"},
-	{"name":"flat_numeric","type":"NUMERIC","mode":"REQUIRED","description":"Flat nullable NUMERIC"}
-]`),
-			expectedSchema: Schema{
-				fieldSchema("Flat nullable string", "flat_string", "STRING", false, false),
-				fieldSchema("Flat required BYTES", "flat_bytes", "BYTES", false, true),
-				fieldSchema("Flat nullable INTEGER", "flat_integer", "INTEGER", false, false),
-				fieldSchema("Flat required FLOAT", "flat_float", "FLOAT", false, true),
-				fieldSchema("Flat nullable BOOLEAN", "flat_boolean", "BOOLEAN", false, false),
-				fieldSchema("Flat required TIMESTAMP", "flat_timestamp", "TIMESTAMP", false, true),
-				fieldSchema("Flat required DATE", "flat_date", "DATE", false, false),
-				fieldSchema("Flat nullable TIME", "flat_time", "TIME", false, true),
-				fieldSchema("Flat required DATETIME", "flat_datetime", "DATETIME", false, false),
-				fieldSchema("Flat nullable NUMERIC", "flat_numeric", "NUMERIC", false, true),
-			},
-		},
-		{
-			description: "Table with a nested RECORD",
-			bqSchemaJSON: []byte(`
-[
-	{"name":"flat_string","type":"STRING","mode":"NULLABLE","description":"Flat nullable string"},
-	{"name":"nested_record","type":"RECORD","mode":"NULLABLE","description":"Nested nullable RECORD","fields":[{"name":"record_field_1","type":"STRING","mode":"NULLABLE","description":"First nested record field"},{"name":"record_field_2","type":"INTEGER","mode":"REQUIRED","description":"Second nested record field"}]}
-]`),
-			expectedSchema: Schema{
-				fieldSchema("Flat nullable string", "flat_string", "STRING", false, false),
-				&FieldSchema{
-					Description: "Nested nullable RECORD",
-					Name:        "nested_record",
-					Required:    false,
-					Type:        "RECORD",
-					Schema: Schema{
-						{
-							Description: "First nested record field",
-							Name:        "record_field_1",
-							Required:    false,
-							Type:        "STRING",
-						},
-						{
-							Description: "Second nested record field",
-							Name:        "record_field_2",
-							Required:    true,
-							Type:        "INTEGER",
-						},
-					},
-				},
-			},
-		},
-		{
-			description: "Table with a repeated RECORD",
-			bqSchemaJSON: []byte(`
-[
-	{"name":"flat_string","type":"STRING","mode":"NULLABLE","description":"Flat nullable string"},
-	{"name":"nested_record","type":"RECORD","mode":"REPEATED","description":"Nested nullable RECORD","fields":[{"name":"record_field_1","type":"STRING","mode":"NULLABLE","description":"First nested record field"},{"name":"record_field_2","type":"INTEGER","mode":"REQUIRED","description":"Second nested record field"}]}
-]`),
-			expectedSchema: Schema{
-				fieldSchema("Flat nullable string", "flat_string", "STRING", false, false),
-				&FieldSchema{
-					Description: "Nested nullable RECORD",
-					Name:        "nested_record",
-					Repeated:    true,
-					Required:    false,
-					Type:        "RECORD",
-					Schema: Schema{
-						{
-							Description: "First nested record field",
-							Name:        "record_field_1",
-							Required:    false,
-							Type:        "STRING",
-						},
-						{
-							Description: "Second nested record field",
-							Name:        "record_field_2",
-							Required:    true,
-							Type:        "INTEGER",
-						},
-					},
-				},
-			},
-		},
-	}
-	for _, tc := range testCasesExpectingSuccess {
-		convertedSchema, err := SchemaFromJSON(tc.bqSchemaJSON)
-		if err != nil {
-			t.Errorf("encountered an error when converting JSON table schema (%s): %v", tc.description, err)
-			continue
-		}
-		if !testutil.Equal(convertedSchema, tc.expectedSchema) {
-			t.Errorf("generated JSON table schema (%s) differs from the expected schema", tc.description)
-		}
-	}
-
-	testCasesExpectingFailure := []struct {
-		bqSchemaJSON []byte
-		description  string
-	}{
-		{
-			description:  "Schema with invalid JSON",
-			bqSchemaJSON: []byte(`This is not JSON`),
-		},
-		{
-			description:  "Schema with unknown field type",
-			bqSchemaJSON: []byte(`[{"name":"strange_type","type":"STRANGE","description":"This type should not exist"}]`),
-		},
-		{
-			description:  "Schema with zero length",
-			bqSchemaJSON: []byte(``),
-		},
-	}
-	for _, tc := range testCasesExpectingFailure {
-		_, err := SchemaFromJSON(tc.bqSchemaJSON)
-		if err == nil {
-			t.Errorf("converting this schema should have returned an error (%s): %v", tc.description, err)
-			continue
-		}
-	}
-}

+ 0 - 255
vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/big_query_storage_client.go

@@ -1,255 +0,0 @@
-// 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 storage
-
-import (
-	"context"
-	"fmt"
-	"time"
-
-	gax "github.com/googleapis/gax-go/v2"
-	"google.golang.org/api/option"
-	"google.golang.org/api/transport"
-	storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1beta1"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/metadata"
-)
-
-// BigQueryStorageCallOptions contains the retry settings for each method of BigQueryStorageClient.
-type BigQueryStorageCallOptions struct {
-	CreateReadSession             []gax.CallOption
-	ReadRows                      []gax.CallOption
-	BatchCreateReadSessionStreams []gax.CallOption
-	FinalizeStream                []gax.CallOption
-	SplitReadStream               []gax.CallOption
-}
-
-func defaultBigQueryStorageClientOptions() []option.ClientOption {
-	return []option.ClientOption{
-		option.WithEndpoint("bigquerystorage.googleapis.com:443"),
-		option.WithScopes(DefaultAuthScopes()...),
-	}
-}
-
-func defaultBigQueryStorageCallOptions() *BigQueryStorageCallOptions {
-	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 &BigQueryStorageCallOptions{
-		CreateReadSession:             retry[[2]string{"default", "idempotent"}],
-		ReadRows:                      retry[[2]string{"default", "idempotent"}],
-		BatchCreateReadSessionStreams: retry[[2]string{"default", "idempotent"}],
-		FinalizeStream:                retry[[2]string{"default", "idempotent"}],
-		SplitReadStream:               retry[[2]string{"default", "idempotent"}],
-	}
-}
-
-// BigQueryStorageClient is a client for interacting with BigQuery Storage API.
-//
-// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
-type BigQueryStorageClient struct {
-	// The connection to the service.
-	conn *grpc.ClientConn
-
-	// The gRPC API client.
-	bigQueryStorageClient storagepb.BigQueryStorageClient
-
-	// The call options for this service.
-	CallOptions *BigQueryStorageCallOptions
-
-	// The x-goog-* metadata to be sent with each request.
-	xGoogMetadata metadata.MD
-}
-
-// NewBigQueryStorageClient creates a new big query storage client.
-//
-// BigQuery storage API.
-//
-// The BigQuery storage API can be used to read data stored in BigQuery.
-func NewBigQueryStorageClient(ctx context.Context, opts ...option.ClientOption) (*BigQueryStorageClient, error) {
-	conn, err := transport.DialGRPC(ctx, append(defaultBigQueryStorageClientOptions(), opts...)...)
-	if err != nil {
-		return nil, err
-	}
-	c := &BigQueryStorageClient{
-		conn:        conn,
-		CallOptions: defaultBigQueryStorageCallOptions(),
-
-		bigQueryStorageClient: storagepb.NewBigQueryStorageClient(conn),
-	}
-	c.setGoogleClientInfo()
-	return c, nil
-}
-
-// Connection returns the client's connection to the API service.
-func (c *BigQueryStorageClient) 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 *BigQueryStorageClient) 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 *BigQueryStorageClient) 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...))
-}
-
-// CreateReadSession creates a new read session. A read session divides the contents of a
-// BigQuery table into one or more streams, which can then be used to read
-// data from the table. The read session also specifies properties of the
-// data to be read, such as a list of columns or a push-down filter describing
-// the rows to be returned.
-//
-// A particular row can be read by at most one stream. When the caller has
-// reached the end of each stream in the session, then all the data in the
-// table has been read.
-//
-// Read sessions automatically expire 24 hours after they are created and do
-// not require manual clean-up by the caller.
-func (c *BigQueryStorageClient) CreateReadSession(ctx context.Context, req *storagepb.CreateReadSessionRequest, opts ...gax.CallOption) (*storagepb.ReadSession, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "table_reference.project_id", req.GetTableReference().GetProjectId(), "table_reference.dataset_id", req.GetTableReference().GetDatasetId()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.CreateReadSession[0:len(c.CallOptions.CreateReadSession):len(c.CallOptions.CreateReadSession)], opts...)
-	var resp *storagepb.ReadSession
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.bigQueryStorageClient.CreateReadSession(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// ReadRows reads rows from the table in the format prescribed by the read session.
-// Each response contains one or more table rows, up to a maximum of 10 MiB
-// per response; read requests which attempt to read individual rows larger
-// than this will fail.
-//
-// Each request also returns a set of stream statistics reflecting the
-// estimated total number of rows in the read stream. This number is computed
-// based on the total table size and the number of active streams in the read
-// session, and may change as other streams continue to read data.
-func (c *BigQueryStorageClient) ReadRows(ctx context.Context, req *storagepb.ReadRowsRequest, opts ...gax.CallOption) (storagepb.BigQueryStorage_ReadRowsClient, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "read_position.stream.name", req.GetReadPosition().GetStream().GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.ReadRows[0:len(c.CallOptions.ReadRows):len(c.CallOptions.ReadRows)], opts...)
-	var resp storagepb.BigQueryStorage_ReadRowsClient
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.bigQueryStorageClient.ReadRows(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// BatchCreateReadSessionStreams creates additional streams for a ReadSession. This API can be used to
-// dynamically adjust the parallelism of a batch processing task upwards by
-// adding additional workers.
-func (c *BigQueryStorageClient) BatchCreateReadSessionStreams(ctx context.Context, req *storagepb.BatchCreateReadSessionStreamsRequest, opts ...gax.CallOption) (*storagepb.BatchCreateReadSessionStreamsResponse, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "session.name", req.GetSession().GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.BatchCreateReadSessionStreams[0:len(c.CallOptions.BatchCreateReadSessionStreams):len(c.CallOptions.BatchCreateReadSessionStreams)], opts...)
-	var resp *storagepb.BatchCreateReadSessionStreamsResponse
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.bigQueryStorageClient.BatchCreateReadSessionStreams(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}
-
-// FinalizeStream triggers the graceful termination of a single stream in a ReadSession. This
-// API can be used to dynamically adjust the parallelism of a batch processing
-// task downwards without losing data.
-//
-// This API does not delete the stream -- it remains visible in the
-// ReadSession, and any data processed by the stream is not released to other
-// streams. However, no additional data will be assigned to the stream once
-// this call completes. Callers must continue reading data on the stream until
-// the end of the stream is reached so that data which has already been
-// assigned to the stream will be processed.
-//
-// This method will return an error if there are no other live streams
-// in the Session, or if SplitReadStream() has been called on the given
-// Stream.
-func (c *BigQueryStorageClient) FinalizeStream(ctx context.Context, req *storagepb.FinalizeStreamRequest, opts ...gax.CallOption) error {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "stream.name", req.GetStream().GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.FinalizeStream[0:len(c.CallOptions.FinalizeStream):len(c.CallOptions.FinalizeStream)], opts...)
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		_, err = c.bigQueryStorageClient.FinalizeStream(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	return err
-}
-
-// SplitReadStream splits a given read stream into two Streams. These streams are referred to
-// as the primary and the residual of the split. The original stream can still
-// be read from in the same manner as before. Both of the returned streams can
-// also be read from, and the total rows return by both child streams will be
-// the same as the rows read from the original stream.
-//
-// Moreover, the two child streams will be allocated back to back in the
-// original Stream. Concretely, it is guaranteed that for streams Original,
-// Primary, and Residual, that Original[0-j] = Primary[0-j] and
-// Original[j-n] = Residual[0-m] once the streams have been read to
-// completion.
-//
-// This method is guaranteed to be idempotent.
-func (c *BigQueryStorageClient) SplitReadStream(ctx context.Context, req *storagepb.SplitReadStreamRequest, opts ...gax.CallOption) (*storagepb.SplitReadStreamResponse, error) {
-	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "original_stream.name", req.GetOriginalStream().GetName()))
-	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
-	opts = append(c.CallOptions.SplitReadStream[0:len(c.CallOptions.SplitReadStream):len(c.CallOptions.SplitReadStream)], opts...)
-	var resp *storagepb.SplitReadStreamResponse
-	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
-		var err error
-		resp, err = c.bigQueryStorageClient.SplitReadStream(ctx, req, settings.GRPC...)
-		return err
-	}, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return resp, nil
-}

+ 0 - 132
vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/big_query_storage_client_example_test.go

@@ -1,132 +0,0 @@
-// 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 storage_test
-
-import (
-	"context"
-	"io"
-
-	storage "cloud.google.com/go/bigquery/storage/apiv1beta1"
-	storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1beta1"
-)
-
-func ExampleNewBigQueryStorageClient() {
-	ctx := context.Background()
-	c, err := storage.NewBigQueryStorageClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use client.
-	_ = c
-}
-
-func ExampleBigQueryStorageClient_CreateReadSession() {
-	ctx := context.Background()
-	c, err := storage.NewBigQueryStorageClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &storagepb.CreateReadSessionRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.CreateReadSession(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleBigQueryStorageClient_ReadRows() {
-	ctx := context.Background()
-	c, err := storage.NewBigQueryStorageClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &storagepb.ReadRowsRequest{
-		// TODO: Fill request struct fields.
-	}
-	stream, err := c.ReadRows(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	for {
-		resp, err := stream.Recv()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			// TODO: handle error.
-		}
-		// TODO: Use resp.
-		_ = resp
-	}
-}
-
-func ExampleBigQueryStorageClient_BatchCreateReadSessionStreams() {
-	ctx := context.Background()
-	c, err := storage.NewBigQueryStorageClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &storagepb.BatchCreateReadSessionStreamsRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.BatchCreateReadSessionStreams(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}
-
-func ExampleBigQueryStorageClient_FinalizeStream() {
-	ctx := context.Background()
-	c, err := storage.NewBigQueryStorageClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &storagepb.FinalizeStreamRequest{
-		// TODO: Fill request struct fields.
-	}
-	err = c.FinalizeStream(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-}
-
-func ExampleBigQueryStorageClient_SplitReadStream() {
-	ctx := context.Background()
-	c, err := storage.NewBigQueryStorageClient(ctx)
-	if err != nil {
-		// TODO: Handle error.
-	}
-
-	req := &storagepb.SplitReadStreamRequest{
-		// TODO: Fill request struct fields.
-	}
-	resp, err := c.SplitReadStream(ctx, req)
-	if err != nil {
-		// TODO: Handle error.
-	}
-	// TODO: Use resp.
-	_ = resp
-}

+ 0 - 89
vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/doc.go

@@ -1,89 +0,0 @@
-// 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 storage is an auto-generated package for the
-// BigQuery Storage API.
-//
-//   NOTE: This package is in beta. It is not stable, and may be subject to changes.
-//
-package storage // import "cloud.google.com/go/bigquery/storage/apiv1beta1"
-
-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/bigquery",
-		"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 = "20190121"

+ 0 - 452
vendor/cloud.google.com/go/bigquery/storage/apiv1beta1/mock_test.go

@@ -1,452 +0,0 @@
-// 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 storage
-
-import (
-	emptypb "github.com/golang/protobuf/ptypes/empty"
-	storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1beta1"
-)
-
-import (
-	"context"
-	"flag"
-	"fmt"
-	"io"
-	"log"
-	"net"
-	"os"
-	"strings"
-	"testing"
-
-	"github.com/golang/protobuf/proto"
-	"github.com/golang/protobuf/ptypes"
-	"google.golang.org/api/option"
-	status "google.golang.org/genproto/googleapis/rpc/status"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/metadata"
-	gstatus "google.golang.org/grpc/status"
-)
-
-var _ = io.EOF
-var _ = ptypes.MarshalAny
-var _ status.Status
-
-type mockBigQueryStorageServer struct {
-	// Embed for forward compatibility.
-	// Tests will keep working if more methods are added
-	// in the future.
-	storagepb.BigQueryStorageServer
-
-	reqs []proto.Message
-
-	// If set, all calls return this error.
-	err error
-
-	// responses to return if err == nil
-	resps []proto.Message
-}
-
-func (s *mockBigQueryStorageServer) CreateReadSession(ctx context.Context, req *storagepb.CreateReadSessionRequest) (*storagepb.ReadSession, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*storagepb.ReadSession), nil
-}
-
-func (s *mockBigQueryStorageServer) ReadRows(req *storagepb.ReadRowsRequest, stream storagepb.BigQueryStorage_ReadRowsServer) error {
-	md, _ := metadata.FromIncomingContext(stream.Context())
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return s.err
-	}
-	for _, v := range s.resps {
-		if err := stream.Send(v.(*storagepb.ReadRowsResponse)); err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func (s *mockBigQueryStorageServer) BatchCreateReadSessionStreams(ctx context.Context, req *storagepb.BatchCreateReadSessionStreamsRequest) (*storagepb.BatchCreateReadSessionStreamsResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*storagepb.BatchCreateReadSessionStreamsResponse), nil
-}
-
-func (s *mockBigQueryStorageServer) FinalizeStream(ctx context.Context, req *storagepb.FinalizeStreamRequest) (*emptypb.Empty, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*emptypb.Empty), nil
-}
-
-func (s *mockBigQueryStorageServer) SplitReadStream(ctx context.Context, req *storagepb.SplitReadStreamRequest) (*storagepb.SplitReadStreamResponse, error) {
-	md, _ := metadata.FromIncomingContext(ctx)
-	if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
-		return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
-	}
-	s.reqs = append(s.reqs, req)
-	if s.err != nil {
-		return nil, s.err
-	}
-	return s.resps[0].(*storagepb.SplitReadStreamResponse), nil
-}
-
-// clientOpt is the option tests should use to connect to the test server.
-// It is initialized by TestMain.
-var clientOpt option.ClientOption
-
-var (
-	mockBigQueryStorage mockBigQueryStorageServer
-)
-
-func TestMain(m *testing.M) {
-	flag.Parse()
-
-	serv := grpc.NewServer()
-	storagepb.RegisterBigQueryStorageServer(serv, &mockBigQueryStorage)
-
-	lis, err := net.Listen("tcp", "localhost:0")
-	if err != nil {
-		log.Fatal(err)
-	}
-	go serv.Serve(lis)
-
-	conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
-	if err != nil {
-		log.Fatal(err)
-	}
-	clientOpt = option.WithGRPCConn(conn)
-
-	os.Exit(m.Run())
-}
-
-func TestBigQueryStorageCreateReadSession(t *testing.T) {
-	var name string = "name3373707"
-	var expectedResponse = &storagepb.ReadSession{
-		Name: name,
-	}
-
-	mockBigQueryStorage.err = nil
-	mockBigQueryStorage.reqs = nil
-
-	mockBigQueryStorage.resps = append(mockBigQueryStorage.resps[:0], expectedResponse)
-
-	var tableReference *storagepb.TableReference = &storagepb.TableReference{}
-	var parent string = "parent-995424086"
-	var request = &storagepb.CreateReadSessionRequest{
-		TableReference: tableReference,
-		Parent:         parent,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.CreateReadSession(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockBigQueryStorage.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestBigQueryStorageCreateReadSessionError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockBigQueryStorage.err = gstatus.Error(errCode, "test error")
-
-	var tableReference *storagepb.TableReference = &storagepb.TableReference{}
-	var parent string = "parent-995424086"
-	var request = &storagepb.CreateReadSessionRequest{
-		TableReference: tableReference,
-		Parent:         parent,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.CreateReadSession(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestBigQueryStorageReadRows(t *testing.T) {
-	var expectedResponse *storagepb.ReadRowsResponse = &storagepb.ReadRowsResponse{}
-
-	mockBigQueryStorage.err = nil
-	mockBigQueryStorage.reqs = nil
-
-	mockBigQueryStorage.resps = append(mockBigQueryStorage.resps[:0], expectedResponse)
-
-	var readPosition *storagepb.StreamPosition = &storagepb.StreamPosition{}
-	var request = &storagepb.ReadRowsRequest{
-		ReadPosition: readPosition,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	stream, err := c.ReadRows(context.Background(), request)
-	if err != nil {
-		t.Fatal(err)
-	}
-	resp, err := stream.Recv()
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockBigQueryStorage.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestBigQueryStorageReadRowsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockBigQueryStorage.err = gstatus.Error(errCode, "test error")
-
-	var readPosition *storagepb.StreamPosition = &storagepb.StreamPosition{}
-	var request = &storagepb.ReadRowsRequest{
-		ReadPosition: readPosition,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	stream, err := c.ReadRows(context.Background(), request)
-	if err != nil {
-		t.Fatal(err)
-	}
-	resp, err := stream.Recv()
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestBigQueryStorageBatchCreateReadSessionStreams(t *testing.T) {
-	var expectedResponse *storagepb.BatchCreateReadSessionStreamsResponse = &storagepb.BatchCreateReadSessionStreamsResponse{}
-
-	mockBigQueryStorage.err = nil
-	mockBigQueryStorage.reqs = nil
-
-	mockBigQueryStorage.resps = append(mockBigQueryStorage.resps[:0], expectedResponse)
-
-	var session *storagepb.ReadSession = &storagepb.ReadSession{}
-	var requestedStreams int32 = 1017221410
-	var request = &storagepb.BatchCreateReadSessionStreamsRequest{
-		Session:          session,
-		RequestedStreams: requestedStreams,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.BatchCreateReadSessionStreams(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockBigQueryStorage.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestBigQueryStorageBatchCreateReadSessionStreamsError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockBigQueryStorage.err = gstatus.Error(errCode, "test error")
-
-	var session *storagepb.ReadSession = &storagepb.ReadSession{}
-	var requestedStreams int32 = 1017221410
-	var request = &storagepb.BatchCreateReadSessionStreamsRequest{
-		Session:          session,
-		RequestedStreams: requestedStreams,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.BatchCreateReadSessionStreams(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}
-func TestBigQueryStorageFinalizeStream(t *testing.T) {
-	var expectedResponse *emptypb.Empty = &emptypb.Empty{}
-
-	mockBigQueryStorage.err = nil
-	mockBigQueryStorage.reqs = nil
-
-	mockBigQueryStorage.resps = append(mockBigQueryStorage.resps[:0], expectedResponse)
-
-	var stream *storagepb.Stream = &storagepb.Stream{}
-	var request = &storagepb.FinalizeStreamRequest{
-		Stream: stream,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = c.FinalizeStream(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockBigQueryStorage.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-}
-
-func TestBigQueryStorageFinalizeStreamError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockBigQueryStorage.err = gstatus.Error(errCode, "test error")
-
-	var stream *storagepb.Stream = &storagepb.Stream{}
-	var request = &storagepb.FinalizeStreamRequest{
-		Stream: stream,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	err = c.FinalizeStream(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-}
-func TestBigQueryStorageSplitReadStream(t *testing.T) {
-	var expectedResponse *storagepb.SplitReadStreamResponse = &storagepb.SplitReadStreamResponse{}
-
-	mockBigQueryStorage.err = nil
-	mockBigQueryStorage.reqs = nil
-
-	mockBigQueryStorage.resps = append(mockBigQueryStorage.resps[:0], expectedResponse)
-
-	var originalStream *storagepb.Stream = &storagepb.Stream{}
-	var request = &storagepb.SplitReadStreamRequest{
-		OriginalStream: originalStream,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.SplitReadStream(context.Background(), request)
-
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	if want, got := request, mockBigQueryStorage.reqs[0]; !proto.Equal(want, got) {
-		t.Errorf("wrong request %q, want %q", got, want)
-	}
-
-	if want, got := expectedResponse, resp; !proto.Equal(want, got) {
-		t.Errorf("wrong response %q, want %q)", got, want)
-	}
-}
-
-func TestBigQueryStorageSplitReadStreamError(t *testing.T) {
-	errCode := codes.PermissionDenied
-	mockBigQueryStorage.err = gstatus.Error(errCode, "test error")
-
-	var originalStream *storagepb.Stream = &storagepb.Stream{}
-	var request = &storagepb.SplitReadStreamRequest{
-		OriginalStream: originalStream,
-	}
-
-	c, err := NewBigQueryStorageClient(context.Background(), clientOpt)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	resp, err := c.SplitReadStream(context.Background(), request)
-
-	if st, ok := gstatus.FromError(err); !ok {
-		t.Errorf("got error %v, expected grpc error", err)
-	} else if c := st.Code(); c != errCode {
-		t.Errorf("got error code %q, want %q", c, errCode)
-	}
-	_ = resp
-}

+ 0 - 620
vendor/cloud.google.com/go/bigquery/table.go

@@ -1,620 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"time"
-
-	"cloud.google.com/go/internal/optional"
-	"cloud.google.com/go/internal/trace"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// A Table is a reference to a BigQuery table.
-type Table struct {
-	// ProjectID, DatasetID and TableID may be omitted if the Table is the destination for a query.
-	// In this case the result will be stored in an ephemeral table.
-	ProjectID string
-	DatasetID string
-	// TableID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_).
-	// The maximum length is 1,024 characters.
-	TableID string
-
-	c *Client
-}
-
-// TableMetadata contains information about a BigQuery table.
-type TableMetadata struct {
-	// The following fields can be set when creating a table.
-
-	// The user-friendly name for the table.
-	Name string
-
-	// The user-friendly description of the table.
-	Description string
-
-	// The table schema. If provided on create, ViewQuery must be empty.
-	Schema Schema
-
-	// The query to use for a view. If provided on create, Schema must be nil.
-	ViewQuery string
-
-	// Use Legacy SQL for the view query.
-	// At most one of UseLegacySQL and UseStandardSQL can be true.
-	UseLegacySQL bool
-
-	// Use Legacy SQL for the view query. The default.
-	// At most one of UseLegacySQL and UseStandardSQL can be true.
-	// Deprecated: use UseLegacySQL.
-	UseStandardSQL bool
-
-	// If non-nil, the table is partitioned by time.
-	TimePartitioning *TimePartitioning
-
-	// Clustering specifies the data clustering configuration for the table.
-	Clustering *Clustering
-
-	// The time when this table expires. If set, this table will expire at the
-	// specified time. Expired tables will be deleted and their storage
-	// reclaimed. The zero value is ignored.
-	ExpirationTime time.Time
-
-	// User-provided labels.
-	Labels map[string]string
-
-	// Information about a table stored outside of BigQuery.
-	ExternalDataConfig *ExternalDataConfig
-
-	// Custom encryption configuration (e.g., Cloud KMS keys).
-	EncryptionConfig *EncryptionConfig
-
-	// All the fields below are read-only.
-
-	FullID           string // An opaque ID uniquely identifying the table.
-	Type             TableType
-	CreationTime     time.Time
-	LastModifiedTime time.Time
-
-	// The size of the table in bytes.
-	// This does not include data that is being buffered during a streaming insert.
-	NumBytes int64
-
-	// The number of rows of data in this table.
-	// This does not include data that is being buffered during a streaming insert.
-	NumRows uint64
-
-	// Contains information regarding this table's streaming buffer, if one is
-	// present. This field will be nil if the table is not being streamed to or if
-	// there is no data in the streaming buffer.
-	StreamingBuffer *StreamingBuffer
-
-	// ETag is the ETag obtained when reading metadata. Pass it to Table.Update to
-	// ensure that the metadata hasn't changed since it was read.
-	ETag string
-}
-
-// TableCreateDisposition specifies the circumstances under which destination table will be created.
-// Default is CreateIfNeeded.
-type TableCreateDisposition string
-
-const (
-	// CreateIfNeeded will create the table if it does not already exist.
-	// Tables are created atomically on successful completion of a job.
-	CreateIfNeeded TableCreateDisposition = "CREATE_IF_NEEDED"
-
-	// CreateNever ensures the table must already exist and will not be
-	// automatically created.
-	CreateNever TableCreateDisposition = "CREATE_NEVER"
-)
-
-// TableWriteDisposition specifies how existing data in a destination table is treated.
-// Default is WriteAppend.
-type TableWriteDisposition string
-
-const (
-	// WriteAppend will append to any existing data in the destination table.
-	// Data is appended atomically on successful completion of a job.
-	WriteAppend TableWriteDisposition = "WRITE_APPEND"
-
-	// WriteTruncate overrides the existing data in the destination table.
-	// Data is overwritten atomically on successful completion of a job.
-	WriteTruncate TableWriteDisposition = "WRITE_TRUNCATE"
-
-	// WriteEmpty fails writes if the destination table already contains data.
-	WriteEmpty TableWriteDisposition = "WRITE_EMPTY"
-)
-
-// TableType is the type of table.
-type TableType string
-
-const (
-	// RegularTable is a regular table.
-	RegularTable TableType = "TABLE"
-	// ViewTable is a table type describing that the table is view. See more
-	// information at https://cloud.google.com/bigquery/docs/views.
-	ViewTable TableType = "VIEW"
-	// ExternalTable is a table type describing that the table is an external
-	// table (also known as a federated data source). See more information at
-	// https://cloud.google.com/bigquery/external-data-sources.
-	ExternalTable TableType = "EXTERNAL"
-)
-
-// TimePartitioning describes the time-based date partitioning on a table.
-// For more information see: https://cloud.google.com/bigquery/docs/creating-partitioned-tables.
-type TimePartitioning struct {
-	// The amount of time to keep the storage for a partition.
-	// If the duration is empty (0), the data in the partitions do not expire.
-	Expiration time.Duration
-
-	// If empty, the table is partitioned by pseudo column '_PARTITIONTIME'; if set, the
-	// table is partitioned by this field. The field must be a top-level TIMESTAMP or
-	// DATE field. Its mode must be NULLABLE or REQUIRED.
-	Field string
-
-	// If true, queries that reference this table must include a filter (e.g. a WHERE predicate)
-	// that can be used for partition elimination.
-	RequirePartitionFilter bool
-}
-
-func (p *TimePartitioning) toBQ() *bq.TimePartitioning {
-	if p == nil {
-		return nil
-	}
-	return &bq.TimePartitioning{
-		Type:                   "DAY",
-		ExpirationMs:           int64(p.Expiration / time.Millisecond),
-		Field:                  p.Field,
-		RequirePartitionFilter: p.RequirePartitionFilter,
-	}
-}
-
-func bqToTimePartitioning(q *bq.TimePartitioning) *TimePartitioning {
-	if q == nil {
-		return nil
-	}
-	return &TimePartitioning{
-		Expiration:             time.Duration(q.ExpirationMs) * time.Millisecond,
-		Field:                  q.Field,
-		RequirePartitionFilter: q.RequirePartitionFilter,
-	}
-}
-
-// 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 {
-	Fields []string
-}
-
-func (c *Clustering) toBQ() *bq.Clustering {
-	if c == nil {
-		return nil
-	}
-	return &bq.Clustering{
-		Fields: c.Fields,
-	}
-}
-
-func bqToClustering(q *bq.Clustering) *Clustering {
-	if q == nil {
-		return nil
-	}
-	return &Clustering{
-		Fields: q.Fields,
-	}
-}
-
-// EncryptionConfig configures customer-managed encryption on tables.
-type EncryptionConfig struct {
-	// Describes the Cloud KMS encryption key that will be used to protect
-	// destination BigQuery table. The BigQuery Service Account associated with your
-	// project requires access to this encryption key.
-	KMSKeyName string
-}
-
-func (e *EncryptionConfig) toBQ() *bq.EncryptionConfiguration {
-	if e == nil {
-		return nil
-	}
-	return &bq.EncryptionConfiguration{
-		KmsKeyName: e.KMSKeyName,
-	}
-}
-
-func bqToEncryptionConfig(q *bq.EncryptionConfiguration) *EncryptionConfig {
-	if q == nil {
-		return nil
-	}
-	return &EncryptionConfig{
-		KMSKeyName: q.KmsKeyName,
-	}
-}
-
-// StreamingBuffer holds information about the streaming buffer.
-type StreamingBuffer struct {
-	// A lower-bound estimate of the number of bytes currently in the streaming
-	// buffer.
-	EstimatedBytes uint64
-
-	// A lower-bound estimate of the number of rows currently in the streaming
-	// buffer.
-	EstimatedRows uint64
-
-	// The time of the oldest entry in the streaming buffer.
-	OldestEntryTime time.Time
-}
-
-func (t *Table) toBQ() *bq.TableReference {
-	return &bq.TableReference{
-		ProjectId: t.ProjectID,
-		DatasetId: t.DatasetID,
-		TableId:   t.TableID,
-	}
-}
-
-// FullyQualifiedName returns the ID of the table in projectID:datasetID.tableID format.
-func (t *Table) FullyQualifiedName() string {
-	return fmt.Sprintf("%s:%s.%s", t.ProjectID, t.DatasetID, t.TableID)
-}
-
-// implicitTable reports whether Table is an empty placeholder, which signifies that a new table should be created with an auto-generated Table ID.
-func (t *Table) implicitTable() bool {
-	return t.ProjectID == "" && t.DatasetID == "" && t.TableID == ""
-}
-
-// Create creates a table in the BigQuery service.
-// Pass in a TableMetadata value to configure the table.
-// If tm.View.Query is non-empty, the created table will be of type VIEW.
-// If no ExpirationTime is specified, the table will never expire.
-// After table creation, a view can be modified only if its table was initially created
-// with a view.
-func (t *Table) Create(ctx context.Context, tm *TableMetadata) (err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Table.Create")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	table, err := tm.toBQ()
-	if err != nil {
-		return err
-	}
-	table.TableReference = &bq.TableReference{
-		ProjectId: t.ProjectID,
-		DatasetId: t.DatasetID,
-		TableId:   t.TableID,
-	}
-	req := t.c.bqs.Tables.Insert(t.ProjectID, t.DatasetID, table).Context(ctx)
-	setClientHeader(req.Header())
-	_, err = req.Do()
-	return err
-}
-
-func (tm *TableMetadata) toBQ() (*bq.Table, error) {
-	t := &bq.Table{}
-	if tm == nil {
-		return t, nil
-	}
-	if tm.Schema != nil && tm.ViewQuery != "" {
-		return nil, errors.New("bigquery: provide Schema or ViewQuery, not both")
-	}
-	t.FriendlyName = tm.Name
-	t.Description = tm.Description
-	t.Labels = tm.Labels
-	if tm.Schema != nil {
-		t.Schema = tm.Schema.toBQ()
-	}
-	if tm.ViewQuery != "" {
-		if tm.UseStandardSQL && tm.UseLegacySQL {
-			return nil, errors.New("bigquery: cannot provide both UseStandardSQL and UseLegacySQL")
-		}
-		t.View = &bq.ViewDefinition{Query: tm.ViewQuery}
-		if tm.UseLegacySQL {
-			t.View.UseLegacySql = true
-		} else {
-			t.View.UseLegacySql = false
-			t.View.ForceSendFields = append(t.View.ForceSendFields, "UseLegacySql")
-		}
-	} else if tm.UseLegacySQL || tm.UseStandardSQL {
-		return nil, errors.New("bigquery: UseLegacy/StandardSQL requires ViewQuery")
-	}
-	t.TimePartitioning = tm.TimePartitioning.toBQ()
-	t.Clustering = tm.Clustering.toBQ()
-
-	if !validExpiration(tm.ExpirationTime) {
-		return nil, fmt.Errorf("invalid expiration time: %v.\n"+
-			"Valid expiration times are after 1678 and before 2262", tm.ExpirationTime)
-	}
-	if !tm.ExpirationTime.IsZero() && tm.ExpirationTime != NeverExpire {
-		t.ExpirationTime = tm.ExpirationTime.UnixNano() / 1e6
-	}
-	if tm.ExternalDataConfig != nil {
-		edc := tm.ExternalDataConfig.toBQ()
-		t.ExternalDataConfiguration = &edc
-	}
-	t.EncryptionConfiguration = tm.EncryptionConfig.toBQ()
-	if tm.FullID != "" {
-		return nil, errors.New("cannot set FullID on create")
-	}
-	if tm.Type != "" {
-		return nil, errors.New("cannot set Type on create")
-	}
-	if !tm.CreationTime.IsZero() {
-		return nil, errors.New("cannot set CreationTime on create")
-	}
-	if !tm.LastModifiedTime.IsZero() {
-		return nil, errors.New("cannot set LastModifiedTime on create")
-	}
-	if tm.NumBytes != 0 {
-		return nil, errors.New("cannot set NumBytes on create")
-	}
-	if tm.NumRows != 0 {
-		return nil, errors.New("cannot set NumRows on create")
-	}
-	if tm.StreamingBuffer != nil {
-		return nil, errors.New("cannot set StreamingBuffer on create")
-	}
-	if tm.ETag != "" {
-		return nil, errors.New("cannot set ETag on create")
-	}
-	return t, nil
-}
-
-// Metadata fetches the metadata for the table.
-func (t *Table) Metadata(ctx context.Context) (md *TableMetadata, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Table.Metadata")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	req := t.c.bqs.Tables.Get(t.ProjectID, t.DatasetID, t.TableID).Context(ctx)
-	setClientHeader(req.Header())
-	var table *bq.Table
-	err = runWithRetry(ctx, func() (err error) {
-		table, err = req.Do()
-		return err
-	})
-	if err != nil {
-		return nil, err
-	}
-	return bqToTableMetadata(table)
-}
-
-func bqToTableMetadata(t *bq.Table) (*TableMetadata, error) {
-	md := &TableMetadata{
-		Description:      t.Description,
-		Name:             t.FriendlyName,
-		Type:             TableType(t.Type),
-		FullID:           t.Id,
-		Labels:           t.Labels,
-		NumBytes:         t.NumBytes,
-		NumRows:          t.NumRows,
-		ExpirationTime:   unixMillisToTime(t.ExpirationTime),
-		CreationTime:     unixMillisToTime(t.CreationTime),
-		LastModifiedTime: unixMillisToTime(int64(t.LastModifiedTime)),
-		ETag:             t.Etag,
-		EncryptionConfig: bqToEncryptionConfig(t.EncryptionConfiguration),
-	}
-	if t.Schema != nil {
-		md.Schema = bqToSchema(t.Schema)
-	}
-	if t.View != nil {
-		md.ViewQuery = t.View.Query
-		md.UseLegacySQL = t.View.UseLegacySql
-	}
-	md.TimePartitioning = bqToTimePartitioning(t.TimePartitioning)
-	md.Clustering = bqToClustering(t.Clustering)
-	if t.StreamingBuffer != nil {
-		md.StreamingBuffer = &StreamingBuffer{
-			EstimatedBytes:  t.StreamingBuffer.EstimatedBytes,
-			EstimatedRows:   t.StreamingBuffer.EstimatedRows,
-			OldestEntryTime: unixMillisToTime(int64(t.StreamingBuffer.OldestEntryTime)),
-		}
-	}
-	if t.ExternalDataConfiguration != nil {
-		edc, err := bqToExternalDataConfig(t.ExternalDataConfiguration)
-		if err != nil {
-			return nil, err
-		}
-		md.ExternalDataConfig = edc
-	}
-	return md, nil
-}
-
-// Delete deletes the table.
-func (t *Table) Delete(ctx context.Context) (err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Table.Delete")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	req := t.c.bqs.Tables.Delete(t.ProjectID, t.DatasetID, t.TableID).Context(ctx)
-	setClientHeader(req.Header())
-	return req.Do()
-}
-
-// Read fetches the contents of the table.
-func (t *Table) Read(ctx context.Context) *RowIterator {
-	return t.read(ctx, fetchPage)
-}
-
-func (t *Table) read(ctx context.Context, pf pageFetcher) *RowIterator {
-	return newRowIterator(ctx, t, pf)
-}
-
-// NeverExpire is a sentinel value used to remove a table'e expiration time.
-var NeverExpire = time.Time{}.Add(-1)
-
-// Update modifies specific Table metadata fields.
-func (t *Table) Update(ctx context.Context, tm TableMetadataToUpdate, etag string) (md *TableMetadata, err error) {
-	ctx = trace.StartSpan(ctx, "cloud.google.com/go/bigquery.Table.Update")
-	defer func() { trace.EndSpan(ctx, err) }()
-
-	bqt, err := tm.toBQ()
-	if err != nil {
-		return nil, err
-	}
-	call := t.c.bqs.Tables.Patch(t.ProjectID, t.DatasetID, t.TableID, bqt).Context(ctx)
-	setClientHeader(call.Header())
-	if etag != "" {
-		call.Header().Set("If-Match", etag)
-	}
-	var res *bq.Table
-	if err := runWithRetry(ctx, func() (err error) {
-		res, err = call.Do()
-		return err
-	}); err != nil {
-		return nil, err
-	}
-	return bqToTableMetadata(res)
-}
-
-func (tm *TableMetadataToUpdate) toBQ() (*bq.Table, error) {
-	t := &bq.Table{}
-	forceSend := func(field string) {
-		t.ForceSendFields = append(t.ForceSendFields, field)
-	}
-
-	if tm.Description != nil {
-		t.Description = optional.ToString(tm.Description)
-		forceSend("Description")
-	}
-	if tm.Name != nil {
-		t.FriendlyName = optional.ToString(tm.Name)
-		forceSend("FriendlyName")
-	}
-	if tm.Schema != nil {
-		t.Schema = tm.Schema.toBQ()
-		forceSend("Schema")
-	}
-	if tm.EncryptionConfig != nil {
-		t.EncryptionConfiguration = tm.EncryptionConfig.toBQ()
-	}
-
-	if !validExpiration(tm.ExpirationTime) {
-		return nil, fmt.Errorf("invalid expiration time: %v.\n"+
-			"Valid expiration times are after 1678 and before 2262", tm.ExpirationTime)
-	}
-	if tm.ExpirationTime == NeverExpire {
-		t.NullFields = append(t.NullFields, "ExpirationTime")
-	} else if !tm.ExpirationTime.IsZero() {
-		t.ExpirationTime = tm.ExpirationTime.UnixNano() / 1e6
-		forceSend("ExpirationTime")
-	}
-	if tm.TimePartitioning != nil {
-		t.TimePartitioning = tm.TimePartitioning.toBQ()
-		t.TimePartitioning.ForceSendFields = []string{"RequirePartitionFilter"}
-		if tm.TimePartitioning.Expiration == 0 {
-			t.TimePartitioning.NullFields = []string{"ExpirationMs"}
-		}
-	}
-	if tm.ViewQuery != nil {
-		t.View = &bq.ViewDefinition{
-			Query:           optional.ToString(tm.ViewQuery),
-			ForceSendFields: []string{"Query"},
-		}
-	}
-	if tm.UseLegacySQL != nil {
-		if t.View == nil {
-			t.View = &bq.ViewDefinition{}
-		}
-		t.View.UseLegacySql = optional.ToBool(tm.UseLegacySQL)
-		t.View.ForceSendFields = append(t.View.ForceSendFields, "UseLegacySql")
-	}
-	labels, forces, nulls := tm.update()
-	t.Labels = labels
-	t.ForceSendFields = append(t.ForceSendFields, forces...)
-	t.NullFields = append(t.NullFields, nulls...)
-	return t, nil
-}
-
-// validExpiration ensures a specified time is either the sentinel NeverExpire,
-// the zero value, or within the defined range of UnixNano. Internal
-// represetations of expiration times are based upon Time.UnixNano. Any time
-// before 1678 or after 2262 cannot be represented by an int64 and is therefore
-// undefined and invalid. See https://godoc.org/time#Time.UnixNano.
-func validExpiration(t time.Time) bool {
-	return t == NeverExpire || t.IsZero() || time.Unix(0, t.UnixNano()).Equal(t)
-}
-
-// TableMetadataToUpdate is used when updating a table's metadata.
-// Only non-nil fields will be updated.
-type TableMetadataToUpdate struct {
-	// The user-friendly description of this table.
-	Description optional.String
-
-	// The user-friendly name for this table.
-	Name optional.String
-
-	// The table's schema.
-	// When updating a schema, you can add columns but not remove them.
-	Schema Schema
-
-	// The table's encryption configuration.  When calling Update, ensure that
-	// all mutable fields of EncryptionConfig are populated.
-	EncryptionConfig *EncryptionConfig
-
-	// The time when this table expires. To remove a table's expiration,
-	// set ExpirationTime to NeverExpire. The zero value is ignored.
-	ExpirationTime time.Time
-
-	// The query to use for a view.
-	ViewQuery optional.String
-
-	// Use Legacy SQL for the view query.
-	UseLegacySQL optional.Bool
-
-	// TimePartitioning allows modification of certain aspects of partition
-	// configuration such as partition expiration and whether partition
-	// filtration is required at query time.  When calling Update, ensure
-	// that all mutable fields of TimePartitioning are populated.
-	TimePartitioning *TimePartitioning
-
-	labelUpdater
-}
-
-// labelUpdater contains common code for updating labels.
-type labelUpdater struct {
-	setLabels    map[string]string
-	deleteLabels map[string]bool
-}
-
-// SetLabel causes a label to be added or modified on a call to Update.
-func (u *labelUpdater) SetLabel(name, value string) {
-	if u.setLabels == nil {
-		u.setLabels = map[string]string{}
-	}
-	u.setLabels[name] = value
-}
-
-// DeleteLabel causes a label to be deleted on a call to Update.
-func (u *labelUpdater) DeleteLabel(name string) {
-	if u.deleteLabels == nil {
-		u.deleteLabels = map[string]bool{}
-	}
-	u.deleteLabels[name] = true
-}
-
-func (u *labelUpdater) update() (labels map[string]string, forces, nulls []string) {
-	if u.setLabels == nil && u.deleteLabels == nil {
-		return nil, nil, nil
-	}
-	labels = map[string]string{}
-	for k, v := range u.setLabels {
-		labels[k] = v
-	}
-	if len(labels) == 0 && len(u.deleteLabels) > 0 {
-		forces = []string{"Labels"}
-	}
-	for l := range u.deleteLabels {
-		nulls = append(nulls, "Labels."+l)
-	}
-	return labels, forces, nulls
-}

+ 0 - 370
vendor/cloud.google.com/go/bigquery/table_test.go

@@ -1,370 +0,0 @@
-// Copyright 2017 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"testing"
-	"time"
-
-	"cloud.google.com/go/internal/testutil"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func TestBQToTableMetadata(t *testing.T) {
-	aTime := time.Date(2017, 1, 26, 0, 0, 0, 0, time.Local)
-	aTimeMillis := aTime.UnixNano() / 1e6
-	for _, test := range []struct {
-		in   *bq.Table
-		want *TableMetadata
-	}{
-		{&bq.Table{}, &TableMetadata{}}, // test minimal case
-		{
-			&bq.Table{
-				CreationTime:     aTimeMillis,
-				Description:      "desc",
-				Etag:             "etag",
-				ExpirationTime:   aTimeMillis,
-				FriendlyName:     "fname",
-				Id:               "id",
-				LastModifiedTime: uint64(aTimeMillis),
-				Location:         "loc",
-				NumBytes:         123,
-				NumLongTermBytes: 23,
-				NumRows:          7,
-				StreamingBuffer: &bq.Streamingbuffer{
-					EstimatedBytes:  11,
-					EstimatedRows:   3,
-					OldestEntryTime: uint64(aTimeMillis),
-				},
-				TimePartitioning: &bq.TimePartitioning{
-					ExpirationMs: 7890,
-					Type:         "DAY",
-					Field:        "pfield",
-				},
-				Clustering: &bq.Clustering{
-					Fields: []string{"cfield1", "cfield2"},
-				},
-				EncryptionConfiguration: &bq.EncryptionConfiguration{KmsKeyName: "keyName"},
-				Type:                    "EXTERNAL",
-				View:                    &bq.ViewDefinition{Query: "view-query"},
-				Labels:                  map[string]string{"a": "b"},
-				ExternalDataConfiguration: &bq.ExternalDataConfiguration{
-					SourceFormat: "GOOGLE_SHEETS",
-				},
-			},
-			&TableMetadata{
-				Description:        "desc",
-				Name:               "fname",
-				ViewQuery:          "view-query",
-				FullID:             "id",
-				Type:               ExternalTable,
-				Labels:             map[string]string{"a": "b"},
-				ExternalDataConfig: &ExternalDataConfig{SourceFormat: GoogleSheets},
-				ExpirationTime:     aTime.Truncate(time.Millisecond),
-				CreationTime:       aTime.Truncate(time.Millisecond),
-				LastModifiedTime:   aTime.Truncate(time.Millisecond),
-				NumBytes:           123,
-				NumRows:            7,
-				TimePartitioning: &TimePartitioning{
-					Expiration: 7890 * time.Millisecond,
-					Field:      "pfield",
-				},
-				Clustering: &Clustering{
-					Fields: []string{"cfield1", "cfield2"},
-				},
-				StreamingBuffer: &StreamingBuffer{
-					EstimatedBytes:  11,
-					EstimatedRows:   3,
-					OldestEntryTime: aTime,
-				},
-				EncryptionConfig: &EncryptionConfig{KMSKeyName: "keyName"},
-				ETag:             "etag",
-			},
-		},
-	} {
-		got, err := bqToTableMetadata(test.in)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if diff := testutil.Diff(got, test.want); diff != "" {
-			t.Errorf("%+v:\n, -got, +want:\n%s", test.in, diff)
-		}
-	}
-}
-
-func TestTableMetadataToBQ(t *testing.T) {
-	aTime := time.Date(2017, 1, 26, 0, 0, 0, 0, time.Local)
-	aTimeMillis := aTime.UnixNano() / 1e6
-	sc := Schema{fieldSchema("desc", "name", "STRING", false, true)}
-
-	for _, test := range []struct {
-		in   *TableMetadata
-		want *bq.Table
-	}{
-		{nil, &bq.Table{}},
-		{&TableMetadata{}, &bq.Table{}},
-		{
-			&TableMetadata{
-				Name:               "n",
-				Description:        "d",
-				Schema:             sc,
-				ExpirationTime:     aTime,
-				Labels:             map[string]string{"a": "b"},
-				ExternalDataConfig: &ExternalDataConfig{SourceFormat: Bigtable},
-				EncryptionConfig:   &EncryptionConfig{KMSKeyName: "keyName"},
-			},
-			&bq.Table{
-				FriendlyName: "n",
-				Description:  "d",
-				Schema: &bq.TableSchema{
-					Fields: []*bq.TableFieldSchema{
-						bqTableFieldSchema("desc", "name", "STRING", "REQUIRED"),
-					},
-				},
-				ExpirationTime:            aTimeMillis,
-				Labels:                    map[string]string{"a": "b"},
-				ExternalDataConfiguration: &bq.ExternalDataConfiguration{SourceFormat: "BIGTABLE"},
-				EncryptionConfiguration:   &bq.EncryptionConfiguration{KmsKeyName: "keyName"},
-			},
-		},
-		{
-			&TableMetadata{ViewQuery: "q"},
-			&bq.Table{
-				View: &bq.ViewDefinition{
-					Query:           "q",
-					UseLegacySql:    false,
-					ForceSendFields: []string{"UseLegacySql"},
-				},
-			},
-		},
-		{
-			&TableMetadata{
-				ViewQuery:        "q",
-				UseLegacySQL:     true,
-				TimePartitioning: &TimePartitioning{},
-			},
-			&bq.Table{
-				View: &bq.ViewDefinition{
-					Query:        "q",
-					UseLegacySql: true,
-				},
-				TimePartitioning: &bq.TimePartitioning{
-					Type:         "DAY",
-					ExpirationMs: 0,
-				},
-			},
-		},
-		{
-			&TableMetadata{
-				ViewQuery:      "q",
-				UseStandardSQL: true,
-				TimePartitioning: &TimePartitioning{
-					Expiration: time.Second,
-					Field:      "ofDreams",
-				},
-				Clustering: &Clustering{
-					Fields: []string{"cfield1"},
-				},
-			},
-			&bq.Table{
-				View: &bq.ViewDefinition{
-					Query:           "q",
-					UseLegacySql:    false,
-					ForceSendFields: []string{"UseLegacySql"},
-				},
-				TimePartitioning: &bq.TimePartitioning{
-					Type:         "DAY",
-					ExpirationMs: 1000,
-					Field:        "ofDreams",
-				},
-				Clustering: &bq.Clustering{
-					Fields: []string{"cfield1"},
-				},
-			},
-		},
-		{
-			&TableMetadata{ExpirationTime: NeverExpire},
-			&bq.Table{ExpirationTime: 0},
-		},
-	} {
-		got, err := test.in.toBQ()
-		if err != nil {
-			t.Fatalf("%+v: %v", test.in, err)
-		}
-		if diff := testutil.Diff(got, test.want); diff != "" {
-			t.Errorf("%+v:\n-got, +want:\n%s", test.in, diff)
-		}
-	}
-
-	// Errors
-	for _, in := range []*TableMetadata{
-		{Schema: sc, ViewQuery: "q"}, // can't have both schema and query
-		{UseLegacySQL: true},         // UseLegacySQL without query
-		{UseStandardSQL: true},       // UseStandardSQL without query
-		// read-only fields
-		{FullID: "x"},
-		{Type: "x"},
-		{CreationTime: aTime},
-		{LastModifiedTime: aTime},
-		{NumBytes: 1},
-		{NumRows: 1},
-		{StreamingBuffer: &StreamingBuffer{}},
-		{ETag: "x"},
-		// expiration time outside allowable range is invalid
-		// See https://godoc.org/time#Time.UnixNano
-		{ExpirationTime: time.Date(1677, 9, 21, 0, 12, 43, 145224192, time.UTC).Add(-1)},
-		{ExpirationTime: time.Date(2262, 04, 11, 23, 47, 16, 854775807, time.UTC).Add(1)},
-	} {
-		_, err := in.toBQ()
-		if err == nil {
-			t.Errorf("%+v: got nil, want error", in)
-		}
-	}
-}
-
-func TestTableMetadataToUpdateToBQ(t *testing.T) {
-	aTime := time.Date(2017, 1, 26, 0, 0, 0, 0, time.Local)
-	for _, test := range []struct {
-		tm   TableMetadataToUpdate
-		want *bq.Table
-	}{
-		{
-			tm:   TableMetadataToUpdate{},
-			want: &bq.Table{},
-		},
-		{
-			tm: TableMetadataToUpdate{
-				Description: "d",
-				Name:        "n",
-			},
-			want: &bq.Table{
-				Description:     "d",
-				FriendlyName:    "n",
-				ForceSendFields: []string{"Description", "FriendlyName"},
-			},
-		},
-		{
-			tm: TableMetadataToUpdate{
-				Schema:         Schema{fieldSchema("desc", "name", "STRING", false, true)},
-				ExpirationTime: aTime,
-			},
-			want: &bq.Table{
-				Schema: &bq.TableSchema{
-					Fields: []*bq.TableFieldSchema{
-						bqTableFieldSchema("desc", "name", "STRING", "REQUIRED"),
-					},
-				},
-				ExpirationTime:  aTime.UnixNano() / 1e6,
-				ForceSendFields: []string{"Schema", "ExpirationTime"},
-			},
-		},
-		{
-			tm: TableMetadataToUpdate{ViewQuery: "q"},
-			want: &bq.Table{
-				View: &bq.ViewDefinition{Query: "q", ForceSendFields: []string{"Query"}},
-			},
-		},
-		{
-			tm: TableMetadataToUpdate{UseLegacySQL: false},
-			want: &bq.Table{
-				View: &bq.ViewDefinition{
-					UseLegacySql:    false,
-					ForceSendFields: []string{"UseLegacySql"},
-				},
-			},
-		},
-		{
-			tm: TableMetadataToUpdate{ViewQuery: "q", UseLegacySQL: true},
-			want: &bq.Table{
-				View: &bq.ViewDefinition{
-					Query:           "q",
-					UseLegacySql:    true,
-					ForceSendFields: []string{"Query", "UseLegacySql"},
-				},
-			},
-		},
-		{
-			tm: func() (tm TableMetadataToUpdate) {
-				tm.SetLabel("L", "V")
-				tm.DeleteLabel("D")
-				return tm
-			}(),
-			want: &bq.Table{
-				Labels:     map[string]string{"L": "V"},
-				NullFields: []string{"Labels.D"},
-			},
-		},
-		{
-			tm: TableMetadataToUpdate{ExpirationTime: NeverExpire},
-			want: &bq.Table{
-				NullFields: []string{"ExpirationTime"},
-			},
-		},
-		{
-			tm: TableMetadataToUpdate{TimePartitioning: &TimePartitioning{Expiration: 0}},
-			want: &bq.Table{
-				TimePartitioning: &bq.TimePartitioning{
-					Type:            "DAY",
-					ForceSendFields: []string{"RequirePartitionFilter"},
-					NullFields:      []string{"ExpirationMs"},
-				},
-			},
-		},
-		{
-			tm: TableMetadataToUpdate{TimePartitioning: &TimePartitioning{Expiration: time.Duration(time.Hour)}},
-			want: &bq.Table{
-				TimePartitioning: &bq.TimePartitioning{
-					ExpirationMs:    3600000,
-					Type:            "DAY",
-					ForceSendFields: []string{"RequirePartitionFilter"},
-				},
-			},
-		},
-	} {
-		got, _ := test.tm.toBQ()
-		if !testutil.Equal(got, test.want) {
-			t.Errorf("%+v:\ngot  %+v\nwant %+v", test.tm, got, test.want)
-		}
-	}
-}
-
-func TestTableMetadataToUpdateToBQErrors(t *testing.T) {
-	// See https://godoc.org/time#Time.UnixNano
-	start := time.Date(1677, 9, 21, 0, 12, 43, 145224192, time.UTC)
-	end := time.Date(2262, 04, 11, 23, 47, 16, 854775807, time.UTC)
-
-	for _, test := range []struct {
-		desc    string
-		aTime   time.Time
-		wantErr bool
-	}{
-		{desc: "ignored zero value", aTime: time.Time{}, wantErr: false},
-		{desc: "earliest valid time", aTime: start, wantErr: false},
-		{desc: "latested valid time", aTime: end, wantErr: false},
-		{desc: "invalid times before 1678", aTime: start.Add(-1), wantErr: true},
-		{desc: "invalid times after 2262", aTime: end.Add(1), wantErr: true},
-		{desc: "valid times after 1678", aTime: start.Add(1), wantErr: false},
-		{desc: "valid times before 2262", aTime: end.Add(-1), wantErr: false},
-	} {
-		tm := &TableMetadataToUpdate{ExpirationTime: test.aTime}
-		_, err := tm.toBQ()
-		if test.wantErr && err == nil {
-			t.Errorf("[%s] got no error, want error", test.desc)
-		}
-		if !test.wantErr && err != nil {
-			t.Errorf("[%s] got error, want no error", test.desc)
-		}
-	}
-}

+ 0 - 870
vendor/cloud.google.com/go/bigquery/value.go

@@ -1,870 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"encoding/base64"
-	"errors"
-	"fmt"
-	"math"
-	"math/big"
-	"reflect"
-	"strconv"
-	"strings"
-	"time"
-
-	"cloud.google.com/go/civil"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-// Value stores the contents of a single cell from a BigQuery result.
-type Value interface{}
-
-// ValueLoader stores a slice of Values representing a result row from a Read operation.
-// See RowIterator.Next for more information.
-type ValueLoader interface {
-	Load(v []Value, s Schema) error
-}
-
-// valueList converts a []Value to implement ValueLoader.
-type valueList []Value
-
-// Load stores a sequence of values in a valueList.
-// It resets the slice length to zero, then appends each value to it.
-func (vs *valueList) Load(v []Value, _ Schema) error {
-	*vs = append((*vs)[:0], v...)
-	return nil
-}
-
-// valueMap converts a map[string]Value to implement ValueLoader.
-type valueMap map[string]Value
-
-// Load stores a sequence of values in a valueMap.
-func (vm *valueMap) Load(v []Value, s Schema) error {
-	if *vm == nil {
-		*vm = map[string]Value{}
-	}
-	loadMap(*vm, v, s)
-	return nil
-}
-
-func loadMap(m map[string]Value, vals []Value, s Schema) {
-	for i, f := range s {
-		val := vals[i]
-		var v interface{}
-		switch {
-		case val == nil:
-			v = val
-		case f.Schema == nil:
-			v = val
-		case !f.Repeated:
-			m2 := map[string]Value{}
-			loadMap(m2, val.([]Value), f.Schema)
-			v = m2
-		default: // repeated and nested
-			sval := val.([]Value)
-			vs := make([]Value, len(sval))
-			for j, e := range sval {
-				m2 := map[string]Value{}
-				loadMap(m2, e.([]Value), f.Schema)
-				vs[j] = m2
-			}
-			v = vs
-		}
-
-		m[f.Name] = v
-	}
-}
-
-type structLoader struct {
-	typ reflect.Type // type of struct
-	err error
-	ops []structLoaderOp
-
-	vstructp reflect.Value // pointer to current struct value; changed by set
-}
-
-// A setFunc is a function that sets a struct field or slice/array
-// element to a value.
-type setFunc func(v reflect.Value, val interface{}) error
-
-// A structLoaderOp instructs the loader to set a struct field to a row value.
-type structLoaderOp struct {
-	fieldIndex []int
-	valueIndex int
-	setFunc    setFunc
-	repeated   bool
-}
-
-var errNoNulls = errors.New("bigquery: NULL values cannot be read into structs")
-
-func setAny(v reflect.Value, x interface{}) error {
-	if x == nil {
-		return errNoNulls
-	}
-	v.Set(reflect.ValueOf(x))
-	return nil
-}
-
-func setInt(v reflect.Value, x interface{}) error {
-	if x == nil {
-		return errNoNulls
-	}
-	xx := x.(int64)
-	if v.OverflowInt(xx) {
-		return fmt.Errorf("bigquery: value %v overflows struct field of type %v", xx, v.Type())
-	}
-	v.SetInt(xx)
-	return nil
-}
-
-func setUint(v reflect.Value, x interface{}) error {
-	if x == nil {
-		return errNoNulls
-	}
-	xx := x.(int64)
-	if xx < 0 || v.OverflowUint(uint64(xx)) {
-		return fmt.Errorf("bigquery: value %v overflows struct field of type %v", xx, v.Type())
-	}
-	v.SetUint(uint64(xx))
-	return nil
-}
-
-func setFloat(v reflect.Value, x interface{}) error {
-	if x == nil {
-		return errNoNulls
-	}
-	xx := x.(float64)
-	if v.OverflowFloat(xx) {
-		return fmt.Errorf("bigquery: value %v overflows struct field of type %v", xx, v.Type())
-	}
-	v.SetFloat(xx)
-	return nil
-}
-
-func setBool(v reflect.Value, x interface{}) error {
-	if x == nil {
-		return errNoNulls
-	}
-	v.SetBool(x.(bool))
-	return nil
-}
-
-func setString(v reflect.Value, x interface{}) error {
-	if x == nil {
-		return errNoNulls
-	}
-	v.SetString(x.(string))
-	return nil
-}
-
-func setBytes(v reflect.Value, x interface{}) error {
-	if x == nil {
-		v.SetBytes(nil)
-	} else {
-		v.SetBytes(x.([]byte))
-	}
-	return nil
-}
-
-func setNull(v reflect.Value, x interface{}, build func() interface{}) error {
-	if x == nil {
-		v.Set(reflect.Zero(v.Type()))
-	} else {
-		n := build()
-		v.Set(reflect.ValueOf(n))
-	}
-	return nil
-}
-
-// set remembers a value for the next call to Load. The value must be
-// a pointer to a struct. (This is checked in RowIterator.Next.)
-func (sl *structLoader) set(structp interface{}, schema Schema) error {
-	if sl.err != nil {
-		return sl.err
-	}
-	sl.vstructp = reflect.ValueOf(structp)
-	typ := sl.vstructp.Type().Elem()
-	if sl.typ == nil {
-		// First call: remember the type and compile the schema.
-		sl.typ = typ
-		ops, err := compileToOps(typ, schema)
-		if err != nil {
-			sl.err = err
-			return err
-		}
-		sl.ops = ops
-	} else if sl.typ != typ {
-		return fmt.Errorf("bigquery: struct type changed from %s to %s", sl.typ, typ)
-	}
-	return nil
-}
-
-// compileToOps produces a sequence of operations that will set the fields of a
-// value of structType to the contents of a row with schema.
-func compileToOps(structType reflect.Type, schema Schema) ([]structLoaderOp, error) {
-	var ops []structLoaderOp
-	fields, err := fieldCache.Fields(structType)
-	if err != nil {
-		return nil, err
-	}
-	for i, schemaField := range schema {
-		// Look for an exported struct field with the same name as the schema
-		// field, ignoring case (BigQuery column names are case-insensitive,
-		// and we want to act like encoding/json anyway).
-		structField := fields.Match(schemaField.Name)
-		if structField == nil {
-			// Ignore schema fields with no corresponding struct field.
-			continue
-		}
-		op := structLoaderOp{
-			fieldIndex: structField.Index,
-			valueIndex: i,
-		}
-		t := structField.Type
-		if schemaField.Repeated {
-			if t.Kind() != reflect.Slice && t.Kind() != reflect.Array {
-				return nil, fmt.Errorf("bigquery: repeated schema field %s requires slice or array, but struct field %s has type %s",
-					schemaField.Name, structField.Name, t)
-			}
-			t = t.Elem()
-			op.repeated = true
-		}
-		if schemaField.Type == RecordFieldType {
-			// Field can be a struct or a pointer to a struct.
-			if t.Kind() == reflect.Ptr {
-				t = t.Elem()
-			}
-			if t.Kind() != reflect.Struct {
-				return nil, fmt.Errorf("bigquery: field %s has type %s, expected struct or *struct",
-					structField.Name, structField.Type)
-			}
-			nested, err := compileToOps(t, schemaField.Schema)
-			if err != nil {
-				return nil, err
-			}
-			op.setFunc = func(v reflect.Value, val interface{}) error {
-				return setNested(nested, v, val)
-			}
-		} else {
-			op.setFunc = determineSetFunc(t, schemaField.Type)
-			if op.setFunc == nil {
-				return nil, fmt.Errorf("bigquery: schema field %s of type %s is not assignable to struct field %s of type %s",
-					schemaField.Name, schemaField.Type, structField.Name, t)
-			}
-		}
-		ops = append(ops, op)
-	}
-	return ops, nil
-}
-
-// determineSetFunc chooses the best function for setting a field of type ftype
-// to a value whose schema field type is stype. It returns nil if stype
-// is not assignable to ftype.
-// determineSetFunc considers only basic types. See compileToOps for
-// handling of repetition and nesting.
-func determineSetFunc(ftype reflect.Type, stype FieldType) setFunc {
-	switch stype {
-	case StringFieldType:
-		if ftype.Kind() == reflect.String {
-			return setString
-		}
-		if ftype == typeOfNullString {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullString{StringVal: x.(string), Valid: true}
-				})
-			}
-		}
-
-	case BytesFieldType:
-		if ftype == typeOfByteSlice {
-			return setBytes
-		}
-
-	case IntegerFieldType:
-		if isSupportedUintType(ftype) {
-			return setUint
-		} else if isSupportedIntType(ftype) {
-			return setInt
-		}
-		if ftype == typeOfNullInt64 {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullInt64{Int64: x.(int64), Valid: true}
-				})
-			}
-		}
-
-	case FloatFieldType:
-		switch ftype.Kind() {
-		case reflect.Float32, reflect.Float64:
-			return setFloat
-		}
-		if ftype == typeOfNullFloat64 {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullFloat64{Float64: x.(float64), Valid: true}
-				})
-			}
-		}
-
-	case BooleanFieldType:
-		if ftype.Kind() == reflect.Bool {
-			return setBool
-		}
-		if ftype == typeOfNullBool {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullBool{Bool: x.(bool), Valid: true}
-				})
-			}
-		}
-
-	case TimestampFieldType:
-		if ftype == typeOfGoTime {
-			return setAny
-		}
-		if ftype == typeOfNullTimestamp {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullTimestamp{Timestamp: x.(time.Time), Valid: true}
-				})
-			}
-		}
-
-	case DateFieldType:
-		if ftype == typeOfDate {
-			return setAny
-		}
-		if ftype == typeOfNullDate {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullDate{Date: x.(civil.Date), Valid: true}
-				})
-			}
-		}
-
-	case TimeFieldType:
-		if ftype == typeOfTime {
-			return setAny
-		}
-		if ftype == typeOfNullTime {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullTime{Time: x.(civil.Time), Valid: true}
-				})
-			}
-		}
-
-	case DateTimeFieldType:
-		if ftype == typeOfDateTime {
-			return setAny
-		}
-		if ftype == typeOfNullDateTime {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} {
-					return NullDateTime{DateTime: x.(civil.DateTime), Valid: true}
-				})
-			}
-		}
-
-	case NumericFieldType:
-		if ftype == typeOfRat {
-			return func(v reflect.Value, x interface{}) error {
-				return setNull(v, x, func() interface{} { return x.(*big.Rat) })
-			}
-		}
-	}
-	return nil
-}
-
-func (sl *structLoader) Load(values []Value, _ Schema) error {
-	if sl.err != nil {
-		return sl.err
-	}
-	return runOps(sl.ops, sl.vstructp.Elem(), values)
-}
-
-// runOps executes a sequence of ops, setting the fields of vstruct to the
-// supplied values.
-func runOps(ops []structLoaderOp, vstruct reflect.Value, values []Value) error {
-	for _, op := range ops {
-		field := vstruct.FieldByIndex(op.fieldIndex)
-		var err error
-		if op.repeated {
-			err = setRepeated(field, values[op.valueIndex].([]Value), op.setFunc)
-		} else {
-			err = op.setFunc(field, values[op.valueIndex])
-		}
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func setNested(ops []structLoaderOp, v reflect.Value, val interface{}) error {
-	// v is either a struct or a pointer to a struct.
-	if v.Kind() == reflect.Ptr {
-		// If the value is nil, set the pointer to nil.
-		if val == nil {
-			v.Set(reflect.Zero(v.Type()))
-			return nil
-		}
-		// If the pointer is nil, set it to a zero struct value.
-		if v.IsNil() {
-			v.Set(reflect.New(v.Type().Elem()))
-		}
-		v = v.Elem()
-	}
-	return runOps(ops, v, val.([]Value))
-}
-
-func setRepeated(field reflect.Value, vslice []Value, setElem setFunc) error {
-	vlen := len(vslice)
-	var flen int
-	switch field.Type().Kind() {
-	case reflect.Slice:
-		// Make a slice of the right size, avoiding allocation if possible.
-		switch {
-		case field.Len() < vlen:
-			field.Set(reflect.MakeSlice(field.Type(), vlen, vlen))
-		case field.Len() > vlen:
-			field.SetLen(vlen)
-		}
-		flen = vlen
-
-	case reflect.Array:
-		flen = field.Len()
-		if flen > vlen {
-			// Set extra elements to their zero value.
-			z := reflect.Zero(field.Type().Elem())
-			for i := vlen; i < flen; i++ {
-				field.Index(i).Set(z)
-			}
-		}
-	default:
-		return fmt.Errorf("bigquery: impossible field type %s", field.Type())
-	}
-	for i, val := range vslice {
-		if i < flen { // avoid writing past the end of a short array
-			if err := setElem(field.Index(i), val); err != nil {
-				return err
-			}
-		}
-	}
-	return nil
-}
-
-// A ValueSaver returns a row of data to be inserted into a table.
-type ValueSaver interface {
-	// Save returns a row to be inserted into a BigQuery table, represented
-	// as a map from field name to Value.
-	// If insertID is non-empty, BigQuery will use it to de-duplicate
-	// insertions of this row on a best-effort basis.
-	Save() (row map[string]Value, insertID string, err error)
-}
-
-// ValuesSaver implements ValueSaver for a slice of Values.
-type ValuesSaver struct {
-	Schema Schema
-
-	// If non-empty, BigQuery will use InsertID to de-duplicate insertions
-	// of this row on a best-effort basis.
-	InsertID string
-
-	Row []Value
-}
-
-// Save implements ValueSaver.
-func (vls *ValuesSaver) Save() (map[string]Value, string, error) {
-	m, err := valuesToMap(vls.Row, vls.Schema)
-	return m, vls.InsertID, err
-}
-
-func valuesToMap(vs []Value, schema Schema) (map[string]Value, error) {
-	if len(vs) != len(schema) {
-		return nil, errors.New("schema does not match length of row to be inserted")
-	}
-
-	m := make(map[string]Value)
-	for i, fieldSchema := range schema {
-		if vs[i] == nil {
-			m[fieldSchema.Name] = nil
-			continue
-		}
-		if fieldSchema.Type != RecordFieldType {
-			m[fieldSchema.Name] = toUploadValue(vs[i], fieldSchema)
-			continue
-		}
-		// Nested record, possibly repeated.
-		vals, ok := vs[i].([]Value)
-		if !ok {
-			return nil, errors.New("nested record is not a []Value")
-		}
-		if !fieldSchema.Repeated {
-			value, err := valuesToMap(vals, fieldSchema.Schema)
-			if err != nil {
-				return nil, err
-			}
-			m[fieldSchema.Name] = value
-			continue
-		}
-		// A repeated nested field is converted into a slice of maps.
-		var maps []Value
-		for _, v := range vals {
-			sv, ok := v.([]Value)
-			if !ok {
-				return nil, errors.New("nested record in slice is not a []Value")
-			}
-			value, err := valuesToMap(sv, fieldSchema.Schema)
-			if err != nil {
-				return nil, err
-			}
-			maps = append(maps, value)
-		}
-		m[fieldSchema.Name] = maps
-	}
-	return m, nil
-}
-
-// StructSaver implements ValueSaver for a struct.
-// The struct is converted to a map of values by using the values of struct
-// fields corresponding to schema fields. Additional and missing
-// fields are ignored, as are nested struct pointers that are nil.
-type StructSaver struct {
-	// Schema determines what fields of the struct are uploaded. It should
-	// match the table's schema.
-	// Schema is optional for StructSavers that are passed to Uploader.Put.
-	Schema Schema
-
-	// If non-empty, BigQuery will use InsertID to de-duplicate insertions
-	// of this row on a best-effort basis.
-	InsertID string
-
-	// Struct should be a struct or a pointer to a struct.
-	Struct interface{}
-}
-
-// Save implements ValueSaver.
-func (ss *StructSaver) Save() (row map[string]Value, insertID string, err error) {
-	vstruct := reflect.ValueOf(ss.Struct)
-	row, err = structToMap(vstruct, ss.Schema)
-	if err != nil {
-		return nil, "", err
-	}
-	return row, ss.InsertID, nil
-}
-
-func structToMap(vstruct reflect.Value, schema Schema) (map[string]Value, error) {
-	if vstruct.Kind() == reflect.Ptr {
-		vstruct = vstruct.Elem()
-	}
-	if !vstruct.IsValid() {
-		return nil, nil
-	}
-	m := map[string]Value{}
-	if vstruct.Kind() != reflect.Struct {
-		return nil, fmt.Errorf("bigquery: type is %s, need struct or struct pointer", vstruct.Type())
-	}
-	fields, err := fieldCache.Fields(vstruct.Type())
-	if err != nil {
-		return nil, err
-	}
-	for _, schemaField := range schema {
-		// Look for an exported struct field with the same name as the schema
-		// field, ignoring case.
-		structField := fields.Match(schemaField.Name)
-		if structField == nil {
-			continue
-		}
-		val, err := structFieldToUploadValue(vstruct.FieldByIndex(structField.Index), schemaField)
-		if err != nil {
-			return nil, err
-		}
-		// Add the value to the map, unless it is nil.
-		if val != nil {
-			m[schemaField.Name] = val
-		}
-	}
-	return m, nil
-}
-
-// structFieldToUploadValue converts a struct field to a value suitable for ValueSaver.Save, using
-// the schemaField as a guide.
-// structFieldToUploadValue is careful to return a true nil interface{} when needed, so its
-// caller can easily identify a nil value.
-func structFieldToUploadValue(vfield reflect.Value, schemaField *FieldSchema) (interface{}, error) {
-	if schemaField.Repeated && (vfield.Kind() != reflect.Slice && vfield.Kind() != reflect.Array) {
-		return nil, fmt.Errorf("bigquery: repeated schema field %s requires slice or array, but value has type %s",
-			schemaField.Name, vfield.Type())
-	}
-
-	// A non-nested field can be represented by its Go value, except for some types.
-	if schemaField.Type != RecordFieldType {
-		return toUploadValueReflect(vfield, schemaField), nil
-	}
-	// A non-repeated nested field is converted into a map[string]Value.
-	if !schemaField.Repeated {
-		m, err := structToMap(vfield, schemaField.Schema)
-		if err != nil {
-			return nil, err
-		}
-		if m == nil {
-			return nil, nil
-		}
-		return m, nil
-	}
-	// A repeated nested field is converted into a slice of maps.
-	// If the field is zero-length (but not nil), we return a zero-length []Value.
-	if vfield.IsNil() {
-		return nil, nil
-	}
-	vals := []Value{}
-	for i := 0; i < vfield.Len(); i++ {
-		m, err := structToMap(vfield.Index(i), schemaField.Schema)
-		if err != nil {
-			return nil, err
-		}
-		vals = append(vals, m)
-	}
-	return vals, nil
-}
-
-func toUploadValue(val interface{}, fs *FieldSchema) interface{} {
-	if fs.Type == TimeFieldType || fs.Type == DateTimeFieldType || fs.Type == NumericFieldType {
-		return toUploadValueReflect(reflect.ValueOf(val), fs)
-	}
-	return val
-}
-
-func toUploadValueReflect(v reflect.Value, fs *FieldSchema) interface{} {
-	switch fs.Type {
-	case TimeFieldType:
-		if v.Type() == typeOfNullTime {
-			return v.Interface()
-		}
-		return formatUploadValue(v, fs, func(v reflect.Value) string {
-			return CivilTimeString(v.Interface().(civil.Time))
-		})
-	case DateTimeFieldType:
-		if v.Type() == typeOfNullDateTime {
-			return v.Interface()
-		}
-		return formatUploadValue(v, fs, func(v reflect.Value) string {
-			return CivilDateTimeString(v.Interface().(civil.DateTime))
-		})
-	case NumericFieldType:
-		if r, ok := v.Interface().(*big.Rat); ok && r == nil {
-			return nil
-		}
-		return formatUploadValue(v, fs, func(v reflect.Value) string {
-			return NumericString(v.Interface().(*big.Rat))
-		})
-	default:
-		if !fs.Repeated || v.Len() > 0 {
-			return v.Interface()
-		}
-		// The service treats a null repeated field as an error. Return
-		// nil to omit the field entirely.
-		return nil
-	}
-}
-
-func formatUploadValue(v reflect.Value, fs *FieldSchema, cvt func(reflect.Value) string) interface{} {
-	if !fs.Repeated {
-		return cvt(v)
-	}
-	if v.Len() == 0 {
-		return nil
-	}
-	s := make([]string, v.Len())
-	for i := 0; i < v.Len(); i++ {
-		s[i] = cvt(v.Index(i))
-	}
-	return s
-}
-
-// CivilTimeString returns a string representing a civil.Time in a format compatible
-// with BigQuery SQL. It rounds the time to the nearest microsecond and returns a
-// string with six digits of sub-second precision.
-//
-// Use CivilTimeString when using civil.Time in DML, for example in INSERT
-// statements.
-func CivilTimeString(t civil.Time) string {
-	if t.Nanosecond == 0 {
-		return t.String()
-	}
-	micro := (t.Nanosecond + 500) / 1000 // round to nearest microsecond
-	t.Nanosecond = 0
-	return t.String() + fmt.Sprintf(".%06d", micro)
-}
-
-// CivilDateTimeString returns a string representing a civil.DateTime in a format compatible
-// with BigQuery SQL. It separate the date and time with a space, and formats the time
-// with CivilTimeString.
-//
-// Use CivilDateTimeString when using civil.DateTime in DML, for example in INSERT
-// statements.
-func CivilDateTimeString(dt civil.DateTime) string {
-	return dt.Date.String() + " " + CivilTimeString(dt.Time)
-}
-
-// parseCivilDateTime parses a date-time represented in a BigQuery SQL
-// compatible format and returns a civil.DateTime.
-func parseCivilDateTime(s string) (civil.DateTime, error) {
-	parts := strings.Fields(s)
-	if len(parts) != 2 {
-		return civil.DateTime{}, fmt.Errorf("bigquery: bad DATETIME value %q", s)
-	}
-	return civil.ParseDateTime(parts[0] + "T" + parts[1])
-}
-
-const (
-	// NumericPrecisionDigits is the maximum number of digits in a NUMERIC value.
-	NumericPrecisionDigits = 38
-
-	// NumericScaleDigits is the maximum number of digits after the decimal point in a NUMERIC value.
-	NumericScaleDigits = 9
-)
-
-// NumericString returns a string representing a *big.Rat in a format compatible
-// with BigQuery SQL. It returns a floating-point literal with 9 digits
-// after the decimal point.
-func NumericString(r *big.Rat) string {
-	return r.FloatString(NumericScaleDigits)
-}
-
-// convertRows converts a series of TableRows into a series of Value slices.
-// schema is used to interpret the data from rows; its length must match the
-// length of each row.
-func convertRows(rows []*bq.TableRow, schema Schema) ([][]Value, error) {
-	var rs [][]Value
-	for _, r := range rows {
-		row, err := convertRow(r, schema)
-		if err != nil {
-			return nil, err
-		}
-		rs = append(rs, row)
-	}
-	return rs, nil
-}
-
-func convertRow(r *bq.TableRow, schema Schema) ([]Value, error) {
-	if len(schema) != len(r.F) {
-		return nil, errors.New("schema length does not match row length")
-	}
-	var values []Value
-	for i, cell := range r.F {
-		fs := schema[i]
-		v, err := convertValue(cell.V, fs.Type, fs.Schema)
-		if err != nil {
-			return nil, err
-		}
-		values = append(values, v)
-	}
-	return values, nil
-}
-
-func convertValue(val interface{}, typ FieldType, schema Schema) (Value, error) {
-	switch val := val.(type) {
-	case nil:
-		return nil, nil
-	case []interface{}:
-		return convertRepeatedRecord(val, typ, schema)
-	case map[string]interface{}:
-		return convertNestedRecord(val, schema)
-	case string:
-		return convertBasicType(val, typ)
-	default:
-		return nil, fmt.Errorf("got value %v; expected a value of type %s", val, typ)
-	}
-}
-
-func convertRepeatedRecord(vals []interface{}, typ FieldType, schema Schema) (Value, error) {
-	var values []Value
-	for _, cell := range vals {
-		// each cell contains a single entry, keyed by "v"
-		val := cell.(map[string]interface{})["v"]
-		v, err := convertValue(val, typ, schema)
-		if err != nil {
-			return nil, err
-		}
-		values = append(values, v)
-	}
-	return values, nil
-}
-
-func convertNestedRecord(val map[string]interface{}, schema Schema) (Value, error) {
-	// convertNestedRecord is similar to convertRow, as a record has the same structure as a row.
-
-	// Nested records are wrapped in a map with a single key, "f".
-	record := val["f"].([]interface{})
-	if len(record) != len(schema) {
-		return nil, errors.New("schema length does not match record length")
-	}
-
-	var values []Value
-	for i, cell := range record {
-		// each cell contains a single entry, keyed by "v"
-		val := cell.(map[string]interface{})["v"]
-		fs := schema[i]
-		v, err := convertValue(val, fs.Type, fs.Schema)
-		if err != nil {
-			return nil, err
-		}
-		values = append(values, v)
-	}
-	return values, nil
-}
-
-// convertBasicType returns val as an interface with a concrete type specified by typ.
-func convertBasicType(val string, typ FieldType) (Value, error) {
-	switch typ {
-	case StringFieldType:
-		return val, nil
-	case BytesFieldType:
-		return base64.StdEncoding.DecodeString(val)
-	case IntegerFieldType:
-		return strconv.ParseInt(val, 10, 64)
-	case FloatFieldType:
-		return strconv.ParseFloat(val, 64)
-	case BooleanFieldType:
-		return strconv.ParseBool(val)
-	case TimestampFieldType:
-		f, err := strconv.ParseFloat(val, 64)
-		if err != nil {
-			return nil, err
-		}
-		secs := math.Trunc(f)
-		nanos := (f - secs) * 1e9
-		return Value(time.Unix(int64(secs), int64(nanos)).UTC()), nil
-	case DateFieldType:
-		return civil.ParseDate(val)
-	case TimeFieldType:
-		return civil.ParseTime(val)
-	case DateTimeFieldType:
-		return civil.ParseDateTime(val)
-	case NumericFieldType:
-		r, ok := (&big.Rat{}).SetString(val)
-		if !ok {
-			return nil, fmt.Errorf("bigquery: invalid NUMERIC value %q", val)
-		}
-		return Value(r), nil
-	default:
-		return nil, fmt.Errorf("unrecognized type: %s", typ)
-	}
-}

+ 0 - 1214
vendor/cloud.google.com/go/bigquery/value_test.go

@@ -1,1214 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigquery
-
-import (
-	"encoding/base64"
-	"fmt"
-	"math"
-	"math/big"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/civil"
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	bq "google.golang.org/api/bigquery/v2"
-)
-
-func TestConvertBasicValues(t *testing.T) {
-	schema := Schema{
-		{Type: StringFieldType},
-		{Type: IntegerFieldType},
-		{Type: FloatFieldType},
-		{Type: BooleanFieldType},
-		{Type: BytesFieldType},
-		{Type: NumericFieldType},
-	}
-	row := &bq.TableRow{
-		F: []*bq.TableCell{
-			{V: "a"},
-			{V: "1"},
-			{V: "1.2"},
-			{V: "true"},
-			{V: base64.StdEncoding.EncodeToString([]byte("foo"))},
-			{V: "123.123456789"},
-		},
-	}
-	got, err := convertRow(row, schema)
-	if err != nil {
-		t.Fatalf("error converting: %v", err)
-	}
-
-	want := []Value{"a", int64(1), 1.2, true, []byte("foo"), big.NewRat(123123456789, 1e9)}
-	if !testutil.Equal(got, want) {
-		t.Errorf("converting basic values: got:\n%v\nwant:\n%v", got, want)
-	}
-}
-
-func TestConvertTime(t *testing.T) {
-	schema := Schema{
-		{Type: TimestampFieldType},
-		{Type: DateFieldType},
-		{Type: TimeFieldType},
-		{Type: DateTimeFieldType},
-	}
-	ts := testTimestamp.Round(time.Millisecond)
-	row := &bq.TableRow{
-		F: []*bq.TableCell{
-			{V: fmt.Sprintf("%.10f", float64(ts.UnixNano())/1e9)},
-			{V: testDate.String()},
-			{V: testTime.String()},
-			{V: testDateTime.String()},
-		},
-	}
-	got, err := convertRow(row, schema)
-	if err != nil {
-		t.Fatalf("error converting: %v", err)
-	}
-	want := []Value{ts, testDate, testTime, testDateTime}
-	for i, g := range got {
-		w := want[i]
-		if !testutil.Equal(g, w) {
-			t.Errorf("#%d: got:\n%v\nwant:\n%v", i, g, w)
-		}
-	}
-	if got[0].(time.Time).Location() != time.UTC {
-		t.Errorf("expected time zone UTC: got:\n%v", got)
-	}
-}
-
-func TestConvertSmallTimes(t *testing.T) {
-	for _, year := range []int{1600, 1066, 1} {
-		want := time.Date(year, time.January, 1, 0, 0, 0, 0, time.UTC)
-		s := fmt.Sprintf("%.10f", float64(want.Unix()))
-		got, err := convertBasicType(s, TimestampFieldType)
-		if err != nil {
-			t.Fatal(err)
-		}
-		if !got.(time.Time).Equal(want) {
-			t.Errorf("got %v, want %v", got, want)
-		}
-	}
-}
-
-func TestConvertNullValues(t *testing.T) {
-	schema := Schema{{Type: StringFieldType}}
-	row := &bq.TableRow{
-		F: []*bq.TableCell{
-			{V: nil},
-		},
-	}
-	got, err := convertRow(row, schema)
-	if err != nil {
-		t.Fatalf("error converting: %v", err)
-	}
-	want := []Value{nil}
-	if !testutil.Equal(got, want) {
-		t.Errorf("converting null values: got:\n%v\nwant:\n%v", got, want)
-	}
-}
-
-func TestBasicRepetition(t *testing.T) {
-	schema := Schema{
-		{Type: IntegerFieldType, Repeated: true},
-	}
-	row := &bq.TableRow{
-		F: []*bq.TableCell{
-			{
-				V: []interface{}{
-					map[string]interface{}{
-						"v": "1",
-					},
-					map[string]interface{}{
-						"v": "2",
-					},
-					map[string]interface{}{
-						"v": "3",
-					},
-				},
-			},
-		},
-	}
-	got, err := convertRow(row, schema)
-	if err != nil {
-		t.Fatalf("error converting: %v", err)
-	}
-	want := []Value{[]Value{int64(1), int64(2), int64(3)}}
-	if !testutil.Equal(got, want) {
-		t.Errorf("converting basic repeated values: got:\n%v\nwant:\n%v", got, want)
-	}
-}
-
-func TestNestedRecordContainingRepetition(t *testing.T) {
-	schema := Schema{
-		{
-			Type: RecordFieldType,
-			Schema: Schema{
-				{Type: IntegerFieldType, Repeated: true},
-			},
-		},
-	}
-	row := &bq.TableRow{
-		F: []*bq.TableCell{
-			{
-				V: map[string]interface{}{
-					"f": []interface{}{
-						map[string]interface{}{
-							"v": []interface{}{
-								map[string]interface{}{"v": "1"},
-								map[string]interface{}{"v": "2"},
-								map[string]interface{}{"v": "3"},
-							},
-						},
-					},
-				},
-			},
-		},
-	}
-
-	got, err := convertRow(row, schema)
-	if err != nil {
-		t.Fatalf("error converting: %v", err)
-	}
-	want := []Value{[]Value{[]Value{int64(1), int64(2), int64(3)}}}
-	if !testutil.Equal(got, want) {
-		t.Errorf("converting basic repeated values: got:\n%v\nwant:\n%v", got, want)
-	}
-}
-
-func TestRepeatedRecordContainingRepetition(t *testing.T) {
-	schema := Schema{
-		{
-			Type:     RecordFieldType,
-			Repeated: true,
-			Schema: Schema{
-				{Type: IntegerFieldType, Repeated: true},
-			},
-		},
-	}
-	row := &bq.TableRow{F: []*bq.TableCell{
-		{
-			V: []interface{}{ // repeated records.
-				map[string]interface{}{ // first record.
-					"v": map[string]interface{}{ // pointless single-key-map wrapper.
-						"f": []interface{}{ // list of record fields.
-							map[string]interface{}{ // only record (repeated ints)
-								"v": []interface{}{ // pointless wrapper.
-									map[string]interface{}{
-										"v": "1",
-									},
-									map[string]interface{}{
-										"v": "2",
-									},
-									map[string]interface{}{
-										"v": "3",
-									},
-								},
-							},
-						},
-					},
-				},
-				map[string]interface{}{ // second record.
-					"v": map[string]interface{}{
-						"f": []interface{}{
-							map[string]interface{}{
-								"v": []interface{}{
-									map[string]interface{}{
-										"v": "4",
-									},
-									map[string]interface{}{
-										"v": "5",
-									},
-									map[string]interface{}{
-										"v": "6",
-									},
-								},
-							},
-						},
-					},
-				},
-			},
-		},
-	}}
-
-	got, err := convertRow(row, schema)
-	if err != nil {
-		t.Fatalf("error converting: %v", err)
-	}
-	want := []Value{ // the row is a list of length 1, containing an entry for the repeated record.
-		[]Value{ // the repeated record is a list of length 2, containing an entry for each repetition.
-			[]Value{ // the record is a list of length 1, containing an entry for the repeated integer field.
-				[]Value{int64(1), int64(2), int64(3)}, // the repeated integer field is a list of length 3.
-			},
-			[]Value{ // second record
-				[]Value{int64(4), int64(5), int64(6)},
-			},
-		},
-	}
-	if !testutil.Equal(got, want) {
-		t.Errorf("converting repeated records with repeated values: got:\n%v\nwant:\n%v", got, want)
-	}
-}
-
-func TestRepeatedRecordContainingRecord(t *testing.T) {
-	schema := Schema{
-		{
-			Type:     RecordFieldType,
-			Repeated: true,
-			Schema: Schema{
-				{
-					Type: StringFieldType,
-				},
-				{
-					Type: RecordFieldType,
-					Schema: Schema{
-						{Type: IntegerFieldType},
-						{Type: StringFieldType},
-					},
-				},
-			},
-		},
-	}
-	row := &bq.TableRow{F: []*bq.TableCell{
-		{
-			V: []interface{}{ // repeated records.
-				map[string]interface{}{ // first record.
-					"v": map[string]interface{}{ // pointless single-key-map wrapper.
-						"f": []interface{}{ // list of record fields.
-							map[string]interface{}{ // first record field (name)
-								"v": "first repeated record",
-							},
-							map[string]interface{}{ // second record field (nested record).
-								"v": map[string]interface{}{ // pointless single-key-map wrapper.
-									"f": []interface{}{ // nested record fields
-										map[string]interface{}{
-											"v": "1",
-										},
-										map[string]interface{}{
-											"v": "two",
-										},
-									},
-								},
-							},
-						},
-					},
-				},
-				map[string]interface{}{ // second record.
-					"v": map[string]interface{}{
-						"f": []interface{}{
-							map[string]interface{}{
-								"v": "second repeated record",
-							},
-							map[string]interface{}{
-								"v": map[string]interface{}{
-									"f": []interface{}{
-										map[string]interface{}{
-											"v": "3",
-										},
-										map[string]interface{}{
-											"v": "four",
-										},
-									},
-								},
-							},
-						},
-					},
-				},
-			},
-		},
-	}}
-
-	got, err := convertRow(row, schema)
-	if err != nil {
-		t.Fatalf("error converting: %v", err)
-	}
-	// TODO: test with flattenresults.
-	want := []Value{ // the row is a list of length 1, containing an entry for the repeated record.
-		[]Value{ // the repeated record is a list of length 2, containing an entry for each repetition.
-			[]Value{ // record contains a string followed by a nested record.
-				"first repeated record",
-				[]Value{
-					int64(1),
-					"two",
-				},
-			},
-			[]Value{ // second record.
-				"second repeated record",
-				[]Value{
-					int64(3),
-					"four",
-				},
-			},
-		},
-	}
-	if !testutil.Equal(got, want) {
-		t.Errorf("converting repeated records containing record : got:\n%v\nwant:\n%v", got, want)
-	}
-}
-
-func TestConvertRowErrors(t *testing.T) {
-	// mismatched lengths
-	if _, err := convertRow(&bq.TableRow{F: []*bq.TableCell{{V: ""}}}, Schema{}); err == nil {
-		t.Error("got nil, want error")
-	}
-	v3 := map[string]interface{}{"v": 3}
-	for _, test := range []struct {
-		value interface{}
-		fs    FieldSchema
-	}{
-		{3, FieldSchema{Type: IntegerFieldType}}, // not a string
-		{[]interface{}{v3}, // not a string, repeated
-			FieldSchema{Type: IntegerFieldType, Repeated: true}},
-		{map[string]interface{}{"f": []interface{}{v3}}, // not a string, nested
-			FieldSchema{Type: RecordFieldType, Schema: Schema{{Type: IntegerFieldType}}}},
-		{map[string]interface{}{"f": []interface{}{v3}}, // wrong length, nested
-			FieldSchema{Type: RecordFieldType, Schema: Schema{}}},
-	} {
-		_, err := convertRow(
-			&bq.TableRow{F: []*bq.TableCell{{V: test.value}}},
-			Schema{&test.fs})
-		if err == nil {
-			t.Errorf("value %v, fs %v: got nil, want error", test.value, test.fs)
-		}
-	}
-
-	// bad field type
-	if _, err := convertBasicType("", FieldType("BAD")); err == nil {
-		t.Error("got nil, want error")
-	}
-}
-
-func TestValuesSaverConvertsToMap(t *testing.T) {
-	testCases := []struct {
-		vs           ValuesSaver
-		wantInsertID string
-		wantRow      map[string]Value
-	}{
-		{
-			vs: ValuesSaver{
-				Schema: Schema{
-					{Name: "intField", Type: IntegerFieldType},
-					{Name: "strField", Type: StringFieldType},
-					{Name: "dtField", Type: DateTimeFieldType},
-					{Name: "nField", Type: NumericFieldType},
-				},
-				InsertID: "iid",
-				Row: []Value{1, "a",
-					civil.DateTime{
-						Date: civil.Date{Year: 1, Month: 2, Day: 3},
-						Time: civil.Time{Hour: 4, Minute: 5, Second: 6, Nanosecond: 7000}},
-					big.NewRat(123456789000, 1e9),
-				},
-			},
-			wantInsertID: "iid",
-			wantRow: map[string]Value{
-				"intField": 1,
-				"strField": "a",
-				"dtField":  "0001-02-03 04:05:06.000007",
-				"nField":   "123.456789000",
-			},
-		},
-		{
-			vs: ValuesSaver{
-				Schema: Schema{
-					{Name: "intField", Type: IntegerFieldType},
-					{
-						Name: "recordField",
-						Type: RecordFieldType,
-						Schema: Schema{
-							{Name: "nestedInt", Type: IntegerFieldType, Repeated: true},
-						},
-					},
-				},
-				InsertID: "iid",
-				Row:      []Value{1, []Value{[]Value{2, 3}}},
-			},
-			wantInsertID: "iid",
-			wantRow: map[string]Value{
-				"intField": 1,
-				"recordField": map[string]Value{
-					"nestedInt": []Value{2, 3},
-				},
-			},
-		},
-		{ // repeated nested field
-			vs: ValuesSaver{
-				Schema: Schema{
-					{
-						Name: "records",
-						Type: RecordFieldType,
-						Schema: Schema{
-							{Name: "x", Type: IntegerFieldType},
-							{Name: "y", Type: IntegerFieldType},
-						},
-						Repeated: true,
-					},
-				},
-				InsertID: "iid",
-				Row: []Value{ // a row is a []Value
-					[]Value{ // repeated field's value is a []Value
-						[]Value{1, 2}, // first record of the repeated field
-						[]Value{3, 4}, // second record
-					},
-				},
-			},
-			wantInsertID: "iid",
-			wantRow: map[string]Value{
-				"records": []Value{
-					map[string]Value{"x": 1, "y": 2},
-					map[string]Value{"x": 3, "y": 4},
-				},
-			},
-		},
-	}
-	for _, tc := range testCases {
-		gotRow, gotInsertID, err := tc.vs.Save()
-		if err != nil {
-			t.Errorf("Expected successful save; got: %v", err)
-			continue
-		}
-		if !testutil.Equal(gotRow, tc.wantRow) {
-			t.Errorf("%v row:\ngot:\n%+v\nwant:\n%+v", tc.vs, gotRow, tc.wantRow)
-		}
-		if !testutil.Equal(gotInsertID, tc.wantInsertID) {
-			t.Errorf("%v ID:\ngot:\n%+v\nwant:\n%+v", tc.vs, gotInsertID, tc.wantInsertID)
-		}
-	}
-}
-
-func TestValuesToMapErrors(t *testing.T) {
-	for _, test := range []struct {
-		values []Value
-		schema Schema
-	}{
-		{ // mismatched length
-			[]Value{1},
-			Schema{},
-		},
-		{ // nested record not a slice
-			[]Value{1},
-			Schema{{Type: RecordFieldType}},
-		},
-		{ // nested record mismatched length
-			[]Value{[]Value{1}},
-			Schema{{Type: RecordFieldType}},
-		},
-		{ // nested repeated record not a slice
-			[]Value{[]Value{1}},
-			Schema{{Type: RecordFieldType, Repeated: true}},
-		},
-		{ // nested repeated record mismatched length
-			[]Value{[]Value{[]Value{1}}},
-			Schema{{Type: RecordFieldType, Repeated: true}},
-		},
-	} {
-		_, err := valuesToMap(test.values, test.schema)
-		if err == nil {
-			t.Errorf("%v, %v: got nil, want error", test.values, test.schema)
-		}
-	}
-}
-
-func TestStructSaver(t *testing.T) {
-	schema := Schema{
-		{Name: "s", Type: StringFieldType},
-		{Name: "r", Type: IntegerFieldType, Repeated: true},
-		{Name: "t", Type: TimeFieldType},
-		{Name: "tr", Type: TimeFieldType, Repeated: true},
-		{Name: "nested", Type: RecordFieldType, Schema: Schema{
-			{Name: "b", Type: BooleanFieldType},
-		}},
-		{Name: "rnested", Type: RecordFieldType, Repeated: true, Schema: Schema{
-			{Name: "b", Type: BooleanFieldType},
-		}},
-		{Name: "p", Type: IntegerFieldType, Required: false},
-		{Name: "n", Type: NumericFieldType, Required: false},
-		{Name: "nr", Type: NumericFieldType, Repeated: true},
-	}
-
-	type (
-		N struct{ B bool }
-		T struct {
-			S       string
-			R       []int
-			T       civil.Time
-			TR      []civil.Time
-			Nested  *N
-			Rnested []*N
-			P       NullInt64
-			N       *big.Rat
-			NR      []*big.Rat
-		}
-	)
-
-	check := func(msg string, in interface{}, want map[string]Value) {
-		ss := StructSaver{
-			Schema:   schema,
-			InsertID: "iid",
-			Struct:   in,
-		}
-		got, gotIID, err := ss.Save()
-		if err != nil {
-			t.Fatalf("%s: %v", msg, err)
-		}
-		if wantIID := "iid"; gotIID != wantIID {
-			t.Errorf("%s: InsertID: got %q, want %q", msg, gotIID, wantIID)
-		}
-		if diff := testutil.Diff(got, want); diff != "" {
-			t.Errorf("%s: %s", msg, diff)
-		}
-	}
-
-	ct1 := civil.Time{Hour: 1, Minute: 2, Second: 3, Nanosecond: 4000}
-	ct2 := civil.Time{Hour: 5, Minute: 6, Second: 7, Nanosecond: 8000}
-	in := T{
-		S:       "x",
-		R:       []int{1, 2},
-		T:       ct1,
-		TR:      []civil.Time{ct1, ct2},
-		Nested:  &N{B: true},
-		Rnested: []*N{{true}, {false}},
-		P:       NullInt64{Valid: true, Int64: 17},
-		N:       big.NewRat(123456, 1000),
-		NR:      []*big.Rat{big.NewRat(3, 1), big.NewRat(56789, 1e5)},
-	}
-	want := map[string]Value{
-		"s":       "x",
-		"r":       []int{1, 2},
-		"t":       "01:02:03.000004",
-		"tr":      []string{"01:02:03.000004", "05:06:07.000008"},
-		"nested":  map[string]Value{"b": true},
-		"rnested": []Value{map[string]Value{"b": true}, map[string]Value{"b": false}},
-		"p":       NullInt64{Valid: true, Int64: 17},
-		"n":       "123.456000000",
-		"nr":      []string{"3.000000000", "0.567890000"},
-	}
-	check("all values", in, want)
-	check("all values, ptr", &in, want)
-	check("empty struct", T{}, map[string]Value{"s": "", "t": "00:00:00", "p": NullInt64{}})
-
-	// Missing and extra fields ignored.
-	type T2 struct {
-		S string
-		// missing R, Nested, RNested
-		Extra int
-	}
-	check("missing and extra", T2{S: "x"}, map[string]Value{"s": "x"})
-
-	check("nils in slice", T{Rnested: []*N{{true}, nil, {false}}},
-		map[string]Value{
-			"s":       "",
-			"t":       "00:00:00",
-			"p":       NullInt64{},
-			"rnested": []Value{map[string]Value{"b": true}, map[string]Value(nil), map[string]Value{"b": false}},
-		})
-
-	check("zero-length repeated", T{Rnested: []*N{}},
-		map[string]Value{
-			"rnested": []Value{},
-			"s":       "",
-			"t":       "00:00:00",
-			"p":       NullInt64{},
-		})
-}
-
-func TestStructSaverErrors(t *testing.T) {
-	type (
-		badField struct {
-			I int `bigquery:"@"`
-		}
-		badR  struct{ R int }
-		badRN struct{ R []int }
-	)
-
-	for i, test := range []struct {
-		inputStruct interface{}
-		schema      Schema
-	}{
-		{0, nil},           // not a struct
-		{&badField{}, nil}, // bad field name
-		{&badR{}, Schema{{Name: "r", Repeated: true}}},        // repeated field has bad type
-		{&badR{}, Schema{{Name: "r", Type: RecordFieldType}}}, // nested field has bad type
-		{&badRN{[]int{0}}, // nested repeated field has bad type
-			Schema{{Name: "r", Type: RecordFieldType, Repeated: true}}},
-	} {
-		ss := &StructSaver{Struct: test.inputStruct, Schema: test.schema}
-		_, _, err := ss.Save()
-		if err == nil {
-			t.Errorf("#%d, %v, %v: got nil, want error", i, test.inputStruct, test.schema)
-		}
-	}
-}
-
-func TestNumericString(t *testing.T) {
-	for _, test := range []struct {
-		in   *big.Rat
-		want string
-	}{
-		{big.NewRat(2, 3), "0.666666667"}, // round to 9 places
-		{big.NewRat(1, 2), "0.500000000"},
-		{big.NewRat(1, 2*1e8), "0.000000005"},
-		{big.NewRat(5, 1e10), "0.000000001"},   // round up the 5 in the 10th decimal place
-		{big.NewRat(-5, 1e10), "-0.000000001"}, // round half away from zero
-	} {
-		got := NumericString(test.in)
-		if got != test.want {
-			t.Errorf("%v: got %q, want %q", test.in, got, test.want)
-		}
-	}
-}
-
-func TestConvertRows(t *testing.T) {
-	schema := Schema{
-		{Type: StringFieldType},
-		{Type: IntegerFieldType},
-		{Type: FloatFieldType},
-		{Type: BooleanFieldType},
-	}
-	rows := []*bq.TableRow{
-		{F: []*bq.TableCell{
-			{V: "a"},
-			{V: "1"},
-			{V: "1.2"},
-			{V: "true"},
-		}},
-		{F: []*bq.TableCell{
-			{V: "b"},
-			{V: "2"},
-			{V: "2.2"},
-			{V: "false"},
-		}},
-	}
-	want := [][]Value{
-		{"a", int64(1), 1.2, true},
-		{"b", int64(2), 2.2, false},
-	}
-	got, err := convertRows(rows, schema)
-	if err != nil {
-		t.Fatalf("got %v, want nil", err)
-	}
-	if !testutil.Equal(got, want) {
-		t.Errorf("\ngot  %v\nwant %v", got, want)
-	}
-
-	rows[0].F[0].V = 1
-	_, err = convertRows(rows, schema)
-	if err == nil {
-		t.Error("got nil, want error")
-	}
-}
-
-func TestValueList(t *testing.T) {
-	schema := Schema{
-		{Name: "s", Type: StringFieldType},
-		{Name: "i", Type: IntegerFieldType},
-		{Name: "f", Type: FloatFieldType},
-		{Name: "b", Type: BooleanFieldType},
-	}
-	want := []Value{"x", 7, 3.14, true}
-	var got []Value
-	vl := (*valueList)(&got)
-	if err := vl.Load(want, schema); err != nil {
-		t.Fatal(err)
-	}
-
-	if !testutil.Equal(got, want) {
-		t.Errorf("got %+v, want %+v", got, want)
-	}
-
-	// Load truncates, not appends.
-	// https://github.com/googleapis/google-cloud-go/issues/437
-	if err := vl.Load(want, schema); err != nil {
-		t.Fatal(err)
-	}
-	if !testutil.Equal(got, want) {
-		t.Errorf("got %+v, want %+v", got, want)
-	}
-}
-
-func TestValueMap(t *testing.T) {
-	ns := Schema{
-		{Name: "x", Type: IntegerFieldType},
-		{Name: "y", Type: IntegerFieldType},
-	}
-	schema := Schema{
-		{Name: "s", Type: StringFieldType},
-		{Name: "i", Type: IntegerFieldType},
-		{Name: "f", Type: FloatFieldType},
-		{Name: "b", Type: BooleanFieldType},
-		{Name: "n", Type: RecordFieldType, Schema: ns},
-		{Name: "rn", Type: RecordFieldType, Schema: ns, Repeated: true},
-	}
-	in := []Value{"x", 7, 3.14, true,
-		[]Value{1, 2},
-		[]Value{[]Value{3, 4}, []Value{5, 6}},
-	}
-	var vm valueMap
-	if err := vm.Load(in, schema); err != nil {
-		t.Fatal(err)
-	}
-	want := map[string]Value{
-		"s": "x",
-		"i": 7,
-		"f": 3.14,
-		"b": true,
-		"n": map[string]Value{"x": 1, "y": 2},
-		"rn": []Value{
-			map[string]Value{"x": 3, "y": 4},
-			map[string]Value{"x": 5, "y": 6},
-		},
-	}
-	if !testutil.Equal(vm, valueMap(want)) {
-		t.Errorf("got\n%+v\nwant\n%+v", vm, want)
-	}
-
-	in = make([]Value, len(schema))
-	want = map[string]Value{
-		"s":  nil,
-		"i":  nil,
-		"f":  nil,
-		"b":  nil,
-		"n":  nil,
-		"rn": nil,
-	}
-	var vm2 valueMap
-	if err := vm2.Load(in, schema); err != nil {
-		t.Fatal(err)
-	}
-	if !testutil.Equal(vm2, valueMap(want)) {
-		t.Errorf("got\n%+v\nwant\n%+v", vm2, want)
-	}
-}
-
-var (
-	// For testing StructLoader
-	schema2 = Schema{
-		{Name: "s", Type: StringFieldType},
-		{Name: "s2", Type: StringFieldType},
-		{Name: "by", Type: BytesFieldType},
-		{Name: "I", Type: IntegerFieldType},
-		{Name: "U", Type: IntegerFieldType},
-		{Name: "F", Type: FloatFieldType},
-		{Name: "B", Type: BooleanFieldType},
-		{Name: "TS", Type: TimestampFieldType},
-		{Name: "D", Type: DateFieldType},
-		{Name: "T", Type: TimeFieldType},
-		{Name: "DT", Type: DateTimeFieldType},
-		{Name: "N", Type: NumericFieldType},
-		{Name: "nested", Type: RecordFieldType, Schema: Schema{
-			{Name: "nestS", Type: StringFieldType},
-			{Name: "nestI", Type: IntegerFieldType},
-		}},
-		{Name: "t", Type: StringFieldType},
-	}
-
-	testTimestamp = time.Date(2016, 11, 5, 7, 50, 22, 8, time.UTC)
-	testDate      = civil.Date{Year: 2016, Month: 11, Day: 5}
-	testTime      = civil.Time{Hour: 7, Minute: 50, Second: 22, Nanosecond: 8}
-	testDateTime  = civil.DateTime{Date: testDate, Time: testTime}
-	testNumeric   = big.NewRat(123, 456)
-
-	testValues = []Value{"x", "y", []byte{1, 2, 3}, int64(7), int64(8), 3.14, true,
-		testTimestamp, testDate, testTime, testDateTime, testNumeric,
-		[]Value{"nested", int64(17)}, "z"}
-)
-
-type testStruct1 struct {
-	B bool
-	I int
-	U uint16
-	times
-	S      string
-	S2     String
-	By     []byte
-	F      float64
-	N      *big.Rat
-	Nested nested
-	Tagged string `bigquery:"t"`
-}
-
-type String string
-
-type nested struct {
-	NestS string
-	NestI int
-}
-
-type times struct {
-	TS time.Time
-	T  civil.Time
-	D  civil.Date
-	DT civil.DateTime
-}
-
-func TestStructLoader(t *testing.T) {
-	var ts1 testStruct1
-	mustLoad(t, &ts1, schema2, testValues)
-	// Note: the schema field named "s" gets matched to the exported struct
-	// field "S", not the unexported "s".
-	want := &testStruct1{
-		B:      true,
-		I:      7,
-		U:      8,
-		F:      3.14,
-		times:  times{TS: testTimestamp, T: testTime, D: testDate, DT: testDateTime},
-		S:      "x",
-		S2:     "y",
-		By:     []byte{1, 2, 3},
-		N:      big.NewRat(123, 456),
-		Nested: nested{NestS: "nested", NestI: 17},
-		Tagged: "z",
-	}
-	if diff := testutil.Diff(&ts1, want, cmp.AllowUnexported(testStruct1{})); diff != "" {
-		t.Error(diff)
-	}
-
-	// Test pointers to nested structs.
-	type nestedPtr struct{ Nested *nested }
-	var np nestedPtr
-	mustLoad(t, &np, schema2, testValues)
-	want2 := &nestedPtr{Nested: &nested{NestS: "nested", NestI: 17}}
-	if diff := testutil.Diff(&np, want2); diff != "" {
-		t.Error(diff)
-	}
-
-	// Existing values should be reused.
-	nst := &nested{NestS: "x", NestI: -10}
-	np = nestedPtr{Nested: nst}
-	mustLoad(t, &np, schema2, testValues)
-	if diff := testutil.Diff(&np, want2); diff != "" {
-		t.Error(diff)
-	}
-	if np.Nested != nst {
-		t.Error("nested struct pointers not equal")
-	}
-}
-
-type repStruct struct {
-	Nums      []int
-	ShortNums [2]int // to test truncation
-	LongNums  [5]int // to test padding with zeroes
-	Nested    []*nested
-}
-
-var (
-	repSchema = Schema{
-		{Name: "nums", Type: IntegerFieldType, Repeated: true},
-		{Name: "shortNums", Type: IntegerFieldType, Repeated: true},
-		{Name: "longNums", Type: IntegerFieldType, Repeated: true},
-		{Name: "nested", Type: RecordFieldType, Repeated: true, Schema: Schema{
-			{Name: "nestS", Type: StringFieldType},
-			{Name: "nestI", Type: IntegerFieldType},
-		}},
-	}
-	v123      = []Value{int64(1), int64(2), int64(3)}
-	repValues = []Value{v123, v123, v123,
-		[]Value{
-			[]Value{"x", int64(1)},
-			[]Value{"y", int64(2)},
-		},
-	}
-)
-
-func TestStructLoaderRepeated(t *testing.T) {
-	var r1 repStruct
-	mustLoad(t, &r1, repSchema, repValues)
-	want := repStruct{
-		Nums:      []int{1, 2, 3},
-		ShortNums: [...]int{1, 2}, // extra values discarded
-		LongNums:  [...]int{1, 2, 3, 0, 0},
-		Nested:    []*nested{{"x", 1}, {"y", 2}},
-	}
-	if diff := testutil.Diff(r1, want); diff != "" {
-		t.Error(diff)
-	}
-	r2 := repStruct{
-		Nums:     []int{-1, -2, -3, -4, -5},    // truncated to zero and appended to
-		LongNums: [...]int{-1, -2, -3, -4, -5}, // unset elements are zeroed
-	}
-	mustLoad(t, &r2, repSchema, repValues)
-	if diff := testutil.Diff(r2, want); diff != "" {
-		t.Error(diff)
-	}
-	if got, want := cap(r2.Nums), 5; got != want {
-		t.Errorf("cap(r2.Nums) = %d, want %d", got, want)
-	}
-
-	// Short slice case.
-	r3 := repStruct{Nums: []int{-1}}
-	mustLoad(t, &r3, repSchema, repValues)
-	if diff := testutil.Diff(r3, want); diff != "" {
-		t.Error(diff)
-	}
-	if got, want := cap(r3.Nums), 3; got != want {
-		t.Errorf("cap(r3.Nums) = %d, want %d", got, want)
-	}
-}
-
-type testStructNullable struct {
-	String    NullString
-	Bytes     []byte
-	Integer   NullInt64
-	Float     NullFloat64
-	Boolean   NullBool
-	Timestamp NullTimestamp
-	Date      NullDate
-	Time      NullTime
-	DateTime  NullDateTime
-	Numeric   *big.Rat
-	Record    *subNullable
-}
-
-type subNullable struct {
-	X NullInt64
-}
-
-var testStructNullableSchema = Schema{
-	{Name: "String", Type: StringFieldType, Required: false},
-	{Name: "Bytes", Type: BytesFieldType, Required: false},
-	{Name: "Integer", Type: IntegerFieldType, Required: false},
-	{Name: "Float", Type: FloatFieldType, Required: false},
-	{Name: "Boolean", Type: BooleanFieldType, Required: false},
-	{Name: "Timestamp", Type: TimestampFieldType, Required: false},
-	{Name: "Date", Type: DateFieldType, Required: false},
-	{Name: "Time", Type: TimeFieldType, Required: false},
-	{Name: "DateTime", Type: DateTimeFieldType, Required: false},
-	{Name: "Numeric", Type: NumericFieldType, Required: false},
-	{Name: "Record", Type: RecordFieldType, Required: false, Schema: Schema{
-		{Name: "X", Type: IntegerFieldType, Required: false},
-	}},
-}
-
-func TestStructLoaderNullable(t *testing.T) {
-	var ts testStructNullable
-	nilVals := make([]Value, len(testStructNullableSchema))
-	mustLoad(t, &ts, testStructNullableSchema, nilVals)
-	want := testStructNullable{}
-	if diff := testutil.Diff(ts, want); diff != "" {
-		t.Error(diff)
-	}
-
-	nonnilVals := []Value{"x", []byte{1, 2, 3}, int64(1), 2.3, true, testTimestamp, testDate, testTime,
-		testDateTime, big.NewRat(1, 2), []Value{int64(4)}}
-
-	// All ts fields are nil. Loading non-nil values will cause them all to
-	// be allocated.
-	mustLoad(t, &ts, testStructNullableSchema, nonnilVals)
-	want = testStructNullable{
-		String:    NullString{StringVal: "x", Valid: true},
-		Bytes:     []byte{1, 2, 3},
-		Integer:   NullInt64{Int64: 1, Valid: true},
-		Float:     NullFloat64{Float64: 2.3, Valid: true},
-		Boolean:   NullBool{Bool: true, Valid: true},
-		Timestamp: NullTimestamp{Timestamp: testTimestamp, Valid: true},
-		Date:      NullDate{Date: testDate, Valid: true},
-		Time:      NullTime{Time: testTime, Valid: true},
-		DateTime:  NullDateTime{DateTime: testDateTime, Valid: true},
-		Numeric:   big.NewRat(1, 2),
-		Record:    &subNullable{X: NullInt64{Int64: 4, Valid: true}},
-	}
-	if diff := testutil.Diff(ts, want); diff != "" {
-		t.Error(diff)
-	}
-
-	// Struct pointers are reused, byte slices are not.
-	want = ts
-	want.Bytes = []byte{17}
-	vals2 := []Value{nil, []byte{17}, nil, nil, nil, nil, nil, nil, nil, nil, []Value{int64(7)}}
-	mustLoad(t, &ts, testStructNullableSchema, vals2)
-	if ts.Record != want.Record {
-		t.Error("record pointers not identical")
-	}
-}
-
-func TestStructLoaderOverflow(t *testing.T) {
-	type S struct {
-		I int16
-		U uint16
-		F float32
-	}
-	schema := Schema{
-		{Name: "I", Type: IntegerFieldType},
-		{Name: "U", Type: IntegerFieldType},
-		{Name: "F", Type: FloatFieldType},
-	}
-	var s S
-	z64 := int64(0)
-	for _, vals := range [][]Value{
-		{int64(math.MaxInt16 + 1), z64, 0},
-		{z64, int64(math.MaxInt32), 0},
-		{z64, int64(-1), 0},
-		{z64, z64, math.MaxFloat32 * 2},
-	} {
-		if err := load(&s, schema, vals); err == nil {
-			t.Errorf("%+v: got nil, want error", vals)
-		}
-	}
-}
-
-func TestStructLoaderFieldOverlap(t *testing.T) {
-	// It's OK if the struct has fields that the schema does not, and vice versa.
-	type S1 struct {
-		I int
-		X [][]int // not in the schema; does not even correspond to a valid BigQuery type
-		// many schema fields missing
-	}
-	var s1 S1
-	if err := load(&s1, schema2, testValues); err != nil {
-		t.Fatal(err)
-	}
-	want1 := S1{I: 7}
-	if diff := testutil.Diff(s1, want1); diff != "" {
-		t.Error(diff)
-	}
-
-	// It's even valid to have no overlapping fields at all.
-	type S2 struct{ Z int }
-
-	var s2 S2
-	mustLoad(t, &s2, schema2, testValues)
-	want2 := S2{}
-	if diff := testutil.Diff(s2, want2); diff != "" {
-		t.Error(diff)
-	}
-}
-
-func TestStructLoaderErrors(t *testing.T) {
-	check := func(sp interface{}) {
-		var sl structLoader
-		err := sl.set(sp, schema2)
-		if err == nil {
-			t.Errorf("%T: got nil, want error", sp)
-		}
-	}
-
-	type bad1 struct{ F int32 } // wrong type for FLOAT column
-	check(&bad1{})
-
-	type bad2 struct{ I uint } // unsupported integer type
-	check(&bad2{})
-
-	type bad3 struct {
-		I int `bigquery:"@"`
-	} // bad field name
-	check(&bad3{})
-
-	type bad4 struct{ Nested int } // non-struct for nested field
-	check(&bad4{})
-
-	type bad5 struct{ Nested struct{ NestS int } } // bad nested struct
-	check(&bad5{})
-
-	bad6 := &struct{ Nums int }{} // non-slice for repeated field
-	sl := structLoader{}
-	err := sl.set(bad6, repSchema)
-	if err == nil {
-		t.Errorf("%T: got nil, want error", bad6)
-	}
-
-	// sl.set's error is sticky, even with good input.
-	err2 := sl.set(&repStruct{}, repSchema)
-	if err2 != err {
-		t.Errorf("%v != %v, expected equal", err2, err)
-	}
-	// sl.Load is similarly sticky
-	err2 = sl.Load(nil, nil)
-	if err2 != err {
-		t.Errorf("%v != %v, expected equal", err2, err)
-	}
-
-	// Null values.
-	schema := Schema{
-		{Name: "i", Type: IntegerFieldType},
-		{Name: "f", Type: FloatFieldType},
-		{Name: "b", Type: BooleanFieldType},
-		{Name: "s", Type: StringFieldType},
-		{Name: "d", Type: DateFieldType},
-		{Name: "r", Type: RecordFieldType, Schema: Schema{{Name: "X", Type: IntegerFieldType}}},
-	}
-	type s struct {
-		I int
-		F float64
-		B bool
-		S string
-		D civil.Date
-	}
-	vals := []Value{int64(0), 0.0, false, "", testDate}
-	mustLoad(t, &s{}, schema, vals)
-	for i, e := range vals {
-		vals[i] = nil
-		got := load(&s{}, schema, vals)
-		if got != errNoNulls {
-			t.Errorf("#%d: got %v, want %v", i, got, errNoNulls)
-		}
-		vals[i] = e
-	}
-
-	// Using more than one struct type with the same structLoader.
-	type different struct {
-		B bool
-		I int
-		times
-		S    string
-		Nums []int
-	}
-
-	sl = structLoader{}
-	if err := sl.set(&testStruct1{}, schema2); err != nil {
-		t.Fatal(err)
-	}
-	err = sl.set(&different{}, schema2)
-	if err == nil {
-		t.Error("different struct types: got nil, want error")
-	}
-}
-
-func mustLoad(t *testing.T, pval interface{}, schema Schema, vals []Value) {
-	if err := load(pval, schema, vals); err != nil {
-		t.Fatalf("loading: %v", err)
-	}
-}
-
-func load(pval interface{}, schema Schema, vals []Value) error {
-	var sl structLoader
-	if err := sl.set(pval, schema); err != nil {
-		return err
-	}
-	return sl.Load(vals, nil)
-}
-
-func BenchmarkStructLoader_NoCompile(b *testing.B) {
-	benchmarkStructLoader(b, false)
-}
-
-func BenchmarkStructLoader_Compile(b *testing.B) {
-	benchmarkStructLoader(b, true)
-}
-
-func benchmarkStructLoader(b *testing.B, compile bool) {
-	var ts1 testStruct1
-	for i := 0; i < b.N; i++ {
-		var sl structLoader
-		for j := 0; j < 10; j++ {
-			if err := load(&ts1, schema2, testValues); err != nil {
-				b.Fatal(err)
-			}
-			if !compile {
-				sl.typ = nil
-			}
-		}
-	}
-}

+ 0 - 1133
vendor/cloud.google.com/go/bigtable/admin.go

@@ -1,1133 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package bigtable
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"math"
-	"regexp"
-	"strings"
-	"time"
-
-	"cloud.google.com/go/bigtable/internal/gax"
-	btopt "cloud.google.com/go/bigtable/internal/option"
-	"cloud.google.com/go/iam"
-	"cloud.google.com/go/internal/optional"
-	"cloud.google.com/go/longrunning"
-	lroauto "cloud.google.com/go/longrunning/autogen"
-	"github.com/golang/protobuf/ptypes"
-	durpb "github.com/golang/protobuf/ptypes/duration"
-	"google.golang.org/api/cloudresourcemanager/v1"
-	"google.golang.org/api/iterator"
-	"google.golang.org/api/option"
-	gtransport "google.golang.org/api/transport/grpc"
-	btapb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
-	"google.golang.org/genproto/protobuf/field_mask"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/metadata"
-	"google.golang.org/grpc/status"
-)
-
-const adminAddr = "bigtableadmin.googleapis.com:443"
-
-// AdminClient is a client type for performing admin operations within a specific instance.
-type AdminClient struct {
-	conn      *grpc.ClientConn
-	tClient   btapb.BigtableTableAdminClient
-	lroClient *lroauto.OperationsClient
-
-	project, instance string
-
-	// Metadata to be sent with each request.
-	md metadata.MD
-}
-
-// NewAdminClient creates a new AdminClient for a given project and instance.
-func NewAdminClient(ctx context.Context, project, instance string, opts ...option.ClientOption) (*AdminClient, error) {
-	o, err := btopt.DefaultClientOptions(adminAddr, AdminScope, clientUserAgent)
-	if err != nil {
-		return nil, err
-	}
-	// Need to add scopes for long running operations (for create table & snapshots)
-	o = append(o, option.WithScopes(cloudresourcemanager.CloudPlatformScope))
-	o = append(o, opts...)
-	conn, err := gtransport.Dial(ctx, o...)
-	if err != nil {
-		return nil, fmt.Errorf("dialing: %v", err)
-	}
-
-	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 &AdminClient{
-		conn:      conn,
-		tClient:   btapb.NewBigtableTableAdminClient(conn),
-		lroClient: lroClient,
-		project:   project,
-		instance:  instance,
-		md:        metadata.Pairs(resourcePrefixHeader, fmt.Sprintf("projects/%s/instances/%s", project, instance)),
-	}, nil
-}
-
-// Close closes the AdminClient.
-func (ac *AdminClient) Close() error {
-	return ac.conn.Close()
-}
-
-func (ac *AdminClient) instancePrefix() string {
-	return fmt.Sprintf("projects/%s/instances/%s", ac.project, ac.instance)
-}
-
-// Tables returns a list of the tables in the instance.
-func (ac *AdminClient) Tables(ctx context.Context) ([]string, error) {
-	ctx = mergeOutgoingMetadata(ctx, ac.md)
-	prefix := ac.instancePrefix()
-	req := &btapb.ListTablesRequest{
-		Parent: prefix,
-	}
-
-	var res *btapb.ListTablesResponse
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		res, err = ac.tClient.ListTables(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-
-	names := make([]string, 0, len(res.Tables))
-	for _, tbl := range res.Tables {
-		names = append(names, strings.TrimPrefix(tbl.Name, prefix+"/tables/"))
-	}
-	return names, nil
-}
-
-// TableConf contains all of the information necessary to create a table with column families.
-type TableConf struct {
-	TableID   string
-	SplitKeys []string
-	// Families is a map from family name to GCPolicy
-	Families map[string]GCPolicy
-}
-
-// CreateTable creates a new table in the instance.
-// This method may return before the table's creation is complete.
-func (ac *AdminClient) CreateTable(ctx context.Context, table string) error {
-	return ac.CreateTableFromConf(ctx, &TableConf{TableID: table})
-}
-
-// CreatePresplitTable creates a new table in the instance.
-// The list of row keys will be used to initially split the table into multiple tablets.
-// Given two split keys, "s1" and "s2", three tablets will be created,
-// spanning the key ranges: [, s1), [s1, s2), [s2, ).
-// This method may return before the table's creation is complete.
-func (ac *AdminClient) CreatePresplitTable(ctx context.Context, table string, splitKeys []string) error {
-	return ac.CreateTableFromConf(ctx, &TableConf{TableID: table, SplitKeys: splitKeys})
-}
-
-// 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, ac.md)
-	var reqSplits []*btapb.CreateTableRequest_Split
-	for _, split := range conf.SplitKeys {
-		reqSplits = append(reqSplits, &btapb.CreateTableRequest_Split{Key: []byte(split)})
-	}
-	var tbl btapb.Table
-	if conf.Families != nil {
-		tbl.ColumnFamilies = make(map[string]*btapb.ColumnFamily)
-		for fam, policy := range conf.Families {
-			tbl.ColumnFamilies[fam] = &btapb.ColumnFamily{GcRule: policy.proto()}
-		}
-	}
-	prefix := ac.instancePrefix()
-	req := &btapb.CreateTableRequest{
-		Parent:        prefix,
-		TableId:       conf.TableID,
-		Table:         &tbl,
-		InitialSplits: reqSplits,
-	}
-	_, err := ac.tClient.CreateTable(ctx, req)
-	return err
-}
-
-// 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, ac.md)
-	prefix := ac.instancePrefix()
-	req := &btapb.ModifyColumnFamiliesRequest{
-		Name: prefix + "/tables/" + table,
-		Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-			Id:  family,
-			Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Create{Create: &btapb.ColumnFamily{}},
-		}},
-	}
-	_, err := ac.tClient.ModifyColumnFamilies(ctx, req)
-	return err
-}
-
-// DeleteTable deletes a table and all of its data.
-func (ac *AdminClient) DeleteTable(ctx context.Context, table string) error {
-	ctx = mergeOutgoingMetadata(ctx, ac.md)
-	prefix := ac.instancePrefix()
-	req := &btapb.DeleteTableRequest{
-		Name: prefix + "/tables/" + table,
-	}
-	_, err := ac.tClient.DeleteTable(ctx, req)
-	return err
-}
-
-// 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, ac.md)
-	prefix := ac.instancePrefix()
-	req := &btapb.ModifyColumnFamiliesRequest{
-		Name: prefix + "/tables/" + table,
-		Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-			Id:  family,
-			Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Drop{Drop: true},
-		}},
-	}
-	_, err := ac.tClient.ModifyColumnFamilies(ctx, req)
-	return err
-}
-
-// TableInfo represents information about a table.
-type TableInfo struct {
-	// DEPRECATED - This field is deprecated. Please use FamilyInfos instead.
-	Families    []string
-	FamilyInfos []FamilyInfo
-}
-
-// FamilyInfo represents information about a column family.
-type FamilyInfo struct {
-	Name     string
-	GCPolicy string
-}
-
-// TableInfo retrieves information about a table.
-func (ac *AdminClient) TableInfo(ctx context.Context, table string) (*TableInfo, error) {
-	ctx = mergeOutgoingMetadata(ctx, ac.md)
-	prefix := ac.instancePrefix()
-	req := &btapb.GetTableRequest{
-		Name: prefix + "/tables/" + table,
-	}
-
-	var res *btapb.Table
-
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		res, err = ac.tClient.GetTable(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-
-	ti := &TableInfo{}
-	for name, fam := range res.ColumnFamilies {
-		ti.Families = append(ti.Families, name)
-		ti.FamilyInfos = append(ti.FamilyInfos, FamilyInfo{Name: name, GCPolicy: GCRuleToString(fam.GcRule)})
-	}
-	return ti, nil
-}
-
-// SetGCPolicy specifies which cells in a column family should be garbage collected.
-// 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, ac.md)
-	prefix := ac.instancePrefix()
-	req := &btapb.ModifyColumnFamiliesRequest{
-		Name: prefix + "/tables/" + table,
-		Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-			Id:  family,
-			Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Update{Update: &btapb.ColumnFamily{GcRule: policy.proto()}},
-		}},
-	}
-	_, err := ac.tClient.ModifyColumnFamilies(ctx, req)
-	return err
-}
-
-// DropRowRange permanently deletes a row range from the specified table.
-func (ac *AdminClient) DropRowRange(ctx context.Context, table, rowKeyPrefix string) error {
-	ctx = mergeOutgoingMetadata(ctx, ac.md)
-	prefix := ac.instancePrefix()
-	req := &btapb.DropRowRangeRequest{
-		Name:   prefix + "/tables/" + table,
-		Target: &btapb.DropRowRangeRequest_RowKeyPrefix{RowKeyPrefix: []byte(rowKeyPrefix)},
-	}
-	_, 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.
-//
-// This is a private alpha release of Cloud Bigtable snapshots. This feature
-// is not currently available to most Cloud Bigtable customers. This feature
-// 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, ac.md)
-	prefix := ac.instancePrefix()
-	snapshotPath := prefix + "/clusters/" + cluster + "/snapshots/" + snapshot
-
-	req := &btapb.CreateTableFromSnapshotRequest{
-		Parent:         prefix,
-		TableId:        table,
-		SourceSnapshot: snapshotPath,
-	}
-	op, err := ac.tClient.CreateTableFromSnapshot(ctx, req)
-	if err != nil {
-		return err
-	}
-	resp := btapb.Table{}
-	return longrunning.InternalNewOperation(ac.lroClient, op).Wait(ctx, &resp)
-}
-
-// DefaultSnapshotDuration is the default TTL for a snapshot.
-const DefaultSnapshotDuration time.Duration = 0
-
-// SnapshotTable creates a new snapshot in the specified cluster from the
-// specified source table. Setting the TTL to `DefaultSnapshotDuration` will
-// use the server side default for the duration.
-//
-// This is a private alpha release of Cloud Bigtable snapshots. This feature
-// is not currently available to most Cloud Bigtable customers. This feature
-// 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, ac.md)
-	prefix := ac.instancePrefix()
-
-	var ttlProto *durpb.Duration
-
-	if ttl > 0 {
-		ttlProto = ptypes.DurationProto(ttl)
-	}
-
-	req := &btapb.SnapshotTableRequest{
-		Name:       prefix + "/tables/" + table,
-		Cluster:    prefix + "/clusters/" + cluster,
-		SnapshotId: snapshot,
-		Ttl:        ttlProto,
-	}
-
-	op, err := ac.tClient.SnapshotTable(ctx, req)
-	if err != nil {
-		return err
-	}
-	resp := btapb.Snapshot{}
-	return longrunning.InternalNewOperation(ac.lroClient, op).Wait(ctx, &resp)
-}
-
-// Snapshots returns a SnapshotIterator for iterating over the snapshots in a cluster.
-// To list snapshots across all of the clusters in the instance specify "-" as the cluster.
-//
-// This is a private alpha release of Cloud Bigtable snapshots. This feature is not
-// currently available to most Cloud Bigtable customers. This feature 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) Snapshots(ctx context.Context, cluster string) *SnapshotIterator {
-	ctx = mergeOutgoingMetadata(ctx, ac.md)
-	prefix := ac.instancePrefix()
-	clusterPath := prefix + "/clusters/" + cluster
-
-	it := &SnapshotIterator{}
-	req := &btapb.ListSnapshotsRequest{
-		Parent: clusterPath,
-	}
-
-	fetch := func(pageSize int, pageToken string) (string, error) {
-		req.PageToken = pageToken
-		if pageSize > math.MaxInt32 {
-			req.PageSize = math.MaxInt32
-		} else {
-			req.PageSize = int32(pageSize)
-		}
-
-		var resp *btapb.ListSnapshotsResponse
-		err := gax.Invoke(ctx, func(ctx context.Context) error {
-			var err error
-			resp, err = ac.tClient.ListSnapshots(ctx, req)
-			return err
-		}, retryOptions...)
-		if err != nil {
-			return "", err
-		}
-		for _, s := range resp.Snapshots {
-			snapshotInfo, err := newSnapshotInfo(s)
-			if err != nil {
-				return "", fmt.Errorf("failed to parse snapshot proto %v", err)
-			}
-			it.items = append(it.items, snapshotInfo)
-		}
-		return resp.NextPageToken, nil
-	}
-	bufLen := func() int { return len(it.items) }
-	takeBuf := func() interface{} { b := it.items; it.items = nil; return b }
-
-	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, bufLen, takeBuf)
-
-	return it
-}
-
-func newSnapshotInfo(snapshot *btapb.Snapshot) (*SnapshotInfo, error) {
-	nameParts := strings.Split(snapshot.Name, "/")
-	name := nameParts[len(nameParts)-1]
-	tablePathParts := strings.Split(snapshot.SourceTable.Name, "/")
-	tableID := tablePathParts[len(tablePathParts)-1]
-
-	createTime, err := ptypes.Timestamp(snapshot.CreateTime)
-	if err != nil {
-		return nil, fmt.Errorf("invalid createTime: %v", err)
-	}
-
-	deleteTime, err := ptypes.Timestamp(snapshot.DeleteTime)
-	if err != nil {
-		return nil, fmt.Errorf("invalid deleteTime: %v", err)
-	}
-
-	return &SnapshotInfo{
-		Name:        name,
-		SourceTable: tableID,
-		DataSize:    snapshot.DataSizeBytes,
-		CreateTime:  createTime,
-		DeleteTime:  deleteTime,
-	}, nil
-}
-
-// SnapshotIterator is an EntryIterator that iterates over log entries.
-//
-// This is a private alpha release of Cloud Bigtable snapshots. This feature
-// is not currently available to most Cloud Bigtable customers. This feature
-// might be changed in backward-incompatible ways and is not recommended for
-// production use. It is not subject to any SLA or deprecation policy.
-type SnapshotIterator struct {
-	items    []*SnapshotInfo
-	pageInfo *iterator.PageInfo
-	nextFunc func() error
-}
-
-// PageInfo supports pagination. See https://godoc.org/google.golang.org/api/iterator package for details.
-func (it *SnapshotIterator) PageInfo() *iterator.PageInfo {
-	return it.pageInfo
-}
-
-// Next returns the next result. Its second return value is iterator.Done
-// (https://godoc.org/google.golang.org/api/iterator) if there are no more
-// results. Once Next returns Done, all subsequent calls will return Done.
-func (it *SnapshotIterator) Next() (*SnapshotInfo, error) {
-	if err := it.nextFunc(); err != nil {
-		return nil, err
-	}
-	item := it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-// SnapshotInfo contains snapshot metadata.
-type SnapshotInfo struct {
-	Name        string
-	SourceTable string
-	DataSize    int64
-	CreateTime  time.Time
-	DeleteTime  time.Time
-}
-
-// SnapshotInfo gets snapshot metadata.
-//
-// This is a private alpha release of Cloud Bigtable snapshots. This feature
-// is not currently available to most Cloud Bigtable customers. This feature
-// 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, ac.md)
-	prefix := ac.instancePrefix()
-	clusterPath := prefix + "/clusters/" + cluster
-	snapshotPath := clusterPath + "/snapshots/" + snapshot
-
-	req := &btapb.GetSnapshotRequest{
-		Name: snapshotPath,
-	}
-
-	var resp *btapb.Snapshot
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		resp, err = ac.tClient.GetSnapshot(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-
-	return newSnapshotInfo(resp)
-}
-
-// DeleteSnapshot deletes a snapshot in a cluster.
-//
-// This is a private alpha release of Cloud Bigtable snapshots. This feature
-// is not currently available to most Cloud Bigtable customers. This feature
-// 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, ac.md)
-	prefix := ac.instancePrefix()
-	clusterPath := prefix + "/clusters/" + cluster
-	snapshotPath := clusterPath + "/snapshots/" + snapshot
-
-	req := &btapb.DeleteSnapshotRequest{
-		Name: snapshotPath,
-	}
-	_, err := ac.tClient.DeleteSnapshot(ctx, req)
-	return err
-}
-
-// getConsistencyToken gets the consistency token for a table.
-func (ac *AdminClient) getConsistencyToken(ctx context.Context, tableName string) (string, error) {
-	req := &btapb.GenerateConsistencyTokenRequest{
-		Name: tableName,
-	}
-	resp, err := ac.tClient.GenerateConsistencyToken(ctx, req)
-	if err != nil {
-		return "", err
-	}
-	return resp.GetConsistencyToken(), nil
-}
-
-// isConsistent checks if a token is consistent for a table.
-func (ac *AdminClient) isConsistent(ctx context.Context, tableName, token string) (bool, error) {
-	req := &btapb.CheckConsistencyRequest{
-		Name:             tableName,
-		ConsistencyToken: token,
-	}
-	var resp *btapb.CheckConsistencyResponse
-
-	// Retry calls on retryable errors to avoid losing the token gathered before.
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		resp, err = ac.tClient.CheckConsistency(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return false, err
-	}
-	return resp.GetConsistent(), nil
-}
-
-// 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 {
-	// Get the token.
-	prefix := ac.instancePrefix()
-	tableName := prefix + "/tables/" + table
-	token, err := ac.getConsistencyToken(ctx, tableName)
-	if err != nil {
-		return err
-	}
-
-	// Periodically check if the token is consistent.
-	timer := time.NewTicker(time.Second * 10)
-	defer timer.Stop()
-	for {
-		consistent, err := ac.isConsistent(ctx, tableName, token)
-		if err != nil {
-			return err
-		}
-		if consistent {
-			return nil
-		}
-		// Sleep for a bit or until the ctx is cancelled.
-		select {
-		case <-ctx.Done():
-			return ctx.Err()
-		case <-timer.C:
-		}
-	}
-}
-
-const instanceAdminAddr = "bigtableadmin.googleapis.com:443"
-
-// InstanceAdminClient is a client type for performing admin operations on instances.
-// These operations can be substantially more dangerous than those provided by AdminClient.
-type InstanceAdminClient struct {
-	conn      *grpc.ClientConn
-	iClient   btapb.BigtableInstanceAdminClient
-	lroClient *lroauto.OperationsClient
-
-	project string
-
-	// Metadata to be sent with each request.
-	md metadata.MD
-}
-
-// NewInstanceAdminClient creates a new InstanceAdminClient for a given project.
-func NewInstanceAdminClient(ctx context.Context, project string, opts ...option.ClientOption) (*InstanceAdminClient, error) {
-	o, err := btopt.DefaultClientOptions(instanceAdminAddr, InstanceAdminScope, clientUserAgent)
-	if err != nil {
-		return nil, err
-	}
-	o = append(o, opts...)
-	conn, err := gtransport.Dial(ctx, o...)
-	if err != nil {
-		return nil, fmt.Errorf("dialing: %v", err)
-	}
-
-	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 &InstanceAdminClient{
-		conn:      conn,
-		iClient:   btapb.NewBigtableInstanceAdminClient(conn),
-		lroClient: lroClient,
-
-		project: project,
-		md:      metadata.Pairs(resourcePrefixHeader, "projects/"+project),
-	}, nil
-}
-
-// Close closes the InstanceAdminClient.
-func (iac *InstanceAdminClient) Close() error {
-	return iac.conn.Close()
-}
-
-// StorageType is the type of storage used for all tables in an instance
-type StorageType int
-
-const (
-	SSD StorageType = iota
-	HDD
-)
-
-func (st StorageType) proto() btapb.StorageType {
-	if st == HDD {
-		return btapb.StorageType_HDD
-	}
-	return btapb.StorageType_SSD
-}
-
-// InstanceType is the type of the instance
-type InstanceType int32
-
-const (
-	PRODUCTION  InstanceType = InstanceType(btapb.Instance_PRODUCTION)
-	DEVELOPMENT              = InstanceType(btapb.Instance_DEVELOPMENT)
-)
-
-// InstanceInfo represents information about an instance
-type InstanceInfo struct {
-	Name        string // name of the instance
-	DisplayName string // display name for UIs
-}
-
-// InstanceConf contains the information necessary to create an Instance
-type InstanceConf struct {
-	InstanceId, DisplayName, ClusterId, Zone string
-	// NumNodes must not be specified for DEVELOPMENT instance types
-	NumNodes     int32
-	StorageType  StorageType
-	InstanceType InstanceType
-}
-
-// InstanceWithClustersConfig contains the information necessary to create an Instance
-type InstanceWithClustersConfig struct {
-	InstanceID, DisplayName string
-	Clusters                []ClusterConfig
-	InstanceType            InstanceType
-}
-
-var instanceNameRegexp = regexp.MustCompile(`^projects/([^/]+)/instances/([a-z][-a-z0-9]*)$`)
-
-// 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 {
-	newConfig := InstanceWithClustersConfig{
-		InstanceID:   conf.InstanceId,
-		DisplayName:  conf.DisplayName,
-		InstanceType: conf.InstanceType,
-		Clusters: []ClusterConfig{
-			{
-				InstanceID:  conf.InstanceId,
-				ClusterID:   conf.ClusterId,
-				Zone:        conf.Zone,
-				NumNodes:    conf.NumNodes,
-				StorageType: conf.StorageType,
-			},
-		},
-	}
-	return iac.CreateInstanceWithClusters(ctx, &newConfig)
-}
-
-// 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, iac.md)
-	clusters := make(map[string]*btapb.Cluster)
-	for _, cluster := range conf.Clusters {
-		clusters[cluster.ClusterID] = cluster.proto(iac.project)
-	}
-
-	req := &btapb.CreateInstanceRequest{
-		Parent:     "projects/" + iac.project,
-		InstanceId: conf.InstanceID,
-		Instance:   &btapb.Instance{DisplayName: conf.DisplayName, Type: btapb.Instance_Type(conf.InstanceType)},
-		Clusters:   clusters,
-	}
-
-	lro, err := iac.iClient.CreateInstance(ctx, req)
-	if err != nil {
-		return err
-	}
-	resp := btapb.Instance{}
-	return longrunning.InternalNewOperation(iac.lroClient, lro).Wait(ctx, &resp)
-}
-
-// DeleteInstance deletes an instance from the project.
-func (iac *InstanceAdminClient) DeleteInstance(ctx context.Context, instanceID string) error {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	req := &btapb.DeleteInstanceRequest{Name: "projects/" + iac.project + "/instances/" + instanceID}
-	_, err := iac.iClient.DeleteInstance(ctx, req)
-	return err
-}
-
-// Instances returns a list of instances in the project.
-func (iac *InstanceAdminClient) Instances(ctx context.Context) ([]*InstanceInfo, error) {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	req := &btapb.ListInstancesRequest{
-		Parent: "projects/" + iac.project,
-	}
-	var res *btapb.ListInstancesResponse
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		res, err = iac.iClient.ListInstances(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-	if len(res.FailedLocations) > 0 {
-		// We don't have a good way to return a partial result in the face of some zones being unavailable.
-		// Fail the entire request.
-		return nil, status.Errorf(codes.Unavailable, "Failed locations: %v", res.FailedLocations)
-	}
-
-	var is []*InstanceInfo
-	for _, i := range res.Instances {
-		m := instanceNameRegexp.FindStringSubmatch(i.Name)
-		if m == nil {
-			return nil, fmt.Errorf("malformed instance name %q", i.Name)
-		}
-		is = append(is, &InstanceInfo{
-			Name:        m[2],
-			DisplayName: i.DisplayName,
-		})
-	}
-	return is, nil
-}
-
-// InstanceInfo returns information about an instance.
-func (iac *InstanceAdminClient) InstanceInfo(ctx context.Context, instanceID string) (*InstanceInfo, error) {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	req := &btapb.GetInstanceRequest{
-		Name: "projects/" + iac.project + "/instances/" + instanceID,
-	}
-	var res *btapb.Instance
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		res, err = iac.iClient.GetInstance(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-
-	m := instanceNameRegexp.FindStringSubmatch(res.Name)
-	if m == nil {
-		return nil, fmt.Errorf("malformed instance name %q", res.Name)
-	}
-	return &InstanceInfo{
-		Name:        m[2],
-		DisplayName: res.DisplayName,
-	}, nil
-}
-
-// ClusterConfig contains the information necessary to create a cluster
-type ClusterConfig struct {
-	InstanceID, ClusterID, Zone string
-	NumNodes                    int32
-	StorageType                 StorageType
-}
-
-func (cc *ClusterConfig) proto(project string) *btapb.Cluster {
-	return &btapb.Cluster{
-		ServeNodes:         cc.NumNodes,
-		DefaultStorageType: cc.StorageType.proto(),
-		Location:           "projects/" + project + "/locations/" + cc.Zone,
-	}
-}
-
-// 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
-}
-
-// 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, iac.md)
-
-	req := &btapb.CreateClusterRequest{
-		Parent:    "projects/" + iac.project + "/instances/" + conf.InstanceID,
-		ClusterId: conf.ClusterID,
-		Cluster:   conf.proto(iac.project),
-	}
-
-	lro, err := iac.iClient.CreateCluster(ctx, req)
-	if err != nil {
-		return err
-	}
-	resp := btapb.Cluster{}
-	return longrunning.InternalNewOperation(iac.lroClient, lro).Wait(ctx, &resp)
-}
-
-// DeleteCluster deletes a cluster from an instance.
-func (iac *InstanceAdminClient) DeleteCluster(ctx context.Context, instanceID, clusterID string) error {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	req := &btapb.DeleteClusterRequest{Name: "projects/" + iac.project + "/instances/" + instanceID + "/clusters/" + clusterID}
-	_, err := iac.iClient.DeleteCluster(ctx, req)
-	return err
-}
-
-// UpdateCluster updates attributes of a cluster
-func (iac *InstanceAdminClient) UpdateCluster(ctx context.Context, instanceID, clusterID string, serveNodes int32) error {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	cluster := &btapb.Cluster{
-		Name:       "projects/" + iac.project + "/instances/" + instanceID + "/clusters/" + clusterID,
-		ServeNodes: serveNodes}
-	lro, err := iac.iClient.UpdateCluster(ctx, cluster)
-	if err != nil {
-		return err
-	}
-	return longrunning.InternalNewOperation(iac.lroClient, lro).Wait(ctx, nil)
-}
-
-// Clusters lists the clusters in an instance.
-func (iac *InstanceAdminClient) Clusters(ctx context.Context, instanceID string) ([]*ClusterInfo, error) {
-	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) error {
-		var err error
-		res, err = iac.iClient.ListClusters(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-	// TODO(garyelliott): Deal with failed_locations.
-	var cis []*ClusterInfo
-	for _, c := range res.Clusters {
-		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(),
-		})
-	}
-	return cis, nil
-}
-
-// GetCluster fetches a cluster in an instance
-func (iac *InstanceAdminClient) GetCluster(ctx context.Context, instanceID, clusterID string) (*ClusterInfo, error) {
-	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) error {
-		var err error
-		c, err = iac.iClient.GetCluster(ctx, req)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-
-	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(),
-	}
-	return cis, nil
-}
-
-// InstanceIAM returns the instance's IAM handle.
-func (iac *InstanceAdminClient) InstanceIAM(instanceID string) *iam.Handle {
-	return iam.InternalNewHandleGRPCClient(iac.iClient, "projects/"+iac.project+"/instances/"+instanceID)
-
-}
-
-// Routing policies.
-const (
-	// MultiClusterRouting is a policy that allows read/write requests to be
-	// routed to any cluster in the instance. Requests will will fail over to
-	// another cluster in the event of transient errors or delays. Choosing
-	// this option sacrifices read-your-writes consistency to improve
-	// availability.
-	MultiClusterRouting = "multi_cluster_routing_use_any"
-	// SingleClusterRouting is a policy that unconditionally routes all
-	// read/write requests to a specific cluster. This option preserves
-	// read-your-writes consistency, but does not improve availability.
-	SingleClusterRouting = "single_cluster_routing"
-)
-
-// ProfileConf contains the information necessary to create an profile
-type ProfileConf struct {
-	Name                     string
-	ProfileID                string
-	InstanceID               string
-	Etag                     string
-	Description              string
-	RoutingPolicy            string
-	ClusterID                string
-	AllowTransactionalWrites bool
-
-	// If true, warnings are ignored
-	IgnoreWarnings bool
-}
-
-// ProfileIterator iterates over profiles.
-type ProfileIterator struct {
-	items    []*btapb.AppProfile
-	pageInfo *iterator.PageInfo
-	nextFunc func() error
-}
-
-// ProfileAttrsToUpdate define addrs to update during an Update call. If unset, no fields will be replaced.
-type ProfileAttrsToUpdate struct {
-	// If set, updates the description.
-	Description optional.String
-
-	//If set, updates the routing policy.
-	RoutingPolicy optional.String
-
-	//If RoutingPolicy is updated to SingleClusterRouting, set these fields as well.
-	ClusterID                string
-	AllowTransactionalWrites bool
-
-	// If true, warnings are ignored
-	IgnoreWarnings bool
-}
-
-// GetFieldMaskPath returns the field mask path.
-func (p *ProfileAttrsToUpdate) GetFieldMaskPath() []string {
-	path := make([]string, 0)
-	if p.Description != nil {
-		path = append(path, "description")
-	}
-
-	if p.RoutingPolicy != nil {
-		path = append(path, optional.ToString(p.RoutingPolicy))
-	}
-	return path
-}
-
-// PageInfo supports pagination. See https://godoc.org/google.golang.org/api/iterator package for details.
-func (it *ProfileIterator) PageInfo() *iterator.PageInfo {
-	return it.pageInfo
-}
-
-// Next returns the next result. Its second return value is iterator.Done
-// (https://godoc.org/google.golang.org/api/iterator) if there are no more
-// results. Once Next returns Done, all subsequent calls will return Done.
-func (it *ProfileIterator) Next() (*btapb.AppProfile, error) {
-	if err := it.nextFunc(); err != nil {
-		return nil, err
-	}
-	item := it.items[0]
-	it.items = it.items[1:]
-	return item, nil
-}
-
-// CreateAppProfile creates an app profile within an instance.
-func (iac *InstanceAdminClient) CreateAppProfile(ctx context.Context, profile ProfileConf) (*btapb.AppProfile, error) {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	parent := "projects/" + iac.project + "/instances/" + profile.InstanceID
-	appProfile := &btapb.AppProfile{
-		Etag:        profile.Etag,
-		Description: profile.Description,
-	}
-
-	if profile.RoutingPolicy == "" {
-		return nil, errors.New("invalid routing policy")
-	}
-
-	switch profile.RoutingPolicy {
-	case MultiClusterRouting:
-		appProfile.RoutingPolicy = &btapb.AppProfile_MultiClusterRoutingUseAny_{
-			MultiClusterRoutingUseAny: &btapb.AppProfile_MultiClusterRoutingUseAny{},
-		}
-	case SingleClusterRouting:
-		appProfile.RoutingPolicy = &btapb.AppProfile_SingleClusterRouting_{
-			SingleClusterRouting: &btapb.AppProfile_SingleClusterRouting{
-				ClusterId:                profile.ClusterID,
-				AllowTransactionalWrites: profile.AllowTransactionalWrites,
-			},
-		}
-	default:
-		return nil, errors.New("invalid routing policy")
-	}
-
-	return iac.iClient.CreateAppProfile(ctx, &btapb.CreateAppProfileRequest{
-		Parent:         parent,
-		AppProfile:     appProfile,
-		AppProfileId:   profile.ProfileID,
-		IgnoreWarnings: profile.IgnoreWarnings,
-	})
-}
-
-// GetAppProfile gets information about an app profile.
-func (iac *InstanceAdminClient) GetAppProfile(ctx context.Context, instanceID, name string) (*btapb.AppProfile, error) {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	profileRequest := &btapb.GetAppProfileRequest{
-		Name: "projects/" + iac.project + "/instances/" + instanceID + "/appProfiles/" + name,
-	}
-	var ap *btapb.AppProfile
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		ap, err = iac.iClient.GetAppProfile(ctx, profileRequest)
-		return err
-	}, retryOptions...)
-	if err != nil {
-		return nil, err
-	}
-	return ap, err
-}
-
-// ListAppProfiles lists information about app profiles in an instance.
-func (iac *InstanceAdminClient) ListAppProfiles(ctx context.Context, instanceID string) *ProfileIterator {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	listRequest := &btapb.ListAppProfilesRequest{
-		Parent: "projects/" + iac.project + "/instances/" + instanceID,
-	}
-
-	pit := &ProfileIterator{}
-	fetch := func(pageSize int, pageToken string) (string, error) {
-		listRequest.PageToken = pageToken
-		var profileRes *btapb.ListAppProfilesResponse
-		err := gax.Invoke(ctx, func(ctx context.Context) error {
-			var err error
-			profileRes, err = iac.iClient.ListAppProfiles(ctx, listRequest)
-			return err
-		}, retryOptions...)
-		if err != nil {
-			return "", err
-		}
-
-		pit.items = append(pit.items, profileRes.AppProfiles...)
-		return profileRes.NextPageToken, nil
-	}
-
-	bufLen := func() int { return len(pit.items) }
-	takeBuf := func() interface{} { b := pit.items; pit.items = nil; return b }
-	pit.pageInfo, pit.nextFunc = iterator.NewPageInfo(fetch, bufLen, takeBuf)
-	return pit
-
-}
-
-// 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, iac.md)
-
-	profile := &btapb.AppProfile{
-		Name: "projects/" + iac.project + "/instances/" + instanceID + "/appProfiles/" + profileID,
-	}
-
-	if updateAttrs.Description != nil {
-		profile.Description = optional.ToString(updateAttrs.Description)
-	}
-	if updateAttrs.RoutingPolicy != nil {
-		switch optional.ToString(updateAttrs.RoutingPolicy) {
-		case MultiClusterRouting:
-			profile.RoutingPolicy = &btapb.AppProfile_MultiClusterRoutingUseAny_{
-				MultiClusterRoutingUseAny: &btapb.AppProfile_MultiClusterRoutingUseAny{},
-			}
-		case SingleClusterRouting:
-			profile.RoutingPolicy = &btapb.AppProfile_SingleClusterRouting_{
-				SingleClusterRouting: &btapb.AppProfile_SingleClusterRouting{
-					ClusterId:                updateAttrs.ClusterID,
-					AllowTransactionalWrites: updateAttrs.AllowTransactionalWrites,
-				},
-			}
-		default:
-			return errors.New("invalid routing policy")
-		}
-	}
-	patchRequest := &btapb.UpdateAppProfileRequest{
-		AppProfile: profile,
-		UpdateMask: &field_mask.FieldMask{
-			Paths: updateAttrs.GetFieldMaskPath(),
-		},
-		IgnoreWarnings: updateAttrs.IgnoreWarnings,
-	}
-	updateRequest, err := iac.iClient.UpdateAppProfile(ctx, patchRequest)
-	if err != nil {
-		return err
-	}
-
-	return longrunning.InternalNewOperation(iac.lroClient, updateRequest).Wait(ctx, nil)
-
-}
-
-// DeleteAppProfile deletes an app profile from an instance.
-func (iac *InstanceAdminClient) DeleteAppProfile(ctx context.Context, instanceID, name string) error {
-	ctx = mergeOutgoingMetadata(ctx, iac.md)
-	deleteProfileRequest := &btapb.DeleteAppProfileRequest{
-		Name:           "projects/" + iac.project + "/instances/" + instanceID + "/appProfiles/" + name,
-		IgnoreWarnings: true,
-	}
-	_, err := iac.iClient.DeleteAppProfile(ctx, deleteProfileRequest)
-	return err
-
-}

+ 0 - 578
vendor/cloud.google.com/go/bigtable/admin_test.go

@@ -1,578 +0,0 @@
-// Copyright 2015 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
-//
-//      http://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.
-
-package bigtable
-
-import (
-	"context"
-	"fmt"
-	"math"
-	"sort"
-	"strings"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/golang/protobuf/proto"
-	"google.golang.org/api/iterator"
-	btapb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
-)
-
-func TestAdminIntegration(t *testing.T) {
-	testEnv, err := NewIntegrationEnv()
-	if err != nil {
-		t.Fatalf("IntegrationEnv: %v", err)
-	}
-	defer testEnv.Close()
-
-	timeout := 2 * time.Second
-	if testEnv.Config().UseProd {
-		timeout = 5 * time.Minute
-	}
-	ctx, _ := context.WithTimeout(context.Background(), timeout)
-
-	adminClient, err := testEnv.NewAdminClient()
-	if err != nil {
-		t.Fatalf("NewAdminClient: %v", err)
-	}
-	defer adminClient.Close()
-
-	iAdminClient, err := testEnv.NewInstanceAdminClient()
-	if err != nil {
-		t.Fatalf("NewInstanceAdminClient: %v", err)
-	}
-	if iAdminClient != nil {
-		defer iAdminClient.Close()
-
-		iInfo, err := iAdminClient.InstanceInfo(ctx, adminClient.instance)
-		if err != nil {
-			t.Errorf("InstanceInfo: %v", err)
-		}
-		if iInfo.Name != adminClient.instance {
-			t.Errorf("InstanceInfo returned name %#v, want %#v", iInfo.Name, adminClient.instance)
-		}
-	}
-
-	list := func() []string {
-		tbls, err := adminClient.Tables(ctx)
-		if err != nil {
-			t.Fatalf("Fetching list of tables: %v", err)
-		}
-		sort.Strings(tbls)
-		return tbls
-	}
-	containsAll := func(got, want []string) bool {
-		gotSet := make(map[string]bool)
-
-		for _, s := range got {
-			gotSet[s] = true
-		}
-		for _, s := range want {
-			if !gotSet[s] {
-				return false
-			}
-		}
-		return true
-	}
-
-	defer adminClient.DeleteTable(ctx, "mytable")
-
-	if err := adminClient.CreateTable(ctx, "mytable"); err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	defer adminClient.DeleteTable(ctx, "myothertable")
-
-	if err := adminClient.CreateTable(ctx, "myothertable"); err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	if got, want := list(), []string{"myothertable", "mytable"}; !containsAll(got, want) {
-		t.Errorf("adminClient.Tables returned %#v, want %#v", got, want)
-	}
-
-	must(adminClient.WaitForReplication(ctx, "mytable"))
-
-	if err := adminClient.DeleteTable(ctx, "myothertable"); err != nil {
-		t.Fatalf("Deleting table: %v", err)
-	}
-	tables := list()
-	if got, want := tables, []string{"mytable"}; !containsAll(got, want) {
-		t.Errorf("adminClient.Tables returned %#v, want %#v", got, want)
-	}
-	if got, unwanted := tables, []string{"myothertable"}; containsAll(got, unwanted) {
-		t.Errorf("adminClient.Tables return %#v. unwanted %#v", got, unwanted)
-	}
-
-	tblConf := TableConf{
-		TableID: "conftable",
-		Families: map[string]GCPolicy{
-			"fam1": MaxVersionsPolicy(1),
-			"fam2": MaxVersionsPolicy(2),
-		},
-	}
-	if err := adminClient.CreateTableFromConf(ctx, &tblConf); err != nil {
-		t.Fatalf("Creating table from TableConf: %v", err)
-	}
-	defer adminClient.DeleteTable(ctx, tblConf.TableID)
-
-	tblInfo, err := adminClient.TableInfo(ctx, tblConf.TableID)
-	if err != nil {
-		t.Fatalf("Getting table info: %v", err)
-	}
-	sort.Strings(tblInfo.Families)
-	wantFams := []string{"fam1", "fam2"}
-	if !testutil.Equal(tblInfo.Families, wantFams) {
-		t.Errorf("Column family mismatch, got %v, want %v", tblInfo.Families, wantFams)
-	}
-
-	// Populate mytable and drop row ranges
-	if err = adminClient.CreateColumnFamily(ctx, "mytable", "cf"); err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-
-	client, err := testEnv.NewClient()
-	if err != nil {
-		t.Fatalf("NewClient: %v", err)
-	}
-	defer client.Close()
-
-	tbl := client.Open("mytable")
-
-	prefixes := []string{"a", "b", "c"}
-	for _, prefix := range prefixes {
-		for i := 0; i < 5; i++ {
-			mut := NewMutation()
-			mut.Set("cf", "col", 1000, []byte("1"))
-			if err := tbl.Apply(ctx, fmt.Sprintf("%v-%v", prefix, i), mut); err != nil {
-				t.Fatalf("Mutating row: %v", err)
-			}
-		}
-	}
-
-	if err = adminClient.DropRowRange(ctx, "mytable", "a"); err != nil {
-		t.Errorf("DropRowRange a: %v", err)
-	}
-	if err = adminClient.DropRowRange(ctx, "mytable", "c"); err != nil {
-		t.Errorf("DropRowRange c: %v", err)
-	}
-	if err = adminClient.DropRowRange(ctx, "mytable", "x"); err != nil {
-		t.Errorf("DropRowRange x: %v", err)
-	}
-
-	var gotRowCount int
-	must(tbl.ReadRows(ctx, RowRange{}, func(row Row) bool {
-		gotRowCount++
-		if !strings.HasPrefix(row.Key(), "b") {
-			t.Errorf("Invalid row after dropping range: %v", row)
-		}
-		return true
-	}))
-	if gotRowCount != 5 {
-		t.Errorf("Invalid row count after dropping range: got %v, want %v", gotRowCount, 5)
-	}
-}
-
-func TestInstanceUpdate(t *testing.T) {
-	testEnv, err := NewIntegrationEnv()
-	if err != nil {
-		t.Fatalf("IntegrationEnv: %v", err)
-	}
-	defer testEnv.Close()
-
-	timeout := 2 * time.Second
-	if testEnv.Config().UseProd {
-		timeout = 5 * time.Minute
-	}
-	ctx, cancel := context.WithTimeout(context.Background(), timeout)
-	defer cancel()
-
-	adminClient, err := testEnv.NewAdminClient()
-	if err != nil {
-		t.Fatalf("NewAdminClient: %v", err)
-	}
-
-	defer adminClient.Close()
-
-	iAdminClient, err := testEnv.NewInstanceAdminClient()
-	if err != nil {
-		t.Fatalf("NewInstanceAdminClient: %v", err)
-	}
-
-	if iAdminClient == nil {
-		return
-	}
-
-	defer iAdminClient.Close()
-
-	iInfo, err := iAdminClient.InstanceInfo(ctx, adminClient.instance)
-	if err != nil {
-		t.Errorf("InstanceInfo: %v", err)
-	}
-
-	if iInfo.Name != adminClient.instance {
-		t.Errorf("InstanceInfo returned name %#v, want %#v", iInfo.Name, adminClient.instance)
-	}
-
-	if iInfo.DisplayName != adminClient.instance {
-		t.Errorf("InstanceInfo returned name %#v, want %#v", iInfo.Name, adminClient.instance)
-	}
-
-	const numNodes = 4
-	// update cluster nodes
-	if err := iAdminClient.UpdateCluster(ctx, adminClient.instance, testEnv.Config().Cluster, int32(numNodes)); err != nil {
-		t.Errorf("UpdateCluster: %v", err)
-	}
-
-	// get cluster after updating
-	cis, err := iAdminClient.GetCluster(ctx, adminClient.instance, testEnv.Config().Cluster)
-	if err != nil {
-		t.Errorf("GetCluster %v", err)
-	}
-	if cis.ServeNodes != int(numNodes) {
-		t.Errorf("ServeNodes returned %d, want %d", cis.ServeNodes, int(numNodes))
-	}
-}
-
-func TestAdminSnapshotIntegration(t *testing.T) {
-	testEnv, err := NewIntegrationEnv()
-	if err != nil {
-		t.Fatalf("IntegrationEnv: %v", err)
-	}
-	defer testEnv.Close()
-
-	if !testEnv.Config().UseProd {
-		t.Skip("emulator doesn't support snapshots")
-	}
-
-	timeout := 2 * time.Second
-	if testEnv.Config().UseProd {
-		timeout = 5 * time.Minute
-	}
-	ctx, _ := context.WithTimeout(context.Background(), timeout)
-
-	adminClient, err := testEnv.NewAdminClient()
-	if err != nil {
-		t.Fatalf("NewAdminClient: %v", err)
-	}
-	defer adminClient.Close()
-
-	table := testEnv.Config().Table
-	cluster := testEnv.Config().Cluster
-
-	list := func(cluster string) ([]*SnapshotInfo, error) {
-		infos := []*SnapshotInfo(nil)
-
-		it := adminClient.Snapshots(ctx, cluster)
-		for {
-			s, err := it.Next()
-			if err == iterator.Done {
-				break
-			}
-			if err != nil {
-				return nil, err
-			}
-			infos = append(infos, s)
-		}
-		return infos, err
-	}
-
-	// Delete the table at the end of the test. Schedule ahead of time
-	// in case the client fails
-	defer adminClient.DeleteTable(ctx, table)
-
-	if err := adminClient.CreateTable(ctx, table); err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	// Precondition: no snapshots
-	snapshots, err := list(cluster)
-	if err != nil {
-		t.Fatalf("Initial snapshot list: %v", err)
-	}
-	if got, want := len(snapshots), 0; got != want {
-		t.Fatalf("Initial snapshot list len: %d, want: %d", got, want)
-	}
-
-	// Create snapshot
-	defer adminClient.DeleteSnapshot(ctx, cluster, "mysnapshot")
-
-	if err = adminClient.SnapshotTable(ctx, table, cluster, "mysnapshot", 5*time.Hour); err != nil {
-		t.Fatalf("Creating snaphot: %v", err)
-	}
-
-	// List snapshot
-	snapshots, err = list(cluster)
-	if err != nil {
-		t.Fatalf("Listing snapshots: %v", err)
-	}
-	if got, want := len(snapshots), 1; got != want {
-		t.Fatalf("Listing snapshot count: %d, want: %d", got, want)
-	}
-	if got, want := snapshots[0].Name, "mysnapshot"; got != want {
-		t.Fatalf("Snapshot name: %s, want: %s", got, want)
-	}
-	if got, want := snapshots[0].SourceTable, table; got != want {
-		t.Fatalf("Snapshot SourceTable: %s, want: %s", got, want)
-	}
-	if got, want := snapshots[0].DeleteTime, snapshots[0].CreateTime.Add(5*time.Hour); math.Abs(got.Sub(want).Minutes()) > 1 {
-		t.Fatalf("Snapshot DeleteTime: %s, want: %s", got, want)
-	}
-
-	// Get snapshot
-	snapshot, err := adminClient.SnapshotInfo(ctx, cluster, "mysnapshot")
-	if err != nil {
-		t.Fatalf("SnapshotInfo: %v", snapshot)
-	}
-	if got, want := *snapshot, *snapshots[0]; got != want {
-		t.Fatalf("SnapshotInfo: %v, want: %v", got, want)
-	}
-
-	// Restore
-	restoredTable := table + "-restored"
-	defer adminClient.DeleteTable(ctx, restoredTable)
-	if err = adminClient.CreateTableFromSnapshot(ctx, restoredTable, cluster, "mysnapshot"); err != nil {
-		t.Fatalf("CreateTableFromSnapshot: %v", err)
-	}
-	if _, err := adminClient.TableInfo(ctx, restoredTable); err != nil {
-		t.Fatalf("Restored TableInfo: %v", err)
-	}
-
-	// Delete snapshot
-	if err = adminClient.DeleteSnapshot(ctx, cluster, "mysnapshot"); err != nil {
-		t.Fatalf("DeleteSnapshot: %v", err)
-	}
-	snapshots, err = list(cluster)
-	if err != nil {
-		t.Fatalf("List after Delete: %v", err)
-	}
-	if got, want := len(snapshots), 0; got != want {
-		t.Fatalf("List after delete len: %d, want: %d", got, want)
-	}
-}
-
-func TestGranularity(t *testing.T) {
-	testEnv, err := NewIntegrationEnv()
-	if err != nil {
-		t.Fatalf("IntegrationEnv: %v", err)
-	}
-	defer testEnv.Close()
-
-	timeout := 2 * time.Second
-	if testEnv.Config().UseProd {
-		timeout = 5 * time.Minute
-	}
-	ctx, _ := context.WithTimeout(context.Background(), timeout)
-
-	adminClient, err := testEnv.NewAdminClient()
-	if err != nil {
-		t.Fatalf("NewAdminClient: %v", err)
-	}
-	defer adminClient.Close()
-
-	list := func() []string {
-		tbls, err := adminClient.Tables(ctx)
-		if err != nil {
-			t.Fatalf("Fetching list of tables: %v", err)
-		}
-		sort.Strings(tbls)
-		return tbls
-	}
-	containsAll := func(got, want []string) bool {
-		gotSet := make(map[string]bool)
-
-		for _, s := range got {
-			gotSet[s] = true
-		}
-		for _, s := range want {
-			if !gotSet[s] {
-				return false
-			}
-		}
-		return true
-	}
-
-	defer adminClient.DeleteTable(ctx, "mytable")
-
-	if err := adminClient.CreateTable(ctx, "mytable"); err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	tables := list()
-	if got, want := tables, []string{"mytable"}; !containsAll(got, want) {
-		t.Errorf("adminClient.Tables returned %#v, want %#v", got, want)
-	}
-
-	// calling ModifyColumnFamilies to check the granularity of table
-	prefix := adminClient.instancePrefix()
-	req := &btapb.ModifyColumnFamiliesRequest{
-		Name: prefix + "/tables/" + "mytable",
-		Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-			Id:  "cf",
-			Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Create{&btapb.ColumnFamily{}},
-		}},
-	}
-	table, err := adminClient.tClient.ModifyColumnFamilies(ctx, req)
-	if err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-	if table.Granularity != btapb.Table_TimestampGranularity(btapb.Table_MILLIS) {
-		t.Errorf("ModifyColumnFamilies returned granularity %#v, want %#v", table.Granularity, btapb.Table_TimestampGranularity(btapb.Table_MILLIS))
-	}
-}
-
-func TestInstanceAdminClient_AppProfile(t *testing.T) {
-	testEnv, err := NewIntegrationEnv()
-	if err != nil {
-		t.Fatalf("IntegrationEnv: %v", err)
-	}
-	defer testEnv.Close()
-
-	timeout := 2 * time.Second
-	if testEnv.Config().UseProd {
-		timeout = 5 * time.Minute
-	}
-	ctx, cancel := context.WithTimeout(context.Background(), timeout)
-	defer cancel()
-
-	adminClient, err := testEnv.NewAdminClient()
-	if err != nil {
-		t.Fatalf("NewAdminClient: %v", err)
-	}
-	defer adminClient.Close()
-
-	iAdminClient, err := testEnv.NewInstanceAdminClient()
-	if err != nil {
-		t.Fatalf("NewInstanceAdminClient: %v", err)
-	}
-
-	if iAdminClient == nil {
-		return
-	}
-
-	defer iAdminClient.Close()
-	profile := ProfileConf{
-		ProfileID:     "app_profile1",
-		InstanceID:    adminClient.instance,
-		ClusterID:     testEnv.Config().Cluster,
-		Description:   "creating new app profile 1",
-		RoutingPolicy: SingleClusterRouting,
-	}
-
-	createdProfile, err := iAdminClient.CreateAppProfile(ctx, profile)
-	if err != nil {
-		t.Fatalf("Creating app profile: %v", err)
-
-	}
-
-	gotProfile, err := iAdminClient.GetAppProfile(ctx, adminClient.instance, "app_profile1")
-
-	if err != nil {
-		t.Fatalf("Get app profile: %v", err)
-	}
-
-	if !proto.Equal(createdProfile, gotProfile) {
-		t.Fatalf("created profile: %s, got profile: %s", createdProfile.Name, gotProfile.Name)
-
-	}
-
-	list := func(instanceID string) ([]*btapb.AppProfile, error) {
-		profiles := []*btapb.AppProfile(nil)
-
-		it := iAdminClient.ListAppProfiles(ctx, instanceID)
-		for {
-			s, err := it.Next()
-			if err == iterator.Done {
-				break
-			}
-			if err != nil {
-				return nil, err
-			}
-			profiles = append(profiles, s)
-		}
-		return profiles, err
-	}
-
-	profiles, err := list(adminClient.instance)
-	if err != nil {
-		t.Fatalf("List app profile: %v", err)
-	}
-
-	if got, want := len(profiles), 1; got != want {
-		t.Fatalf("Initial app profile list len: %d, want: %d", got, want)
-	}
-
-	for _, test := range []struct {
-		desc   string
-		uattrs ProfileAttrsToUpdate
-		want   *btapb.AppProfile // nil means error
-	}{
-		{
-			desc:   "empty update",
-			uattrs: ProfileAttrsToUpdate{},
-			want:   nil,
-		},
-
-		{
-			desc:   "empty description update",
-			uattrs: ProfileAttrsToUpdate{Description: ""},
-			want: &btapb.AppProfile{
-				Name:          gotProfile.Name,
-				Description:   "",
-				RoutingPolicy: gotProfile.RoutingPolicy,
-				Etag:          gotProfile.Etag},
-		},
-		{
-			desc: "routing update",
-			uattrs: ProfileAttrsToUpdate{
-				RoutingPolicy: SingleClusterRouting,
-				ClusterID:     testEnv.Config().Cluster,
-			},
-			want: &btapb.AppProfile{
-				Name:        gotProfile.Name,
-				Description: "",
-				Etag:        gotProfile.Etag,
-				RoutingPolicy: &btapb.AppProfile_SingleClusterRouting_{
-					SingleClusterRouting: &btapb.AppProfile_SingleClusterRouting{
-						ClusterId: testEnv.Config().Cluster,
-					}},
-			},
-		},
-	} {
-		err = iAdminClient.UpdateAppProfile(ctx, adminClient.instance, "app_profile1", test.uattrs)
-		if err != nil {
-			if test.want != nil {
-				t.Errorf("%s: %v", test.desc, err)
-			}
-			continue
-		}
-		if err == nil && test.want == nil {
-			t.Errorf("%s: got nil, want error", test.desc)
-			continue
-		}
-
-		got, _ := iAdminClient.GetAppProfile(ctx, adminClient.instance, "app_profile1")
-
-		if !proto.Equal(got, test.want) {
-			t.Fatalf("%s : got profile : %v, want profile: %v", test.desc, gotProfile, test.want)
-		}
-
-	}
-
-	err = iAdminClient.DeleteAppProfile(ctx, adminClient.instance, "app_profile1")
-	if err != nil {
-		t.Fatalf("Delete app profile: %v", err)
-	}
-
-}

+ 0 - 914
vendor/cloud.google.com/go/bigtable/bigtable.go

@@ -1,914 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package bigtable // import "cloud.google.com/go/bigtable"
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"io"
-	"strconv"
-	"time"
-
-	"cloud.google.com/go/bigtable/internal/gax"
-	btopt "cloud.google.com/go/bigtable/internal/option"
-	"github.com/golang/protobuf/proto"
-	"google.golang.org/api/option"
-	gtransport "google.golang.org/api/transport/grpc"
-	btpb "google.golang.org/genproto/googleapis/bigtable/v2"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/metadata"
-	"google.golang.org/grpc/status"
-)
-
-const prodAddr = "bigtable.googleapis.com:443"
-
-// Client is a client for reading and writing data to tables in an instance.
-//
-// A Client is safe to use concurrently, except for its Close method.
-type Client struct {
-	conn              *grpc.ClientConn
-	client            btpb.BigtableClient
-	project, instance string
-	appProfile        string
-}
-
-// ClientConfig has configurations for the client.
-type ClientConfig struct {
-	// The id of the app profile to associate with all data operations sent from this client.
-	// If unspecified, the default app profile for the instance will be used.
-	AppProfile string
-}
-
-// NewClient creates a new Client for a given project and instance.
-// The default ClientConfig will be used.
-func NewClient(ctx context.Context, project, instance string, opts ...option.ClientOption) (*Client, error) {
-	return NewClientWithConfig(ctx, project, instance, ClientConfig{}, opts...)
-}
-
-// NewClientWithConfig creates a new client with the given config.
-func NewClientWithConfig(ctx context.Context, project, instance string, config ClientConfig, opts ...option.ClientOption) (*Client, error) {
-	o, err := btopt.DefaultClientOptions(prodAddr, Scope, clientUserAgent)
-	if err != nil {
-		return nil, err
-	}
-	// Default to a small connection pool that can be overridden.
-	o = append(o,
-		option.WithGRPCConnectionPool(4),
-		// Set the max size to correspond to server-side limits.
-		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(1<<28), grpc.MaxCallRecvMsgSize(1<<28))),
-		// TODO(grpc/grpc-go#1388) using connection pool without WithBlock
-		// can cause RPCs to fail randomly. We can delete this after the issue is fixed.
-		option.WithGRPCDialOption(grpc.WithBlock()))
-	o = append(o, opts...)
-	conn, err := gtransport.Dial(ctx, o...)
-	if err != nil {
-		return nil, fmt.Errorf("dialing: %v", err)
-	}
-
-	return &Client{
-		conn:       conn,
-		client:     btpb.NewBigtableClient(conn),
-		project:    project,
-		instance:   instance,
-		appProfile: config.AppProfile,
-	}, nil
-}
-
-// Close closes the Client.
-func (c *Client) Close() error {
-	return c.conn.Close()
-}
-
-var (
-	idempotentRetryCodes  = []codes.Code{codes.DeadlineExceeded, codes.Unavailable, codes.Aborted}
-	isIdempotentRetryCode = make(map[codes.Code]bool)
-	retryOptions          = []gax.CallOption{
-		gax.WithDelayTimeoutSettings(100*time.Millisecond, 2000*time.Millisecond, 1.2),
-		gax.WithRetryCodes(idempotentRetryCodes),
-	}
-)
-
-func init() {
-	for _, code := range idempotentRetryCodes {
-		isIdempotentRetryCode[code] = true
-	}
-}
-
-func (c *Client) fullTableName(table string) string {
-	return fmt.Sprintf("projects/%s/instances/%s/tables/%s", c.project, c.instance, table)
-}
-
-// A Table refers to a table.
-//
-// A Table is safe to use concurrently.
-type Table struct {
-	c     *Client
-	table string
-
-	// Metadata to be sent with each request.
-	md metadata.MD
-}
-
-// Open opens a table.
-func (c *Client) Open(table string) *Table {
-	return &Table{
-		c:     c,
-		table: table,
-		md:    metadata.Pairs(resourcePrefixHeader, c.fullTableName(table)),
-	}
-}
-
-// TODO(dsymonds): Read method that returns a sequence of ReadItems.
-
-// ReadRows reads rows from a table. f is called for each row.
-// If f returns false, the stream is shut down and ReadRows returns.
-// f owns its argument, and f is called serially in order by row key.
-//
-// 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) error {
-	ctx = mergeOutgoingMetadata(ctx, t.md)
-
-	var prevRowKey string
-	var err error
-	ctx = traceStartSpan(ctx, "cloud.google.com/go/bigtable.ReadRows")
-	defer func() { traceEndSpan(ctx, err) }()
-	attrMap := make(map[string]interface{})
-	err = gax.Invoke(ctx, func(ctx context.Context) error {
-		if !arg.valid() {
-			// Empty row set, no need to make an API call.
-			// NOTE: we must return early if arg == RowList{} because reading
-			// an empty RowList from bigtable returns all rows from that table.
-			return nil
-		}
-		req := &btpb.ReadRowsRequest{
-			TableName:    t.c.fullTableName(t.table),
-			AppProfileId: t.c.appProfile,
-			Rows:         arg.proto(),
-		}
-		for _, opt := range opts {
-			opt.set(req)
-		}
-		ctx, cancel := context.WithCancel(ctx) // for aborting the stream
-		defer cancel()
-
-		startTime := time.Now()
-		stream, err := t.c.client.ReadRows(ctx, req)
-		if err != nil {
-			return err
-		}
-		cr := newChunkReader()
-		for {
-			res, err := stream.Recv()
-			if err == io.EOF {
-				break
-			}
-			if err != nil {
-				// Reset arg for next Invoke call.
-				arg = arg.retainRowsAfter(prevRowKey)
-				attrMap["rowKey"] = prevRowKey
-				attrMap["error"] = err.Error()
-				attrMap["time_secs"] = time.Since(startTime).Seconds()
-				tracePrintf(ctx, attrMap, "Retry details in ReadRows")
-				return err
-			}
-			attrMap["time_secs"] = time.Since(startTime).Seconds()
-			attrMap["rowCount"] = len(res.Chunks)
-			tracePrintf(ctx, attrMap, "Details in ReadRows")
-
-			for _, cc := range res.Chunks {
-				row, err := cr.Process(cc)
-				if err != nil {
-					// No need to prepare for a retry, this is an unretryable error.
-					return err
-				}
-				if row == nil {
-					continue
-				}
-				prevRowKey = row.Key()
-				if !f(row) {
-					// Cancel and drain stream.
-					cancel()
-					for {
-						if _, err := stream.Recv(); err != nil {
-							// The stream has ended. We don't return an error
-							// because the caller has intentionally interrupted the scan.
-							return nil
-						}
-					}
-				}
-			}
-			if err := cr.Close(); err != nil {
-				// No need to prepare for a retry, this is an unretryable error.
-				return err
-			}
-		}
-		return err
-	}, retryOptions...)
-
-	return err
-}
-
-// ReadRow is a convenience implementation of a single-row reader.
-// A missing row will return a zero-length map and a nil error.
-func (t *Table) ReadRow(ctx context.Context, row string, opts ...ReadOption) (Row, error) {
-	var r Row
-	err := t.ReadRows(ctx, SingleRow(row), func(rr Row) bool {
-		r = rr
-		return true
-	}, opts...)
-	return r, err
-}
-
-// decodeFamilyProto adds the cell data from f to the given row.
-func decodeFamilyProto(r Row, row string, f *btpb.Family) {
-	fam := f.Name // does not have colon
-	for _, col := range f.Columns {
-		for _, cell := range col.Cells {
-			ri := ReadItem{
-				Row:       row,
-				Column:    fam + ":" + string(col.Qualifier),
-				Timestamp: Timestamp(cell.TimestampMicros),
-				Value:     cell.Value,
-			}
-			r[fam] = append(r[fam], ri)
-		}
-	}
-}
-
-// RowSet is a set of rows to be read. It is satisfied by RowList, RowRange and RowRangeList.
-// The serialized size of the RowSet must be no larger than 1MiB.
-type RowSet interface {
-	proto() *btpb.RowSet
-
-	// retainRowsAfter returns a new RowSet that does not include the
-	// given row key or any row key lexicographically less than it.
-	retainRowsAfter(lastRowKey string) RowSet
-
-	// Valid reports whether this set can cover at least one row.
-	valid() bool
-}
-
-// RowList is a sequence of row keys.
-type RowList []string
-
-func (r RowList) proto() *btpb.RowSet {
-	keys := make([][]byte, len(r))
-	for i, row := range r {
-		keys[i] = []byte(row)
-	}
-	return &btpb.RowSet{RowKeys: keys}
-}
-
-func (r RowList) retainRowsAfter(lastRowKey string) RowSet {
-	var retryKeys RowList
-	for _, key := range r {
-		if key > lastRowKey {
-			retryKeys = append(retryKeys, key)
-		}
-	}
-	return retryKeys
-}
-
-func (r RowList) valid() bool {
-	return len(r) > 0
-}
-
-// A RowRange is a half-open interval [Start, Limit) encompassing
-// all the rows with keys at least as large as Start, and less than Limit.
-// (Bigtable string comparison is the same as Go's.)
-// A RowRange can be unbounded, encompassing all keys at least as large as Start.
-type RowRange struct {
-	start string
-	limit string
-}
-
-// NewRange returns the new RowRange [begin, end).
-func NewRange(begin, end string) RowRange {
-	return RowRange{
-		start: begin,
-		limit: end,
-	}
-}
-
-// Unbounded tests whether a RowRange is unbounded.
-func (r RowRange) Unbounded() bool {
-	return r.limit == ""
-}
-
-// Contains says whether the RowRange contains the key.
-func (r RowRange) Contains(row string) bool {
-	return r.start <= row && (r.limit == "" || r.limit > row)
-}
-
-// String provides a printable description of a RowRange.
-func (r RowRange) String() string {
-	a := strconv.Quote(r.start)
-	if r.Unbounded() {
-		return fmt.Sprintf("[%s,∞)", a)
-	}
-	return fmt.Sprintf("[%s,%q)", a, r.limit)
-}
-
-func (r RowRange) proto() *btpb.RowSet {
-	rr := &btpb.RowRange{
-		StartKey: &btpb.RowRange_StartKeyClosed{StartKeyClosed: []byte(r.start)},
-	}
-	if !r.Unbounded() {
-		rr.EndKey = &btpb.RowRange_EndKeyOpen{EndKeyOpen: []byte(r.limit)}
-	}
-	return &btpb.RowSet{RowRanges: []*btpb.RowRange{rr}}
-}
-
-func (r RowRange) retainRowsAfter(lastRowKey string) RowSet {
-	if lastRowKey == "" || lastRowKey < r.start {
-		return r
-	}
-	// Set the beginning of the range to the row after the last scanned.
-	start := lastRowKey + "\x00"
-	if r.Unbounded() {
-		return InfiniteRange(start)
-	}
-	return NewRange(start, r.limit)
-}
-
-func (r RowRange) valid() bool {
-	return r.Unbounded() || r.start < r.limit
-}
-
-// RowRangeList is a sequence of RowRanges representing the union of the ranges.
-type RowRangeList []RowRange
-
-func (r RowRangeList) proto() *btpb.RowSet {
-	ranges := make([]*btpb.RowRange, len(r))
-	for i, rr := range r {
-		// RowRange.proto() returns a RowSet with a single element RowRange array
-		ranges[i] = rr.proto().RowRanges[0]
-	}
-	return &btpb.RowSet{RowRanges: ranges}
-}
-
-func (r RowRangeList) retainRowsAfter(lastRowKey string) RowSet {
-	if lastRowKey == "" {
-		return r
-	}
-	// Return a list of any range that has not yet been completely processed
-	var ranges RowRangeList
-	for _, rr := range r {
-		retained := rr.retainRowsAfter(lastRowKey)
-		if retained.valid() {
-			ranges = append(ranges, retained.(RowRange))
-		}
-	}
-	return ranges
-}
-
-func (r RowRangeList) valid() bool {
-	for _, rr := range r {
-		if rr.valid() {
-			return true
-		}
-	}
-	return false
-}
-
-// SingleRow returns a RowSet for reading a single row.
-func SingleRow(row string) RowSet {
-	return RowList{row}
-}
-
-// PrefixRange returns a RowRange consisting of all keys starting with the prefix.
-func PrefixRange(prefix string) RowRange {
-	return RowRange{
-		start: prefix,
-		limit: prefixSuccessor(prefix),
-	}
-}
-
-// InfiniteRange returns the RowRange consisting of all keys at least as
-// large as start.
-func InfiniteRange(start string) RowRange {
-	return RowRange{
-		start: start,
-		limit: "",
-	}
-}
-
-// prefixSuccessor returns the lexically smallest string greater than the
-// prefix, if it exists, or "" otherwise.  In either case, it is the string
-// needed for the Limit of a RowRange.
-func prefixSuccessor(prefix string) string {
-	if prefix == "" {
-		return "" // infinite range
-	}
-	n := len(prefix)
-	for n--; n >= 0 && prefix[n] == '\xff'; n-- {
-	}
-	if n == -1 {
-		return ""
-	}
-	ans := []byte(prefix[:n])
-	ans = append(ans, prefix[n]+1)
-	return string(ans)
-}
-
-// A ReadOption is an optional argument to ReadRows.
-type ReadOption interface {
-	set(req *btpb.ReadRowsRequest)
-}
-
-// RowFilter returns a ReadOption that applies f to the contents of read rows.
-//
-// If multiple RowFilters are provided, only the last is used. To combine filters,
-// use ChainFilters or InterleaveFilters instead.
-func RowFilter(f Filter) ReadOption { return rowFilter{f} }
-
-type rowFilter struct{ f Filter }
-
-func (rf rowFilter) set(req *btpb.ReadRowsRequest) { req.Filter = rf.f.proto() }
-
-// LimitRows returns a ReadOption that will limit the number of rows to be read.
-func LimitRows(limit int64) ReadOption { return limitRows{limit} }
-
-type limitRows struct{ limit int64 }
-
-func (lr limitRows) set(req *btpb.ReadRowsRequest) { req.RowsLimit = lr.limit }
-
-// mutationsAreRetryable returns true if all mutations are idempotent
-// and therefore retryable. A mutation is idempotent iff all cell timestamps
-// have an explicit timestamp set and do not rely on the timestamp being set on the server.
-func mutationsAreRetryable(muts []*btpb.Mutation) bool {
-	serverTime := int64(ServerTime)
-	for _, mut := range muts {
-		setCell := mut.GetSetCell()
-		if setCell != nil && setCell.TimestampMicros == serverTime {
-			return false
-		}
-	}
-	return true
-}
-
-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) error {
-	ctx = mergeOutgoingMetadata(ctx, t.md)
-	after := func(res proto.Message) {
-		for _, o := range opts {
-			o.after(res)
-		}
-	}
-
-	var err error
-	ctx = traceStartSpan(ctx, "cloud.google.com/go/bigtable/Apply")
-	defer func() { traceEndSpan(ctx, err) }()
-	var callOptions []gax.CallOption
-	if m.cond == nil {
-		req := &btpb.MutateRowRequest{
-			TableName:    t.c.fullTableName(t.table),
-			AppProfileId: t.c.appProfile,
-			RowKey:       []byte(row),
-			Mutations:    m.ops,
-		}
-		if mutationsAreRetryable(m.ops) {
-			callOptions = retryOptions
-		}
-		var res *btpb.MutateRowResponse
-		err := gax.Invoke(ctx, func(ctx context.Context) error {
-			var err error
-			res, err = t.c.client.MutateRow(ctx, req)
-			return err
-		}, callOptions...)
-		if err == nil {
-			after(res)
-		}
-		return err
-	}
-
-	req := &btpb.CheckAndMutateRowRequest{
-		TableName:       t.c.fullTableName(t.table),
-		AppProfileId:    t.c.appProfile,
-		RowKey:          []byte(row),
-		PredicateFilter: m.cond.proto(),
-	}
-	if m.mtrue != nil {
-		if m.mtrue.cond != nil {
-			return errors.New("bigtable: conditional mutations cannot be nested")
-		}
-		req.TrueMutations = m.mtrue.ops
-	}
-	if m.mfalse != nil {
-		if m.mfalse.cond != nil {
-			return errors.New("bigtable: conditional mutations cannot be nested")
-		}
-		req.FalseMutations = m.mfalse.ops
-	}
-	if mutationsAreRetryable(req.TrueMutations) && mutationsAreRetryable(req.FalseMutations) {
-		callOptions = retryOptions
-	}
-	var cmRes *btpb.CheckAndMutateRowResponse
-	err = gax.Invoke(ctx, func(ctx context.Context) error {
-		var err error
-		cmRes, err = t.c.client.CheckAndMutateRow(ctx, req)
-		return err
-	}, callOptions...)
-	if err == nil {
-		after(cmRes)
-	}
-	return err
-}
-
-// An ApplyOption is an optional argument to Apply.
-type ApplyOption interface {
-	after(res proto.Message)
-}
-
-type applyAfterFunc func(res proto.Message)
-
-func (a applyAfterFunc) after(res proto.Message) { a(res) }
-
-// GetCondMutationResult returns an ApplyOption that reports whether the conditional
-// mutation's condition matched.
-func GetCondMutationResult(matched *bool) ApplyOption {
-	return applyAfterFunc(func(res proto.Message) {
-		if res, ok := res.(*btpb.CheckAndMutateRowResponse); ok {
-			*matched = res.PredicateMatched
-		}
-	})
-}
-
-// Mutation represents a set of changes for a single row of a table.
-type Mutation struct {
-	ops []*btpb.Mutation
-
-	// for conditional mutations
-	cond          Filter
-	mtrue, mfalse *Mutation
-}
-
-// NewMutation returns a new mutation.
-func NewMutation() *Mutation {
-	return new(Mutation)
-}
-
-// NewCondMutation returns a conditional mutation.
-// The given row filter determines which mutation is applied:
-// If the filter matches any cell in the row, mtrue is applied;
-// otherwise, mfalse is applied.
-// Either given mutation may be nil.
-func NewCondMutation(cond Filter, mtrue, mfalse *Mutation) *Mutation {
-	return &Mutation{cond: cond, mtrue: mtrue, mfalse: mfalse}
-}
-
-// Set sets a value in a specified column, with the given timestamp.
-// The timestamp will be truncated to millisecond granularity.
-// A timestamp of ServerTime means to use the server timestamp.
-func (m *Mutation) Set(family, column string, ts Timestamp, value []byte) {
-	m.ops = append(m.ops, &btpb.Mutation{Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-		FamilyName:      family,
-		ColumnQualifier: []byte(column),
-		TimestampMicros: int64(ts.TruncateToMilliseconds()),
-		Value:           value,
-	}}})
-}
-
-// DeleteCellsInColumn will delete all the cells whose columns are family:column.
-func (m *Mutation) DeleteCellsInColumn(family, column string) {
-	m.ops = append(m.ops, &btpb.Mutation{Mutation: &btpb.Mutation_DeleteFromColumn_{DeleteFromColumn: &btpb.Mutation_DeleteFromColumn{
-		FamilyName:      family,
-		ColumnQualifier: []byte(column),
-	}}})
-}
-
-// DeleteTimestampRange deletes all cells whose columns are family:column
-// and whose timestamps are in the half-open interval [start, end).
-// If end is zero, it will be interpreted as infinity.
-// The timestamps will be truncated to millisecond granularity.
-func (m *Mutation) DeleteTimestampRange(family, column string, start, end Timestamp) {
-	m.ops = append(m.ops, &btpb.Mutation{Mutation: &btpb.Mutation_DeleteFromColumn_{DeleteFromColumn: &btpb.Mutation_DeleteFromColumn{
-		FamilyName:      family,
-		ColumnQualifier: []byte(column),
-		TimeRange: &btpb.TimestampRange{
-			StartTimestampMicros: int64(start.TruncateToMilliseconds()),
-			EndTimestampMicros:   int64(end.TruncateToMilliseconds()),
-		},
-	}}})
-}
-
-// DeleteCellsInFamily will delete all the cells whose columns are family:*.
-func (m *Mutation) DeleteCellsInFamily(family string) {
-	m.ops = append(m.ops, &btpb.Mutation{Mutation: &btpb.Mutation_DeleteFromFamily_{DeleteFromFamily: &btpb.Mutation_DeleteFromFamily{
-		FamilyName: family,
-	}}})
-}
-
-// DeleteRow deletes the entire row.
-func (m *Mutation) DeleteRow() {
-	m.ops = append(m.ops, &btpb.Mutation{Mutation: &btpb.Mutation_DeleteFromRow_{DeleteFromRow: &btpb.Mutation_DeleteFromRow{}}})
-}
-
-// entryErr is a container that combines an entry with the error that was returned for it.
-// Err may be nil if no error was returned for the Entry, or if the Entry has not yet been processed.
-type entryErr struct {
-	Entry *btpb.MutateRowsRequest_Entry
-	Err   error
-}
-
-// ApplyBulk applies multiple Mutations, up to a maximum of 100,000.
-// Each mutation is individually applied atomically,
-// but the set of mutations may be applied in any order.
-//
-// Two types of failures may occur. If the entire process
-// fails, (nil, err) will be returned. If specific mutations
-// fail to apply, ([]err, nil) will be returned, and the errors
-// will correspond to the relevant rowKeys/muts arguments.
-//
-// 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) ([]error, error) {
-	ctx = mergeOutgoingMetadata(ctx, t.md)
-	if len(rowKeys) != len(muts) {
-		return nil, fmt.Errorf("mismatched rowKeys and mutation array lengths: %d, %d", len(rowKeys), len(muts))
-	}
-
-	origEntries := make([]*entryErr, len(rowKeys))
-	for i, key := range rowKeys {
-		mut := muts[i]
-		if mut.cond != nil {
-			return nil, errors.New("conditional mutations cannot be applied in bulk")
-		}
-		origEntries[i] = &entryErr{Entry: &btpb.MutateRowsRequest_Entry{RowKey: []byte(key), Mutations: mut.ops}}
-	}
-
-	var err error
-	ctx = traceStartSpan(ctx, "cloud.google.com/go/bigtable/ApplyBulk")
-	defer func() { traceEndSpan(ctx, err) }()
-
-	for _, group := range groupEntries(origEntries, maxMutations) {
-		attrMap := make(map[string]interface{})
-		err = gax.Invoke(ctx, func(ctx context.Context) error {
-			attrMap["rowCount"] = len(group)
-			tracePrintf(ctx, attrMap, "Row count in ApplyBulk")
-			err := t.doApplyBulk(ctx, group, opts...)
-			if err != nil {
-				// We want to retry the entire request with the current group
-				return err
-			}
-			group = t.getApplyBulkRetries(group)
-			if len(group) > 0 && len(idempotentRetryCodes) > 0 {
-				// We have at least one mutation that needs to be retried.
-				// Return an arbitrary error that is retryable according to callOptions.
-				return status.Errorf(idempotentRetryCodes[0], "Synthetic error: partial failure of ApplyBulk")
-			}
-			return nil
-		}, retryOptions...)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	// Accumulate all of the errors into an array to return, interspersed with nils for successful
-	// entries. The absence of any errors means we should return nil.
-	var errs []error
-	var foundErr bool
-	for _, entry := range origEntries {
-		if entry.Err != nil {
-			foundErr = true
-		}
-		errs = append(errs, entry.Err)
-	}
-	if foundErr {
-		return errs, nil
-	}
-	return nil, nil
-}
-
-// getApplyBulkRetries returns the entries that need to be retried
-func (t *Table) getApplyBulkRetries(entries []*entryErr) []*entryErr {
-	var retryEntries []*entryErr
-	for _, entry := range entries {
-		err := entry.Err
-		if err != nil && isIdempotentRetryCode[grpc.Code(err)] && mutationsAreRetryable(entry.Entry.Mutations) {
-			// There was an error and the entry is retryable.
-			retryEntries = append(retryEntries, entry)
-		}
-	}
-	return retryEntries
-}
-
-// doApplyBulk does the work of a single ApplyBulk invocation
-func (t *Table) doApplyBulk(ctx context.Context, entryErrs []*entryErr, opts ...ApplyOption) error {
-	after := func(res proto.Message) {
-		for _, o := range opts {
-			o.after(res)
-		}
-	}
-
-	entries := make([]*btpb.MutateRowsRequest_Entry, len(entryErrs))
-	for i, entryErr := range entryErrs {
-		entries[i] = entryErr.Entry
-	}
-	req := &btpb.MutateRowsRequest{
-		TableName:    t.c.fullTableName(t.table),
-		AppProfileId: t.c.appProfile,
-		Entries:      entries,
-	}
-	stream, err := t.c.client.MutateRows(ctx, req)
-	if err != nil {
-		return err
-	}
-	for {
-		res, err := stream.Recv()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			return err
-		}
-
-		for i, entry := range res.Entries {
-			s := entry.Status
-			if s.Code == int32(codes.OK) {
-				entryErrs[i].Err = nil
-			} else {
-				entryErrs[i].Err = status.Errorf(codes.Code(s.Code), s.Message)
-			}
-		}
-		after(res)
-	}
-	return nil
-}
-
-// groupEntries groups entries into groups of a specified size without breaking up
-// individual entries.
-func groupEntries(entries []*entryErr, maxSize int) [][]*entryErr {
-	var (
-		res   [][]*entryErr
-		start int
-		gmuts int
-	)
-	addGroup := func(end int) {
-		if end-start > 0 {
-			res = append(res, entries[start:end])
-			start = end
-			gmuts = 0
-		}
-	}
-	for i, e := range entries {
-		emuts := len(e.Entry.Mutations)
-		if gmuts+emuts > maxSize {
-			addGroup(i)
-		}
-		gmuts += emuts
-	}
-	addGroup(len(entries))
-	return res
-}
-
-// Timestamp is in units of microseconds since 1 January 1970.
-type Timestamp int64
-
-// ServerTime is a specific Timestamp that may be passed to (*Mutation).Set.
-// It indicates that the server's timestamp should be used.
-const ServerTime Timestamp = -1
-
-// Time converts a time.Time into a Timestamp.
-func Time(t time.Time) Timestamp { return Timestamp(t.UnixNano() / 1e3) }
-
-// Now returns the Timestamp representation of the current time on the client.
-func Now() Timestamp { return Time(time.Now()) }
-
-// Time converts a Timestamp into a time.Time.
-func (ts Timestamp) Time() time.Time { return time.Unix(0, int64(ts)*1e3) }
-
-// TruncateToMilliseconds truncates a Timestamp to millisecond granularity,
-// which is currently the only granularity supported.
-func (ts Timestamp) TruncateToMilliseconds() Timestamp {
-	if ts == ServerTime {
-		return ts
-	}
-	return ts - ts%1000
-}
-
-// 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, t.md)
-	req := &btpb.ReadModifyWriteRowRequest{
-		TableName:    t.c.fullTableName(t.table),
-		AppProfileId: t.c.appProfile,
-		RowKey:       []byte(row),
-		Rules:        m.ops,
-	}
-	res, err := t.c.client.ReadModifyWriteRow(ctx, req)
-	if err != nil {
-		return nil, err
-	}
-	if res.Row == nil {
-		return nil, errors.New("unable to apply ReadModifyWrite: res.Row=nil")
-	}
-	r := make(Row)
-	for _, fam := range res.Row.Families { // res is *btpb.Row, fam is *btpb.Family
-		decodeFamilyProto(r, row, fam)
-	}
-	return r, nil
-}
-
-// ReadModifyWrite represents a set of operations on a single row of a table.
-// It is like Mutation but for non-idempotent changes.
-// When applied, these operations operate on the latest values of the row's cells,
-// and result in a new value being written to the relevant cell with a timestamp
-// that is max(existing timestamp, current server time).
-//
-// The application of a ReadModifyWrite is atomic; concurrent ReadModifyWrites will
-// be executed serially by the server.
-type ReadModifyWrite struct {
-	ops []*btpb.ReadModifyWriteRule
-}
-
-// NewReadModifyWrite returns a new ReadModifyWrite.
-func NewReadModifyWrite() *ReadModifyWrite { return new(ReadModifyWrite) }
-
-// AppendValue appends a value to a specific cell's value.
-// If the cell is unset, it will be treated as an empty value.
-func (m *ReadModifyWrite) AppendValue(family, column string, v []byte) {
-	m.ops = append(m.ops, &btpb.ReadModifyWriteRule{
-		FamilyName:      family,
-		ColumnQualifier: []byte(column),
-		Rule:            &btpb.ReadModifyWriteRule_AppendValue{AppendValue: v},
-	})
-}
-
-// Increment interprets the value in a specific cell as a 64-bit big-endian signed integer,
-// and adds a value to it. If the cell is unset, it will be treated as zero.
-// If the cell is set and is not an 8-byte value, the entire ApplyReadModifyWrite
-// operation will fail.
-func (m *ReadModifyWrite) Increment(family, column string, delta int64) {
-	m.ops = append(m.ops, &btpb.ReadModifyWriteRule{
-		FamilyName:      family,
-		ColumnQualifier: []byte(column),
-		Rule:            &btpb.ReadModifyWriteRule_IncrementAmount{IncrementAmount: delta},
-	})
-}
-
-// mergeOutgoingMetadata returns a context populated by the existing outgoing metadata,
-// if any, joined with internal metadata.
-func mergeOutgoingMetadata(ctx context.Context, md metadata.MD) context.Context {
-	mdCopy, _ := metadata.FromOutgoingContext(ctx)
-	return metadata.NewOutgoingContext(ctx, metadata.Join(mdCopy, md))
-}
-
-// 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, t.md)
-	var sampledRowKeys []string
-	err := gax.Invoke(ctx, func(ctx context.Context) error {
-		sampledRowKeys = nil
-		req := &btpb.SampleRowKeysRequest{
-			TableName:    t.c.fullTableName(t.table),
-			AppProfileId: t.c.appProfile,
-		}
-		ctx, cancel := context.WithCancel(ctx) // for aborting the stream
-		defer cancel()
-
-		stream, err := t.c.client.SampleRowKeys(ctx, req)
-		if err != nil {
-			return err
-		}
-		for {
-			res, err := stream.Recv()
-			if err == io.EOF {
-				break
-			}
-			if err != nil {
-				return err
-			}
-
-			key := string(res.RowKey)
-			if key == "" {
-				continue
-			}
-
-			sampledRowKeys = append(sampledRowKeys, key)
-		}
-		return nil
-	}, retryOptions...)
-	return sampledRowKeys, err
-}

+ 0 - 1255
vendor/cloud.google.com/go/bigtable/bigtable_test.go

@@ -1,1255 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package bigtable
-
-import (
-	"context"
-	"fmt"
-	"math/rand"
-	"strings"
-	"sync"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-	"google.golang.org/api/option"
-	btpb "google.golang.org/genproto/googleapis/bigtable/v2"
-	"google.golang.org/grpc"
-)
-
-func TestPrefix(t *testing.T) {
-	tests := []struct {
-		prefix, succ string
-	}{
-		{"", ""},
-		{"\xff", ""}, // when used, "" means Infinity
-		{"x\xff", "y"},
-		{"\xfe", "\xff"},
-	}
-	for _, tc := range tests {
-		got := prefixSuccessor(tc.prefix)
-		if got != tc.succ {
-			t.Errorf("prefixSuccessor(%q) = %q, want %s", tc.prefix, got, tc.succ)
-			continue
-		}
-		r := PrefixRange(tc.prefix)
-		if tc.succ == "" && r.limit != "" {
-			t.Errorf("PrefixRange(%q) got limit %q", tc.prefix, r.limit)
-		}
-		if tc.succ != "" && r.limit != tc.succ {
-			t.Errorf("PrefixRange(%q) got limit %q, want %q", tc.prefix, r.limit, tc.succ)
-		}
-	}
-}
-
-func TestApplyErrors(t *testing.T) {
-	ctx := context.Background()
-	table := &Table{
-		c: &Client{
-			project:  "P",
-			instance: "I",
-		},
-		table: "t",
-	}
-	f := ColumnFilter("C")
-	m := NewMutation()
-	m.DeleteRow()
-	// Test nested conditional mutations.
-	cm := NewCondMutation(f, NewCondMutation(f, m, nil), nil)
-	if err := table.Apply(ctx, "x", cm); err == nil {
-		t.Error("got nil, want error")
-	}
-	cm = NewCondMutation(f, nil, NewCondMutation(f, m, nil))
-	if err := table.Apply(ctx, "x", cm); err == nil {
-		t.Error("got nil, want error")
-	}
-}
-
-func TestGroupEntries(t *testing.T) {
-	tests := []struct {
-		desc string
-		in   []*entryErr
-		size int
-		want [][]*entryErr
-	}{
-		{
-			desc: "one entry less than max size is one group",
-			in:   []*entryErr{buildEntry(5)},
-			size: 10,
-			want: [][]*entryErr{{buildEntry(5)}},
-		},
-		{
-			desc: "one entry equal to max size is one group",
-			in:   []*entryErr{buildEntry(10)},
-			size: 10,
-			want: [][]*entryErr{{buildEntry(10)}},
-		},
-		{
-			desc: "one entry greater than max size is one group",
-			in:   []*entryErr{buildEntry(15)},
-			size: 10,
-			want: [][]*entryErr{{buildEntry(15)}},
-		},
-		{
-			desc: "all entries fitting within max size are one group",
-			in:   []*entryErr{buildEntry(10), buildEntry(10)},
-			size: 20,
-			want: [][]*entryErr{{buildEntry(10), buildEntry(10)}},
-		},
-		{
-			desc: "entries each under max size and together over max size are grouped separately",
-			in:   []*entryErr{buildEntry(10), buildEntry(10)},
-			size: 15,
-			want: [][]*entryErr{{buildEntry(10)}, {buildEntry(10)}},
-		},
-		{
-			desc: "entries together over max size are grouped by max size",
-			in:   []*entryErr{buildEntry(5), buildEntry(5), buildEntry(5)},
-			size: 10,
-			want: [][]*entryErr{{buildEntry(5), buildEntry(5)}, {buildEntry(5)}},
-		},
-		{
-			desc: "one entry over max size and one entry under max size are two groups",
-			in:   []*entryErr{buildEntry(15), buildEntry(5)},
-			size: 10,
-			want: [][]*entryErr{{buildEntry(15)}, {buildEntry(5)}},
-		},
-	}
-
-	for _, test := range tests {
-		if got, want := groupEntries(test.in, test.size), test.want; !cmp.Equal(mutationCounts(got), mutationCounts(want)) {
-			t.Errorf("[%s] want = %v, got = %v", test.desc, mutationCounts(want), mutationCounts(got))
-		}
-	}
-}
-
-func buildEntry(numMutations int) *entryErr {
-	var muts []*btpb.Mutation
-	for i := 0; i < numMutations; i++ {
-		muts = append(muts, &btpb.Mutation{})
-	}
-	return &entryErr{Entry: &btpb.MutateRowsRequest_Entry{Mutations: muts}}
-}
-
-func mutationCounts(batched [][]*entryErr) []int {
-	var res []int
-	for _, entries := range batched {
-		var count int
-		for _, e := range entries {
-			count += len(e.Entry.Mutations)
-		}
-		res = append(res, count)
-	}
-	return res
-}
-
-func TestClientIntegration(t *testing.T) {
-	// TODO(jba): go1.9: Use subtests.
-	start := time.Now()
-	lastCheckpoint := start
-	checkpoint := func(s string) {
-		n := time.Now()
-		t.Logf("[%s] %v since start, %v since last checkpoint", s, n.Sub(start), n.Sub(lastCheckpoint))
-		lastCheckpoint = n
-	}
-
-	testEnv, err := NewIntegrationEnv()
-	if err != nil {
-		t.Fatalf("IntegrationEnv: %v", err)
-	}
-
-	var timeout time.Duration
-	if testEnv.Config().UseProd {
-		timeout = 10 * time.Minute
-		t.Logf("Running test against production")
-	} else {
-		timeout = 1 * time.Minute
-		t.Logf("bttest.Server running on %s", testEnv.Config().AdminEndpoint)
-	}
-	ctx, cancel := context.WithTimeout(context.Background(), timeout)
-	defer cancel()
-
-	client, err := testEnv.NewClient()
-	if err != nil {
-		t.Fatalf("Client: %v", err)
-	}
-	defer client.Close()
-	checkpoint("dialed Client")
-
-	adminClient, err := testEnv.NewAdminClient()
-	if err != nil {
-		t.Fatalf("AdminClient: %v", err)
-	}
-	defer adminClient.Close()
-	checkpoint("dialed AdminClient")
-
-	table := testEnv.Config().Table
-
-	// Delete the table at the end of the test.
-	// Do this even before creating the table so that if this is running
-	// against production and CreateTable fails there's a chance of cleaning it up.
-	defer adminClient.DeleteTable(ctx, table)
-
-	if err := adminClient.CreateTable(ctx, table); err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-	checkpoint("created table")
-	if err := adminClient.CreateColumnFamily(ctx, table, "follows"); err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-	checkpoint(`created "follows" column family`)
-
-	tbl := client.Open(table)
-
-	// Insert some data.
-	initialData := map[string][]string{
-		"wmckinley":   {"tjefferson"},
-		"gwashington": {"jadams"},
-		"tjefferson":  {"gwashington", "jadams"}, // wmckinley set conditionally below
-		"jadams":      {"gwashington", "tjefferson"},
-	}
-	for row, ss := range initialData {
-		mut := NewMutation()
-		for _, name := range ss {
-			mut.Set("follows", name, 1000, []byte("1"))
-		}
-		if err := tbl.Apply(ctx, row, mut); err != nil {
-			t.Errorf("Mutating row %q: %v", row, err)
-		}
-	}
-	checkpoint("inserted initial data")
-
-	// TODO(igorbernstein): re-enable this when ready
-	//if err := adminClient.WaitForReplication(ctx, table); err != nil {
-	//	t.Errorf("Waiting for replication for table %q: %v", table, err)
-	//}
-	//checkpoint("waited for replication")
-
-	// Do a conditional mutation with a complex filter.
-	mutTrue := NewMutation()
-	mutTrue.Set("follows", "wmckinley", 1000, []byte("1"))
-	filter := ChainFilters(ColumnFilter("gwash[iz].*"), ValueFilter("."))
-	mut := NewCondMutation(filter, mutTrue, nil)
-	if err := tbl.Apply(ctx, "tjefferson", mut); err != nil {
-		t.Errorf("Conditionally mutating row: %v", err)
-	}
-	// Do a second condition mutation with a filter that does not match,
-	// and thus no changes should be made.
-	mutTrue = NewMutation()
-	mutTrue.DeleteRow()
-	filter = ColumnFilter("snoop.dogg")
-	mut = NewCondMutation(filter, mutTrue, nil)
-	if err := tbl.Apply(ctx, "tjefferson", mut); err != nil {
-		t.Errorf("Conditionally mutating row: %v", err)
-	}
-	checkpoint("did two conditional mutations")
-
-	// Fetch a row.
-	row, err := tbl.ReadRow(ctx, "jadams")
-	if err != nil {
-		t.Fatalf("Reading a row: %v", err)
-	}
-	wantRow := Row{
-		"follows": []ReadItem{
-			{Row: "jadams", Column: "follows:gwashington", Timestamp: 1000, Value: []byte("1")},
-			{Row: "jadams", Column: "follows:tjefferson", Timestamp: 1000, Value: []byte("1")},
-		},
-	}
-	if !testutil.Equal(row, wantRow) {
-		t.Errorf("Read row mismatch.\n got %#v\nwant %#v", row, wantRow)
-	}
-	checkpoint("tested ReadRow")
-
-	// Do a bunch of reads with filters.
-	readTests := []struct {
-		desc   string
-		rr     RowSet
-		filter Filter     // may be nil
-		limit  ReadOption // may be nil
-
-		// We do the read, grab all the cells, turn them into "<row>-<col>-<val>",
-		// and join with a comma.
-		want string
-	}{
-		{
-			desc: "read all, unfiltered",
-			rr:   RowRange{},
-			want: "gwashington-jadams-1,jadams-gwashington-1,jadams-tjefferson-1,tjefferson-gwashington-1,tjefferson-jadams-1,tjefferson-wmckinley-1,wmckinley-tjefferson-1",
-		},
-		{
-			desc: "read with InfiniteRange, unfiltered",
-			rr:   InfiniteRange("tjefferson"),
-			want: "tjefferson-gwashington-1,tjefferson-jadams-1,tjefferson-wmckinley-1,wmckinley-tjefferson-1",
-		},
-		{
-			desc: "read with NewRange, unfiltered",
-			rr:   NewRange("gargamel", "hubbard"),
-			want: "gwashington-jadams-1",
-		},
-		{
-			desc: "read with PrefixRange, unfiltered",
-			rr:   PrefixRange("jad"),
-			want: "jadams-gwashington-1,jadams-tjefferson-1",
-		},
-		{
-			desc: "read with SingleRow, unfiltered",
-			rr:   SingleRow("wmckinley"),
-			want: "wmckinley-tjefferson-1",
-		},
-		{
-			desc:   "read all, with ColumnFilter",
-			rr:     RowRange{},
-			filter: ColumnFilter(".*j.*"), // matches "jadams" and "tjefferson"
-			want:   "gwashington-jadams-1,jadams-tjefferson-1,tjefferson-jadams-1,wmckinley-tjefferson-1",
-		},
-		{
-			desc:   "read all, with ColumnFilter, prefix",
-			rr:     RowRange{},
-			filter: ColumnFilter("j"), // no matches
-			want:   "",
-		},
-		{
-			desc:   "read range, with ColumnRangeFilter",
-			rr:     RowRange{},
-			filter: ColumnRangeFilter("follows", "h", "k"),
-			want:   "gwashington-jadams-1,tjefferson-jadams-1",
-		},
-		{
-			desc:   "read range from empty, with ColumnRangeFilter",
-			rr:     RowRange{},
-			filter: ColumnRangeFilter("follows", "", "u"),
-			want:   "gwashington-jadams-1,jadams-gwashington-1,jadams-tjefferson-1,tjefferson-gwashington-1,tjefferson-jadams-1,wmckinley-tjefferson-1",
-		},
-		{
-			desc:   "read range from start to empty, with ColumnRangeFilter",
-			rr:     RowRange{},
-			filter: ColumnRangeFilter("follows", "h", ""),
-			want:   "gwashington-jadams-1,jadams-tjefferson-1,tjefferson-jadams-1,tjefferson-wmckinley-1,wmckinley-tjefferson-1",
-		},
-		{
-			desc:   "read with RowKeyFilter",
-			rr:     RowRange{},
-			filter: RowKeyFilter(".*wash.*"),
-			want:   "gwashington-jadams-1",
-		},
-		{
-			desc:   "read with RowKeyFilter, prefix",
-			rr:     RowRange{},
-			filter: RowKeyFilter("gwash"),
-			want:   "",
-		},
-		{
-			desc:   "read with RowKeyFilter, no matches",
-			rr:     RowRange{},
-			filter: RowKeyFilter(".*xxx.*"),
-			want:   "",
-		},
-		{
-			desc:   "read with FamilyFilter, no matches",
-			rr:     RowRange{},
-			filter: FamilyFilter(".*xxx.*"),
-			want:   "",
-		},
-		{
-			desc:   "read with ColumnFilter + row limit",
-			rr:     RowRange{},
-			filter: ColumnFilter(".*j.*"), // matches "jadams" and "tjefferson"
-			limit:  LimitRows(2),
-			want:   "gwashington-jadams-1,jadams-tjefferson-1",
-		},
-		{
-			desc:   "read all, strip values",
-			rr:     RowRange{},
-			filter: StripValueFilter(),
-			want:   "gwashington-jadams-,jadams-gwashington-,jadams-tjefferson-,tjefferson-gwashington-,tjefferson-jadams-,tjefferson-wmckinley-,wmckinley-tjefferson-",
-		},
-		{
-			desc:   "read with ColumnFilter + row limit + strip values",
-			rr:     RowRange{},
-			filter: ChainFilters(ColumnFilter(".*j.*"), StripValueFilter()), // matches "jadams" and "tjefferson"
-			limit:  LimitRows(2),
-			want:   "gwashington-jadams-,jadams-tjefferson-",
-		},
-		{
-			desc:   "read with condition, strip values on true",
-			rr:     RowRange{},
-			filter: ConditionFilter(ColumnFilter(".*j.*"), StripValueFilter(), nil),
-			want:   "gwashington-jadams-,jadams-gwashington-,jadams-tjefferson-,tjefferson-gwashington-,tjefferson-jadams-,tjefferson-wmckinley-,wmckinley-tjefferson-",
-		},
-		{
-			desc:   "read with condition, strip values on false",
-			rr:     RowRange{},
-			filter: ConditionFilter(ColumnFilter(".*xxx.*"), nil, StripValueFilter()),
-			want:   "gwashington-jadams-,jadams-gwashington-,jadams-tjefferson-,tjefferson-gwashington-,tjefferson-jadams-,tjefferson-wmckinley-,wmckinley-tjefferson-",
-		},
-		{
-			desc:   "read with ValueRangeFilter + row limit",
-			rr:     RowRange{},
-			filter: ValueRangeFilter([]byte("1"), []byte("5")), // matches our value of "1"
-			limit:  LimitRows(2),
-			want:   "gwashington-jadams-1,jadams-gwashington-1,jadams-tjefferson-1",
-		},
-		{
-			desc:   "read with ValueRangeFilter, no match on exclusive end",
-			rr:     RowRange{},
-			filter: ValueRangeFilter([]byte("0"), []byte("1")), // no match
-			want:   "",
-		},
-		{
-			desc:   "read with ValueRangeFilter, no matches",
-			rr:     RowRange{},
-			filter: ValueRangeFilter([]byte("3"), []byte("5")), // matches nothing
-			want:   "",
-		},
-		{
-			desc:   "read with InterleaveFilter, no matches on all filters",
-			rr:     RowRange{},
-			filter: InterleaveFilters(ColumnFilter(".*x.*"), ColumnFilter(".*z.*")),
-			want:   "",
-		},
-		{
-			desc:   "read with InterleaveFilter, no duplicate cells",
-			rr:     RowRange{},
-			filter: InterleaveFilters(ColumnFilter(".*g.*"), ColumnFilter(".*j.*")),
-			want:   "gwashington-jadams-1,jadams-gwashington-1,jadams-tjefferson-1,tjefferson-gwashington-1,tjefferson-jadams-1,wmckinley-tjefferson-1",
-		},
-		{
-			desc:   "read with InterleaveFilter, with duplicate cells",
-			rr:     RowRange{},
-			filter: InterleaveFilters(ColumnFilter(".*g.*"), ColumnFilter(".*g.*")),
-			want:   "jadams-gwashington-1,jadams-gwashington-1,tjefferson-gwashington-1,tjefferson-gwashington-1",
-		},
-		{
-			desc: "read with a RowRangeList and no filter",
-			rr:   RowRangeList{NewRange("gargamel", "hubbard"), InfiniteRange("wmckinley")},
-			want: "gwashington-jadams-1,wmckinley-tjefferson-1",
-		},
-		{
-			desc:   "chain that excludes rows and matches nothing, in a condition",
-			rr:     RowRange{},
-			filter: ConditionFilter(ChainFilters(ColumnFilter(".*j.*"), ColumnFilter(".*mckinley.*")), StripValueFilter(), nil),
-			want:   "",
-		},
-		{
-			desc:   "chain that ends with an interleave that has no match. covers #804",
-			rr:     RowRange{},
-			filter: ConditionFilter(ChainFilters(ColumnFilter(".*j.*"), InterleaveFilters(ColumnFilter(".*x.*"), ColumnFilter(".*z.*"))), StripValueFilter(), nil),
-			want:   "",
-		},
-	}
-	for _, tc := range readTests {
-		var opts []ReadOption
-		if tc.filter != nil {
-			opts = append(opts, RowFilter(tc.filter))
-		}
-		if tc.limit != nil {
-			opts = append(opts, tc.limit)
-		}
-		var elt []string
-		err := tbl.ReadRows(ctx, tc.rr, func(r Row) bool {
-			for _, ris := range r {
-				for _, ri := range ris {
-					elt = append(elt, formatReadItem(ri))
-				}
-			}
-			return true
-		}, opts...)
-		if err != nil {
-			t.Errorf("%s: %v", tc.desc, err)
-			continue
-		}
-		if got := strings.Join(elt, ","); got != tc.want {
-			t.Errorf("%s: wrong reads.\n got %q\nwant %q", tc.desc, got, tc.want)
-		}
-	}
-
-	// Read a RowList
-	var elt []string
-	keys := RowList{"wmckinley", "gwashington", "jadams"}
-	want := "gwashington-jadams-1,jadams-gwashington-1,jadams-tjefferson-1,wmckinley-tjefferson-1"
-	err = tbl.ReadRows(ctx, keys, func(r Row) bool {
-		for _, ris := range r {
-			for _, ri := range ris {
-				elt = append(elt, formatReadItem(ri))
-			}
-		}
-		return true
-	})
-	if err != nil {
-		t.Errorf("read RowList: %v", err)
-	}
-
-	if got := strings.Join(elt, ","); got != want {
-		t.Errorf("bulk read: wrong reads.\n got %q\nwant %q", got, want)
-	}
-	checkpoint("tested ReadRows in a few ways")
-
-	// Do a scan and stop part way through.
-	// Verify that the ReadRows callback doesn't keep running.
-	stopped := false
-	err = tbl.ReadRows(ctx, InfiniteRange(""), func(r Row) bool {
-		if r.Key() < "h" {
-			return true
-		}
-		if !stopped {
-			stopped = true
-			return false
-		}
-		t.Errorf("ReadRows kept scanning to row %q after being told to stop", r.Key())
-		return false
-	})
-	if err != nil {
-		t.Errorf("Partial ReadRows: %v", err)
-	}
-	checkpoint("did partial ReadRows test")
-
-	// Delete a row and check it goes away.
-	mut = NewMutation()
-	mut.DeleteRow()
-	if err := tbl.Apply(ctx, "wmckinley", mut); err != nil {
-		t.Errorf("Apply DeleteRow: %v", err)
-	}
-	row, err = tbl.ReadRow(ctx, "wmckinley")
-	if err != nil {
-		t.Fatalf("Reading a row after DeleteRow: %v", err)
-	}
-	if len(row) != 0 {
-		t.Fatalf("Read non-zero row after DeleteRow: %v", row)
-	}
-	checkpoint("exercised DeleteRow")
-
-	// Check ReadModifyWrite.
-
-	if err := adminClient.CreateColumnFamily(ctx, table, "counter"); err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-
-	appendRMW := func(b []byte) *ReadModifyWrite {
-		rmw := NewReadModifyWrite()
-		rmw.AppendValue("counter", "likes", b)
-		return rmw
-	}
-	incRMW := func(n int64) *ReadModifyWrite {
-		rmw := NewReadModifyWrite()
-		rmw.Increment("counter", "likes", n)
-		return rmw
-	}
-	rmwSeq := []struct {
-		desc string
-		rmw  *ReadModifyWrite
-		want []byte
-	}{
-		{
-			desc: "append #1",
-			rmw:  appendRMW([]byte{0, 0, 0}),
-			want: []byte{0, 0, 0},
-		},
-		{
-			desc: "append #2",
-			rmw:  appendRMW([]byte{0, 0, 0, 0, 17}), // the remaining 40 bits to make a big-endian 17
-			want: []byte{0, 0, 0, 0, 0, 0, 0, 17},
-		},
-		{
-			desc: "increment",
-			rmw:  incRMW(8),
-			want: []byte{0, 0, 0, 0, 0, 0, 0, 25},
-		},
-	}
-	for _, step := range rmwSeq {
-		row, err := tbl.ApplyReadModifyWrite(ctx, "gwashington", step.rmw)
-		if err != nil {
-			t.Fatalf("ApplyReadModifyWrite %+v: %v", step.rmw, err)
-		}
-		// Make sure the modified cell returned by the RMW operation has a timestamp.
-		if row["counter"][0].Timestamp == 0 {
-			t.Errorf("RMW returned cell timestamp: got %v, want > 0", row["counter"][0].Timestamp)
-		}
-		clearTimestamps(row)
-		wantRow := Row{"counter": []ReadItem{{Row: "gwashington", Column: "counter:likes", Value: step.want}}}
-		if !testutil.Equal(row, wantRow) {
-			t.Fatalf("After %s,\n got %v\nwant %v", step.desc, row, wantRow)
-		}
-	}
-
-	// Check for google-cloud-go/issues/723. RMWs that insert new rows should keep row order sorted in the emulator.
-	_, err = tbl.ApplyReadModifyWrite(ctx, "issue-723-2", appendRMW([]byte{0}))
-	if err != nil {
-		t.Fatalf("ApplyReadModifyWrite null string: %v", err)
-	}
-	_, err = tbl.ApplyReadModifyWrite(ctx, "issue-723-1", appendRMW([]byte{0}))
-	if err != nil {
-		t.Fatalf("ApplyReadModifyWrite null string: %v", err)
-	}
-	// Get only the correct row back on read.
-	r, err := tbl.ReadRow(ctx, "issue-723-1")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	if r.Key() != "issue-723-1" {
-		t.Errorf("ApplyReadModifyWrite: incorrect read after RMW,\n got %v\nwant %v", r.Key(), "issue-723-1")
-	}
-	checkpoint("tested ReadModifyWrite")
-
-	// Test arbitrary timestamps more thoroughly.
-	if err := adminClient.CreateColumnFamily(ctx, table, "ts"); err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-	const numVersions = 4
-	mut = NewMutation()
-	for i := 1; i < numVersions; i++ {
-		// Timestamps are used in thousands because the server
-		// only permits that granularity.
-		mut.Set("ts", "col", Timestamp(i*1000), []byte(fmt.Sprintf("val-%d", i)))
-		mut.Set("ts", "col2", Timestamp(i*1000), []byte(fmt.Sprintf("val-%d", i)))
-	}
-	if err := tbl.Apply(ctx, "testrow", mut); err != nil {
-		t.Fatalf("Mutating row: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "testrow")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		// These should be returned in descending timestamp order.
-		{Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell with multiple versions,\n got %v\nwant %v", r, wantRow)
-	}
-	// Do the same read, but filter to the latest two versions.
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(LatestNFilter(2)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell with multiple versions and LatestNFilter(2),\n got %v\nwant %v", r, wantRow)
-	}
-	// Check cell offset / limit
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(CellsPerRowLimitFilter(3)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell with multiple versions and CellsPerRowLimitFilter(3),\n got %v\nwant %v", r, wantRow)
-	}
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(CellsPerRowOffsetFilter(3)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell with multiple versions and CellsPerRowOffsetFilter(3),\n got %v\nwant %v", r, wantRow)
-	}
-	// Check timestamp range filtering (with truncation)
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(TimestampRangeFilterMicros(1001, 3000)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell with multiple versions and TimestampRangeFilter(1000, 3000),\n got %v\nwant %v", r, wantRow)
-	}
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(TimestampRangeFilterMicros(1000, 0)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell with multiple versions and TimestampRangeFilter(1000, 0),\n got %v\nwant %v", r, wantRow)
-	}
-	// Delete non-existing cells, no such column family in this row
-	// Should not delete anything
-	if err := adminClient.CreateColumnFamily(ctx, table, "non-existing"); err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-	mut = NewMutation()
-	mut.DeleteTimestampRange("non-existing", "col", 2000, 3000) // half-open interval
-	if err := tbl.Apply(ctx, "testrow", mut); err != nil {
-		t.Fatalf("Mutating row: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(LatestNFilter(3)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell was deleted unexpectly,\n got %v\nwant %v", r, wantRow)
-	}
-	// Delete non-existing cells, no such column in this column family
-	// Should not delete anything
-	mut = NewMutation()
-	mut.DeleteTimestampRange("ts", "non-existing", 2000, 3000) // half-open interval
-	if err := tbl.Apply(ctx, "testrow", mut); err != nil {
-		t.Fatalf("Mutating row: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(LatestNFilter(3)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell was deleted unexpectly,\n got %v\nwant %v", r, wantRow)
-	}
-	// Delete the cell with timestamp 2000 and repeat the last read,
-	// checking that we get ts 3000 and ts 1000.
-	mut = NewMutation()
-	mut.DeleteTimestampRange("ts", "col", 2001, 3000) // half-open interval
-	if err := tbl.Apply(ctx, "testrow", mut); err != nil {
-		t.Fatalf("Mutating row: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "testrow", RowFilter(LatestNFilter(2)))
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")},
-		{Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Cell with multiple versions and LatestNFilter(2), after deleting timestamp 2000,\n got %v\nwant %v", r, wantRow)
-	}
-	checkpoint("tested multiple versions in a cell")
-
-	// Check DeleteCellsInFamily
-	if err := adminClient.CreateColumnFamily(ctx, table, "status"); err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-
-	mut = NewMutation()
-	mut.Set("status", "start", 2000, []byte("2"))
-	mut.Set("status", "end", 3000, []byte("3"))
-	mut.Set("ts", "col", 1000, []byte("1"))
-	if err := tbl.Apply(ctx, "row1", mut); err != nil {
-		t.Errorf("Mutating row: %v", err)
-	}
-	if err := tbl.Apply(ctx, "row2", mut); err != nil {
-		t.Errorf("Mutating row: %v", err)
-	}
-
-	mut = NewMutation()
-	mut.DeleteCellsInFamily("status")
-	if err := tbl.Apply(ctx, "row1", mut); err != nil {
-		t.Errorf("Delete cf: %v", err)
-	}
-
-	// ColumnFamily removed
-	r, err = tbl.ReadRow(ctx, "row1")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "row1", Column: "ts:col", Timestamp: 1000, Value: []byte("1")},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("column family was not deleted.\n got %v\n want %v", r, wantRow)
-	}
-
-	// ColumnFamily not removed
-	r, err = tbl.ReadRow(ctx, "row2")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{
-		"ts": []ReadItem{
-			{Row: "row2", Column: "ts:col", Timestamp: 1000, Value: []byte("1")},
-		},
-		"status": []ReadItem{
-			{Row: "row2", Column: "status:end", Timestamp: 3000, Value: []byte("3")},
-			{Row: "row2", Column: "status:start", Timestamp: 2000, Value: []byte("2")},
-		},
-	}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Column family was deleted unexpectedly.\n got %v\n want %v", r, wantRow)
-	}
-	checkpoint("tested family delete")
-
-	// Check DeleteCellsInColumn
-	mut = NewMutation()
-	mut.Set("status", "start", 2000, []byte("2"))
-	mut.Set("status", "middle", 3000, []byte("3"))
-	mut.Set("status", "end", 1000, []byte("1"))
-	if err := tbl.Apply(ctx, "row3", mut); err != nil {
-		t.Errorf("Mutating row: %v", err)
-	}
-	mut = NewMutation()
-	mut.DeleteCellsInColumn("status", "middle")
-	if err := tbl.Apply(ctx, "row3", mut); err != nil {
-		t.Errorf("Delete column: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "row3")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{
-		"status": []ReadItem{
-			{Row: "row3", Column: "status:end", Timestamp: 1000, Value: []byte("1")},
-			{Row: "row3", Column: "status:start", Timestamp: 2000, Value: []byte("2")},
-		},
-	}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Column was not deleted.\n got %v\n want %v", r, wantRow)
-	}
-	mut = NewMutation()
-	mut.DeleteCellsInColumn("status", "start")
-	if err := tbl.Apply(ctx, "row3", mut); err != nil {
-		t.Errorf("Delete column: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "row3")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	wantRow = Row{
-		"status": []ReadItem{
-			{Row: "row3", Column: "status:end", Timestamp: 1000, Value: []byte("1")},
-		},
-	}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Column was not deleted.\n got %v\n want %v", r, wantRow)
-	}
-	mut = NewMutation()
-	mut.DeleteCellsInColumn("status", "end")
-	if err := tbl.Apply(ctx, "row3", mut); err != nil {
-		t.Errorf("Delete column: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "row3")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	if len(r) != 0 {
-		t.Errorf("Delete column: got %v, want empty row", r)
-	}
-	// Add same cell after delete
-	mut = NewMutation()
-	mut.Set("status", "end", 1000, []byte("1"))
-	if err := tbl.Apply(ctx, "row3", mut); err != nil {
-		t.Errorf("Mutating row: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "row3")
-	if err != nil {
-		t.Fatalf("Reading row: %v", err)
-	}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Column was not deleted correctly.\n got %v\n want %v", r, wantRow)
-	}
-	checkpoint("tested column delete")
-
-	// Do highly concurrent reads/writes.
-	// TODO(dsymonds): Raise this to 1000 when https://github.com/grpc/grpc-go/issues/205 is resolved.
-	const maxConcurrency = 100
-	var wg sync.WaitGroup
-	for i := 0; i < maxConcurrency; i++ {
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			switch r := rand.Intn(100); { // r ∈ [0,100)
-			case 0 <= r && r < 30:
-				// Do a read.
-				_, err := tbl.ReadRow(ctx, "testrow", RowFilter(LatestNFilter(1)))
-				if err != nil {
-					t.Errorf("Concurrent read: %v", err)
-				}
-			case 30 <= r && r < 100:
-				// Do a write.
-				mut := NewMutation()
-				mut.Set("ts", "col", 1000, []byte("data"))
-				if err := tbl.Apply(ctx, "testrow", mut); err != nil {
-					t.Errorf("Concurrent write: %v", err)
-				}
-			}
-		}()
-	}
-	wg.Wait()
-	checkpoint("tested high concurrency")
-
-	// Large reads, writes and scans.
-	bigBytes := make([]byte, 5<<20) // 5 MB is larger than current default gRPC max of 4 MB, but less than the max we set.
-	nonsense := []byte("lorem ipsum dolor sit amet, ")
-	fill(bigBytes, nonsense)
-	mut = NewMutation()
-	mut.Set("ts", "col", 1000, bigBytes)
-	if err := tbl.Apply(ctx, "bigrow", mut); err != nil {
-		t.Errorf("Big write: %v", err)
-	}
-	r, err = tbl.ReadRow(ctx, "bigrow")
-	if err != nil {
-		t.Errorf("Big read: %v", err)
-	}
-	wantRow = Row{"ts": []ReadItem{
-		{Row: "bigrow", Column: "ts:col", Timestamp: 1000, Value: bigBytes},
-	}}
-	if !testutil.Equal(r, wantRow) {
-		t.Errorf("Big read returned incorrect bytes: %v", r)
-	}
-	// Now write 1000 rows, each with 82 KB values, then scan them all.
-	medBytes := make([]byte, 82<<10)
-	fill(medBytes, nonsense)
-	sem := make(chan int, 50) // do up to 50 mutations at a time.
-	for i := 0; i < 1000; i++ {
-		mut := NewMutation()
-		mut.Set("ts", "big-scan", 1000, medBytes)
-		row := fmt.Sprintf("row-%d", i)
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			defer func() { <-sem }()
-			sem <- 1
-			if err := tbl.Apply(ctx, row, mut); err != nil {
-				t.Errorf("Preparing large scan: %v", err)
-			}
-		}()
-	}
-	wg.Wait()
-	n := 0
-	err = tbl.ReadRows(ctx, PrefixRange("row-"), func(r Row) bool {
-		for _, ris := range r {
-			for _, ri := range ris {
-				n += len(ri.Value)
-			}
-		}
-		return true
-	}, RowFilter(ColumnFilter("big-scan")))
-	if err != nil {
-		t.Errorf("Doing large scan: %v", err)
-	}
-	if want := 1000 * len(medBytes); n != want {
-		t.Errorf("Large scan returned %d bytes, want %d", n, want)
-	}
-	// Scan a subset of the 1000 rows that we just created, using a LimitRows ReadOption.
-	rc := 0
-	wantRc := 3
-	err = tbl.ReadRows(ctx, PrefixRange("row-"), func(r Row) bool {
-		rc++
-		return true
-	}, LimitRows(int64(wantRc)))
-	if err != nil {
-		t.Fatal(err)
-	}
-	if rc != wantRc {
-		t.Errorf("Scan with row limit returned %d rows, want %d", rc, wantRc)
-	}
-	checkpoint("tested big read/write/scan")
-
-	// Test bulk mutations
-	if err := adminClient.CreateColumnFamily(ctx, table, "bulk"); err != nil {
-		t.Fatalf("Creating column family: %v", err)
-	}
-	bulkData := map[string][]string{
-		"red sox":  {"2004", "2007", "2013"},
-		"patriots": {"2001", "2003", "2004", "2014"},
-		"celtics":  {"1981", "1984", "1986", "2008"},
-	}
-	var rowKeys []string
-	var muts []*Mutation
-	for row, ss := range bulkData {
-		mut := NewMutation()
-		for _, name := range ss {
-			mut.Set("bulk", name, 1000, []byte("1"))
-		}
-		rowKeys = append(rowKeys, row)
-		muts = append(muts, mut)
-	}
-	status, err := tbl.ApplyBulk(ctx, rowKeys, muts)
-	if err != nil {
-		t.Fatalf("Bulk mutating rows %q: %v", rowKeys, err)
-	}
-	if status != nil {
-		t.Errorf("non-nil errors: %v", err)
-	}
-	checkpoint("inserted bulk data")
-
-	// Read each row back
-	for rowKey, ss := range bulkData {
-		row, err := tbl.ReadRow(ctx, rowKey)
-		if err != nil {
-			t.Fatalf("Reading a bulk row: %v", err)
-		}
-		var wantItems []ReadItem
-		for _, val := range ss {
-			wantItems = append(wantItems, ReadItem{Row: rowKey, Column: "bulk:" + val, Timestamp: 1000, Value: []byte("1")})
-		}
-		wantRow := Row{"bulk": wantItems}
-		if !testutil.Equal(row, wantRow) {
-			t.Errorf("Read row mismatch.\n got %#v\nwant %#v", row, wantRow)
-		}
-	}
-	checkpoint("tested reading from bulk insert")
-
-	// Test bulk write errors.
-	// Note: Setting timestamps as ServerTime makes sure the mutations are not retried on error.
-	badMut := NewMutation()
-	badMut.Set("badfamily", "col", ServerTime, nil)
-	badMut2 := NewMutation()
-	badMut2.Set("badfamily2", "goodcol", ServerTime, []byte("1"))
-	status, err = tbl.ApplyBulk(ctx, []string{"badrow", "badrow2"}, []*Mutation{badMut, badMut2})
-	if err != nil {
-		t.Fatalf("Bulk mutating rows %q: %v", rowKeys, err)
-	}
-	if status == nil {
-		t.Errorf("No errors for bad bulk mutation")
-	} else if status[0] == nil || status[1] == nil {
-		t.Errorf("No error for bad bulk mutation")
-	}
-}
-
-type requestCountingInterceptor struct {
-	grpc.ClientStream
-	requestCallback func()
-}
-
-func (i *requestCountingInterceptor) SendMsg(m interface{}) error {
-	i.requestCallback()
-	return i.ClientStream.SendMsg(m)
-}
-
-func (i *requestCountingInterceptor) RecvMsg(m interface{}) error {
-	return i.ClientStream.RecvMsg(m)
-}
-
-func requestCallback(callback func()) func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
-	return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
-		clientStream, err := streamer(ctx, desc, cc, method, opts...)
-		return &requestCountingInterceptor{
-			ClientStream:    clientStream,
-			requestCallback: callback,
-		}, err
-	}
-}
-
-// TestReadRowsInvalidRowSet verifies that the client doesn't send ReadRows() requests with invalid RowSets.
-func TestReadRowsInvalidRowSet(t *testing.T) {
-	testEnv, err := NewEmulatedEnv(IntegrationTestConfig{})
-	if err != nil {
-		t.Fatalf("NewEmulatedEnv failed: %v", err)
-	}
-	var requestCount int
-	incrementRequestCount := func() { requestCount++ }
-	conn, err := grpc.Dial(testEnv.server.Addr, grpc.WithInsecure(), grpc.WithBlock(),
-		grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(100<<20), grpc.MaxCallRecvMsgSize(100<<20)),
-		grpc.WithStreamInterceptor(requestCallback(incrementRequestCount)),
-	)
-	if err != nil {
-		t.Fatalf("grpc.Dial failed: %v", err)
-	}
-	ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
-	defer cancel()
-	adminClient, err := NewAdminClient(ctx, testEnv.config.Project, testEnv.config.Instance, option.WithGRPCConn(conn))
-	if err != nil {
-		t.Fatalf("NewClient failed: %v", err)
-	}
-	defer adminClient.Close()
-	if err := adminClient.CreateTable(ctx, testEnv.config.Table); err != nil {
-		t.Fatalf("CreateTable(%v) failed: %v", testEnv.config.Table, err)
-	}
-	client, err := NewClient(ctx, testEnv.config.Project, testEnv.config.Instance, option.WithGRPCConn(conn))
-	if err != nil {
-		t.Fatalf("NewClient failed: %v", err)
-	}
-	defer client.Close()
-	table := client.Open(testEnv.config.Table)
-	tests := []struct {
-		rr    RowSet
-		valid bool
-	}{
-		{
-			rr:    RowRange{},
-			valid: true,
-		},
-		{
-			rr:    RowRange{start: "b"},
-			valid: true,
-		},
-		{
-			rr:    RowRange{start: "b", limit: "c"},
-			valid: true,
-		},
-		{
-			rr:    RowRange{start: "b", limit: "a"},
-			valid: false,
-		},
-		{
-			rr:    RowList{"a"},
-			valid: true,
-		},
-		{
-			rr:    RowList{},
-			valid: false,
-		},
-	}
-	for _, test := range tests {
-		requestCount = 0
-		err = table.ReadRows(ctx, test.rr, func(r Row) bool { return true })
-		if err != nil {
-			t.Fatalf("ReadRows(%v) failed: %v", test.rr, err)
-		}
-		requestValid := requestCount != 0
-		if requestValid != test.valid {
-			t.Errorf("%s: got %v, want %v", test.rr, requestValid, test.valid)
-		}
-	}
-}
-
-func formatReadItem(ri ReadItem) string {
-	// Use the column qualifier only to make the test data briefer.
-	col := ri.Column[strings.Index(ri.Column, ":")+1:]
-	return fmt.Sprintf("%s-%s-%s", ri.Row, col, ri.Value)
-}
-
-func fill(b, sub []byte) {
-	for len(b) > len(sub) {
-		n := copy(b, sub)
-		b = b[n:]
-	}
-}
-
-func clearTimestamps(r Row) {
-	for _, ris := range r {
-		for i := range ris {
-			ris[i].Timestamp = 0
-		}
-	}
-}
-
-func TestSampleRowKeys(t *testing.T) {
-	start := time.Now()
-	lastCheckpoint := start
-	checkpoint := func(s string) {
-		n := time.Now()
-		t.Logf("[%s] %v since start, %v since last checkpoint", s, n.Sub(start), n.Sub(lastCheckpoint))
-		lastCheckpoint = n
-	}
-	ctx := context.Background()
-	client, adminClient, table, err := doSetup(ctx)
-	if err != nil {
-		t.Fatalf("%v", err)
-	}
-	defer client.Close()
-	defer adminClient.Close()
-	tbl := client.Open(table)
-	// Delete the table at the end of the test.
-	// Do this even before creating the table so that if this is running
-	// against production and CreateTable fails there's a chance of cleaning it up.
-	defer adminClient.DeleteTable(ctx, table)
-
-	// Insert some data.
-	initialData := map[string][]string{
-		"wmckinley11":   {"tjefferson11"},
-		"gwashington77": {"jadams77"},
-		"tjefferson0":   {"gwashington0", "jadams0"},
-	}
-
-	for row, ss := range initialData {
-		mut := NewMutation()
-		for _, name := range ss {
-			mut.Set("follows", name, 1000, []byte("1"))
-		}
-		if err := tbl.Apply(ctx, row, mut); err != nil {
-			t.Errorf("Mutating row %q: %v", row, err)
-		}
-	}
-	checkpoint("inserted initial data")
-	sampleKeys, err := tbl.SampleRowKeys(context.Background())
-	if err != nil {
-		t.Errorf("%s: %v", "SampleRowKeys:", err)
-	}
-	if len(sampleKeys) == 0 {
-		t.Error("SampleRowKeys length 0")
-	}
-	checkpoint("tested SampleRowKeys.")
-}
-
-func doSetup(ctx context.Context) (*Client, *AdminClient, string, error) {
-	start := time.Now()
-	lastCheckpoint := start
-	checkpoint := func(s string) {
-		n := time.Now()
-		fmt.Printf("[%s] %v since start, %v since last checkpoint", s, n.Sub(start), n.Sub(lastCheckpoint))
-		lastCheckpoint = n
-	}
-
-	testEnv, err := NewIntegrationEnv()
-	if err != nil {
-		return nil, nil, "", fmt.Errorf("IntegrationEnv: %v", err)
-	}
-
-	var timeout time.Duration
-	if testEnv.Config().UseProd {
-		timeout = 10 * time.Minute
-		fmt.Printf("Running test against production")
-	} else {
-		timeout = 1 * time.Minute
-		fmt.Printf("bttest.Server running on %s", testEnv.Config().AdminEndpoint)
-	}
-	ctx, cancel := context.WithTimeout(ctx, timeout)
-	defer cancel()
-
-	client, err := testEnv.NewClient()
-	if err != nil {
-		return nil, nil, "", fmt.Errorf("Client: %v", err)
-	}
-	checkpoint("dialed Client")
-
-	adminClient, err := testEnv.NewAdminClient()
-	if err != nil {
-		return nil, nil, "", fmt.Errorf("AdminClient: %v", err)
-	}
-	checkpoint("dialed AdminClient")
-
-	table := testEnv.Config().Table
-	if err := adminClient.CreateTable(ctx, table); err != nil {
-		return nil, nil, "", fmt.Errorf("Creating table: %v", err)
-	}
-	checkpoint("created table")
-	if err := adminClient.CreateColumnFamily(ctx, table, "follows"); err != nil {
-		return nil, nil, "", fmt.Errorf("Creating column family: %v", err)
-	}
-	checkpoint(`created "follows" column family`)
-
-	return client, adminClient, table, nil
-}

+ 0 - 83
vendor/cloud.google.com/go/bigtable/bttest/example_test.go

@@ -1,83 +0,0 @@
-/*
-Copyright 2016 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
-
-    http://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.
-*/
-package bttest_test
-
-import (
-	"context"
-	"fmt"
-	"log"
-
-	"cloud.google.com/go/bigtable"
-	"cloud.google.com/go/bigtable/bttest"
-	"google.golang.org/api/option"
-	"google.golang.org/grpc"
-)
-
-func ExampleNewServer() {
-
-	srv, err := bttest.NewServer("localhost:0")
-
-	if err != nil {
-		log.Fatalln(err)
-	}
-
-	ctx := context.Background()
-
-	conn, err := grpc.Dial(srv.Addr, grpc.WithInsecure())
-	if err != nil {
-		log.Fatalln(err)
-	}
-
-	proj, instance := "proj", "instance"
-
-	adminClient, err := bigtable.NewAdminClient(ctx, proj, instance, option.WithGRPCConn(conn))
-	if err != nil {
-		log.Fatalln(err)
-	}
-
-	if err = adminClient.CreateTable(ctx, "example"); err != nil {
-		log.Fatalln(err)
-	}
-
-	if err = adminClient.CreateColumnFamily(ctx, "example", "links"); err != nil {
-		log.Fatalln(err)
-	}
-
-	client, err := bigtable.NewClient(ctx, proj, instance, option.WithGRPCConn(conn))
-	if err != nil {
-		log.Fatalln(err)
-	}
-	tbl := client.Open("example")
-
-	mut := bigtable.NewMutation()
-	mut.Set("links", "golang.org", bigtable.Now(), []byte("Gophers!"))
-	if err = tbl.Apply(ctx, "com.google.cloud", mut); err != nil {
-		log.Fatalln(err)
-	}
-
-	if row, err := tbl.ReadRow(ctx, "com.google.cloud"); err != nil {
-		log.Fatalln(err)
-	} else {
-		for _, column := range row["links"] {
-			fmt.Println(column.Column)
-			fmt.Println(string(column.Value))
-		}
-	}
-
-	// Output:
-	// links:golang.org
-	// Gophers!
-}

+ 0 - 1406
vendor/cloud.google.com/go/bigtable/bttest/inmem.go

@@ -1,1406 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-/*
-Package bttest contains test helpers for working with the bigtable package.
-
-To use a Server, create it, and then connect to it with no security:
-(The project/instance values are ignored.)
-	srv, err := bttest.NewServer("localhost:0")
-	...
-	conn, err := grpc.Dial(srv.Addr, grpc.WithInsecure())
-	...
-	client, err := bigtable.NewClient(ctx, proj, instance,
-	        option.WithGRPCConn(conn))
-	...
-*/
-package bttest // import "cloud.google.com/go/bigtable/bttest"
-
-import (
-	"bytes"
-	"context"
-	"encoding/binary"
-	"fmt"
-	"log"
-	"math/rand"
-	"net"
-	"regexp"
-	"sort"
-	"strings"
-	"sync"
-	"time"
-
-	emptypb "github.com/golang/protobuf/ptypes/empty"
-	"github.com/golang/protobuf/ptypes/wrappers"
-	"github.com/google/btree"
-	btapb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
-	btpb "google.golang.org/genproto/googleapis/bigtable/v2"
-	"google.golang.org/genproto/googleapis/longrunning"
-	statpb "google.golang.org/genproto/googleapis/rpc/status"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/status"
-)
-
-const (
-	// MilliSeconds field of the minimum valid Timestamp.
-	minValidMilliSeconds = 0
-
-	// MilliSeconds field of the max valid Timestamp.
-	maxValidMilliSeconds = int64(time.Millisecond) * 253402300800
-)
-
-var (
-	validLabelTransformer = regexp.MustCompile(`[a-z0-9\-]{1,15}`)
-)
-
-// Server is an in-memory Cloud Bigtable fake.
-// It is unauthenticated, and only a rough approximation.
-type Server struct {
-	Addr string
-
-	l   net.Listener
-	srv *grpc.Server
-	s   *server
-}
-
-// server is the real implementation of the fake.
-// It is a separate and unexported type so the API won't be cluttered with
-// methods that are only relevant to the fake's implementation.
-type server struct {
-	mu     sync.Mutex
-	tables map[string]*table // keyed by fully qualified name
-	gcc    chan int          // set when gcloop starts, closed when server shuts down
-
-	// Any unimplemented methods will cause a panic.
-	btapb.BigtableTableAdminServer
-	btpb.BigtableServer
-}
-
-// NewServer creates a new Server.
-// The Server will be listening for gRPC connections, without TLS,
-// on the provided address. The resolved address is named by the Addr field.
-func NewServer(laddr string, opt ...grpc.ServerOption) (*Server, error) {
-	l, err := net.Listen("tcp", laddr)
-	if err != nil {
-		return nil, err
-	}
-
-	s := &Server{
-		Addr: l.Addr().String(),
-		l:    l,
-		srv:  grpc.NewServer(opt...),
-		s: &server{
-			tables: make(map[string]*table),
-		},
-	}
-	btapb.RegisterBigtableTableAdminServer(s.srv, s.s)
-	btpb.RegisterBigtableServer(s.srv, s.s)
-
-	go s.srv.Serve(s.l)
-
-	return s, nil
-}
-
-// Close shuts down the server.
-func (s *Server) Close() {
-	s.s.mu.Lock()
-	if s.s.gcc != nil {
-		close(s.s.gcc)
-	}
-	s.s.mu.Unlock()
-
-	s.srv.Stop()
-	s.l.Close()
-}
-
-func (s *server) CreateTable(ctx context.Context, req *btapb.CreateTableRequest) (*btapb.Table, error) {
-	tbl := req.Parent + "/tables/" + req.TableId
-
-	s.mu.Lock()
-	if _, ok := s.tables[tbl]; ok {
-		s.mu.Unlock()
-		return nil, status.Errorf(codes.AlreadyExists, "table %q already exists", tbl)
-	}
-	s.tables[tbl] = newTable(req)
-	s.mu.Unlock()
-
-	return &btapb.Table{Name: tbl}, nil
-}
-
-func (s *server) CreateTableFromSnapshot(context.Context, *btapb.CreateTableFromSnapshotRequest) (*longrunning.Operation, error) {
-	return nil, status.Errorf(codes.Unimplemented, "the emulator does not currently support snapshots")
-}
-
-func (s *server) ListTables(ctx context.Context, req *btapb.ListTablesRequest) (*btapb.ListTablesResponse, error) {
-	res := &btapb.ListTablesResponse{}
-	prefix := req.Parent + "/tables/"
-
-	s.mu.Lock()
-	for tbl := range s.tables {
-		if strings.HasPrefix(tbl, prefix) {
-			res.Tables = append(res.Tables, &btapb.Table{Name: tbl})
-		}
-	}
-	s.mu.Unlock()
-
-	return res, nil
-}
-
-func (s *server) GetTable(ctx context.Context, req *btapb.GetTableRequest) (*btapb.Table, error) {
-	tbl := req.Name
-
-	s.mu.Lock()
-	tblIns, ok := s.tables[tbl]
-	s.mu.Unlock()
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", tbl)
-	}
-
-	return &btapb.Table{
-		Name:           tbl,
-		ColumnFamilies: toColumnFamilies(tblIns.columnFamilies()),
-	}, nil
-}
-
-func (s *server) DeleteTable(ctx context.Context, req *btapb.DeleteTableRequest) (*emptypb.Empty, error) {
-	s.mu.Lock()
-	defer s.mu.Unlock()
-	if _, ok := s.tables[req.Name]; !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.Name)
-	}
-	delete(s.tables, req.Name)
-	return &emptypb.Empty{}, nil
-}
-
-func (s *server) ModifyColumnFamilies(ctx context.Context, req *btapb.ModifyColumnFamiliesRequest) (*btapb.Table, error) {
-	s.mu.Lock()
-	tbl, ok := s.tables[req.Name]
-	s.mu.Unlock()
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.Name)
-	}
-
-	tbl.mu.Lock()
-	defer tbl.mu.Unlock()
-
-	for _, mod := range req.Modifications {
-		if create := mod.GetCreate(); create != nil {
-			if _, ok := tbl.families[mod.Id]; ok {
-				return nil, status.Errorf(codes.AlreadyExists, "family %q already exists", mod.Id)
-			}
-			newcf := &columnFamily{
-				name:   req.Name + "/columnFamilies/" + mod.Id,
-				order:  tbl.counter,
-				gcRule: create.GcRule,
-			}
-			tbl.counter++
-			tbl.families[mod.Id] = newcf
-		} else if mod.GetDrop() {
-			if _, ok := tbl.families[mod.Id]; !ok {
-				return nil, fmt.Errorf("can't delete unknown family %q", mod.Id)
-			}
-			delete(tbl.families, mod.Id)
-		} else if modify := mod.GetUpdate(); modify != nil {
-			if _, ok := tbl.families[mod.Id]; !ok {
-				return nil, fmt.Errorf("no such family %q", mod.Id)
-			}
-			newcf := &columnFamily{
-				name:   req.Name + "/columnFamilies/" + mod.Id,
-				gcRule: modify.GcRule,
-			}
-			// assume that we ALWAYS want to replace by the new setting
-			// we may need partial update through
-			tbl.families[mod.Id] = newcf
-		}
-	}
-
-	s.needGC()
-	return &btapb.Table{
-		Name:           req.Name,
-		ColumnFamilies: toColumnFamilies(tbl.families),
-		Granularity:    btapb.Table_TimestampGranularity(btapb.Table_MILLIS),
-	}, nil
-}
-
-func (s *server) DropRowRange(ctx context.Context, req *btapb.DropRowRangeRequest) (*emptypb.Empty, error) {
-	s.mu.Lock()
-	defer s.mu.Unlock()
-	tbl, ok := s.tables[req.Name]
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.Name)
-	}
-
-	if req.GetDeleteAllDataFromTable() {
-		tbl.rows = btree.New(btreeDegree)
-	} else {
-		// Delete rows by prefix.
-		prefixBytes := req.GetRowKeyPrefix()
-		if prefixBytes == nil {
-			return nil, fmt.Errorf("missing row key prefix")
-		}
-		prefix := string(prefixBytes)
-
-		// The BTree does not specify what happens if rows are deleted during
-		// iteration, and it provides no "delete range" method.
-		// So we collect the rows first, then delete them one by one.
-		var rowsToDelete []*row
-		tbl.rows.AscendGreaterOrEqual(btreeKey(prefix), func(i btree.Item) bool {
-			r := i.(*row)
-			if strings.HasPrefix(r.key, prefix) {
-				rowsToDelete = append(rowsToDelete, r)
-				return true
-			}
-			return false // stop iteration
-		})
-		for _, r := range rowsToDelete {
-			tbl.rows.Delete(r)
-		}
-	}
-	return &emptypb.Empty{}, nil
-}
-
-func (s *server) GenerateConsistencyToken(ctx context.Context, req *btapb.GenerateConsistencyTokenRequest) (*btapb.GenerateConsistencyTokenResponse, error) {
-	// Check that the table exists.
-	_, ok := s.tables[req.Name]
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.Name)
-	}
-
-	return &btapb.GenerateConsistencyTokenResponse{
-		ConsistencyToken: "TokenFor-" + req.Name,
-	}, nil
-}
-
-func (s *server) CheckConsistency(ctx context.Context, req *btapb.CheckConsistencyRequest) (*btapb.CheckConsistencyResponse, error) {
-	// Check that the table exists.
-	_, ok := s.tables[req.Name]
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.Name)
-	}
-
-	// Check this is the right token.
-	if req.ConsistencyToken != "TokenFor-"+req.Name {
-		return nil, status.Errorf(codes.InvalidArgument, "token %q not valid", req.ConsistencyToken)
-	}
-
-	// Single cluster instances are always consistent.
-	return &btapb.CheckConsistencyResponse{
-		Consistent: true,
-	}, nil
-}
-
-func (s *server) SnapshotTable(context.Context, *btapb.SnapshotTableRequest) (*longrunning.Operation, error) {
-	return nil, status.Errorf(codes.Unimplemented, "the emulator does not currently support snapshots")
-}
-
-func (s *server) GetSnapshot(context.Context, *btapb.GetSnapshotRequest) (*btapb.Snapshot, error) {
-	return nil, status.Errorf(codes.Unimplemented, "the emulator does not currently support snapshots")
-}
-func (s *server) ListSnapshots(context.Context, *btapb.ListSnapshotsRequest) (*btapb.ListSnapshotsResponse, error) {
-	return nil, status.Errorf(codes.Unimplemented, "the emulator does not currently support snapshots")
-}
-func (s *server) DeleteSnapshot(context.Context, *btapb.DeleteSnapshotRequest) (*emptypb.Empty, error) {
-	return nil, status.Errorf(codes.Unimplemented, "the emulator does not currently support snapshots")
-}
-
-func (s *server) ReadRows(req *btpb.ReadRowsRequest, stream btpb.Bigtable_ReadRowsServer) error {
-	s.mu.Lock()
-	tbl, ok := s.tables[req.TableName]
-	s.mu.Unlock()
-	if !ok {
-		return status.Errorf(codes.NotFound, "table %q not found", req.TableName)
-	}
-
-	// Rows to read can be specified by a set of row keys and/or a set of row ranges.
-	// Output is a stream of sorted, de-duped rows.
-	tbl.mu.RLock()
-	rowSet := make(map[string]*row)
-
-	addRow := func(i btree.Item) bool {
-		r := i.(*row)
-		rowSet[r.key] = r
-		return true
-	}
-
-	if req.Rows != nil &&
-		len(req.Rows.RowKeys)+len(req.Rows.RowRanges) > 0 {
-		// Add the explicitly given keys
-		for _, key := range req.Rows.RowKeys {
-			k := string(key)
-			if i := tbl.rows.Get(btreeKey(k)); i != nil {
-				addRow(i)
-			}
-		}
-
-		// Add keys from row ranges
-		for _, rr := range req.Rows.RowRanges {
-			var start, end string
-			switch sk := rr.StartKey.(type) {
-			case *btpb.RowRange_StartKeyClosed:
-				start = string(sk.StartKeyClosed)
-			case *btpb.RowRange_StartKeyOpen:
-				start = string(sk.StartKeyOpen) + "\x00"
-			}
-			switch ek := rr.EndKey.(type) {
-			case *btpb.RowRange_EndKeyClosed:
-				end = string(ek.EndKeyClosed) + "\x00"
-			case *btpb.RowRange_EndKeyOpen:
-				end = string(ek.EndKeyOpen)
-			}
-			switch {
-			case start == "" && end == "":
-				tbl.rows.Ascend(addRow) // all rows
-			case start == "":
-				tbl.rows.AscendLessThan(btreeKey(end), addRow)
-			case end == "":
-				tbl.rows.AscendGreaterOrEqual(btreeKey(start), addRow)
-			default:
-				tbl.rows.AscendRange(btreeKey(start), btreeKey(end), addRow)
-			}
-		}
-	} else {
-		// Read all rows
-		tbl.rows.Ascend(addRow)
-	}
-	tbl.mu.RUnlock()
-
-	rows := make([]*row, 0, len(rowSet))
-	for _, r := range rowSet {
-		r.mu.Lock()
-		fams := len(r.families)
-		r.mu.Unlock()
-
-		if fams != 0 {
-			rows = append(rows, r)
-		}
-	}
-	sort.Sort(byRowKey(rows))
-
-	limit := int(req.RowsLimit)
-	count := 0
-	for _, r := range rows {
-		if limit > 0 && count >= limit {
-			return nil
-		}
-		streamed, err := streamRow(stream, r, req.Filter)
-		if err != nil {
-			return err
-		}
-		if streamed {
-			count++
-		}
-	}
-	return nil
-}
-
-// streamRow filters the given row and sends it via the given stream.
-// Returns true if at least one cell matched the filter and was streamed, false otherwise.
-func streamRow(stream btpb.Bigtable_ReadRowsServer, r *row, f *btpb.RowFilter) (bool, error) {
-	r.mu.Lock()
-	nr := r.copy()
-	r.mu.Unlock()
-	r = nr
-
-	match, err := filterRow(f, r)
-	if err != nil {
-		return false, err
-	}
-	if !match {
-		return false, nil
-	}
-
-	rrr := &btpb.ReadRowsResponse{}
-	families := r.sortedFamilies()
-	for _, fam := range families {
-		for _, colName := range fam.colNames {
-			cells := fam.cells[colName]
-			if len(cells) == 0 {
-				continue
-			}
-			for _, cell := range cells {
-				rrr.Chunks = append(rrr.Chunks, &btpb.ReadRowsResponse_CellChunk{
-					RowKey:          []byte(r.key),
-					FamilyName:      &wrappers.StringValue{Value: fam.name},
-					Qualifier:       &wrappers.BytesValue{Value: []byte(colName)},
-					TimestampMicros: cell.ts,
-					Value:           cell.value,
-					Labels:          cell.labels,
-				})
-			}
-		}
-	}
-	// We can't have a cell with just COMMIT set, which would imply a new empty cell.
-	// So modify the last cell to have the COMMIT flag set.
-	if len(rrr.Chunks) > 0 {
-		rrr.Chunks[len(rrr.Chunks)-1].RowStatus = &btpb.ReadRowsResponse_CellChunk_CommitRow{CommitRow: true}
-	}
-
-	return true, stream.Send(rrr)
-}
-
-// filterRow modifies a row with the given filter. Returns true if at least one cell from the row matches,
-// false otherwise. If a filter is invalid, filterRow returns false and an error.
-func filterRow(f *btpb.RowFilter, r *row) (bool, error) {
-	if f == nil {
-		return true, nil
-	}
-	// Handle filters that apply beyond just including/excluding cells.
-	switch f := f.Filter.(type) {
-	case *btpb.RowFilter_BlockAllFilter:
-		return !f.BlockAllFilter, nil
-	case *btpb.RowFilter_PassAllFilter:
-		return f.PassAllFilter, nil
-	case *btpb.RowFilter_Chain_:
-		for _, sub := range f.Chain.Filters {
-			match, err := filterRow(sub, r)
-			if err != nil {
-				return false, err
-			}
-			if !match {
-				return false, nil
-			}
-		}
-		return true, nil
-	case *btpb.RowFilter_Interleave_:
-		srs := make([]*row, 0, len(f.Interleave.Filters))
-		for _, sub := range f.Interleave.Filters {
-			sr := r.copy()
-			filterRow(sub, sr)
-			srs = append(srs, sr)
-		}
-		// merge
-		// TODO(dsymonds): is this correct?
-		r.families = make(map[string]*family)
-		for _, sr := range srs {
-			for _, fam := range sr.families {
-				f := r.getOrCreateFamily(fam.name, fam.order)
-				for colName, cs := range fam.cells {
-					f.cells[colName] = append(f.cellsByColumn(colName), cs...)
-				}
-			}
-		}
-		var count int
-		for _, fam := range r.families {
-			for _, cs := range fam.cells {
-				sort.Sort(byDescTS(cs))
-				count += len(cs)
-			}
-		}
-		return count > 0, nil
-	case *btpb.RowFilter_CellsPerColumnLimitFilter:
-		lim := int(f.CellsPerColumnLimitFilter)
-		for _, fam := range r.families {
-			for col, cs := range fam.cells {
-				if len(cs) > lim {
-					fam.cells[col] = cs[:lim]
-				}
-			}
-		}
-		return true, nil
-	case *btpb.RowFilter_Condition_:
-		match, err := filterRow(f.Condition.PredicateFilter, r.copy())
-		if err != nil {
-			return false, err
-		}
-		if match {
-			if f.Condition.TrueFilter == nil {
-				return false, nil
-			}
-			return filterRow(f.Condition.TrueFilter, r)
-		}
-		if f.Condition.FalseFilter == nil {
-			return false, nil
-		}
-		return filterRow(f.Condition.FalseFilter, r)
-	case *btpb.RowFilter_RowKeyRegexFilter:
-		rx, err := newRegexp(f.RowKeyRegexFilter)
-		if err != nil {
-			return false, status.Errorf(codes.InvalidArgument, "Error in field 'rowkey_regex_filter' : %v", err)
-		}
-		if !rx.MatchString(r.key) {
-			return false, nil
-		}
-	case *btpb.RowFilter_CellsPerRowLimitFilter:
-		// Grab the first n cells in the row.
-		lim := int(f.CellsPerRowLimitFilter)
-		for _, fam := range r.families {
-			for _, col := range fam.colNames {
-				cs := fam.cells[col]
-				if len(cs) > lim {
-					fam.cells[col] = cs[:lim]
-					lim = 0
-				} else {
-					lim -= len(cs)
-				}
-			}
-		}
-		return true, nil
-	case *btpb.RowFilter_CellsPerRowOffsetFilter:
-		// Skip the first n cells in the row.
-		offset := int(f.CellsPerRowOffsetFilter)
-		for _, fam := range r.families {
-			for _, col := range fam.colNames {
-				cs := fam.cells[col]
-				if len(cs) > offset {
-					fam.cells[col] = cs[offset:]
-					offset = 0
-					return true, nil
-				}
-				fam.cells[col] = cs[:0]
-				offset -= len(cs)
-			}
-		}
-		return true, nil
-	case *btpb.RowFilter_RowSampleFilter:
-		// The row sample filter "matches all cells from a row with probability
-		// p, and matches no cells from the row with probability 1-p."
-		// See https://github.com/googleapis/googleapis/blob/master/google/bigtable/v2/data.proto
-		if f.RowSampleFilter <= 0.0 || f.RowSampleFilter >= 1.0 {
-			return false, status.Error(codes.InvalidArgument, "row_sample_filter argument must be between 0.0 and 1.0")
-		}
-		return randFloat() < f.RowSampleFilter, nil
-	}
-
-	// Any other case, operate on a per-cell basis.
-	cellCount := 0
-	for _, fam := range r.families {
-		for colName, cs := range fam.cells {
-			filtered, err := filterCells(f, fam.name, colName, cs)
-			if err != nil {
-				return false, err
-			}
-			fam.cells[colName] = filtered
-			cellCount += len(fam.cells[colName])
-		}
-	}
-	return cellCount > 0, nil
-}
-
-var randFloat = rand.Float64
-
-func filterCells(f *btpb.RowFilter, fam, col string, cs []cell) ([]cell, error) {
-	var ret []cell
-	for _, cell := range cs {
-		include, err := includeCell(f, fam, col, cell)
-		if err != nil {
-			return nil, err
-		}
-		if include {
-			cell, err = modifyCell(f, cell)
-			if err != nil {
-				return nil, err
-			}
-			ret = append(ret, cell)
-		}
-	}
-	return ret, nil
-}
-
-func modifyCell(f *btpb.RowFilter, c cell) (cell, error) {
-	if f == nil {
-		return c, nil
-	}
-	// Consider filters that may modify the cell contents
-	switch filter := f.Filter.(type) {
-	case *btpb.RowFilter_StripValueTransformer:
-		return cell{ts: c.ts}, nil
-	case *btpb.RowFilter_ApplyLabelTransformer:
-		if !validLabelTransformer.MatchString(filter.ApplyLabelTransformer) {
-			return cell{}, status.Errorf(
-				codes.InvalidArgument,
-				`apply_label_transformer must match RE2([a-z0-9\-]+), but found %v`,
-				filter.ApplyLabelTransformer,
-			)
-		}
-		return cell{ts: c.ts, value: c.value, labels: []string{filter.ApplyLabelTransformer}}, nil
-	default:
-		return c, nil
-	}
-}
-
-func includeCell(f *btpb.RowFilter, fam, col string, cell cell) (bool, error) {
-	if f == nil {
-		return true, nil
-	}
-	// TODO(dsymonds): Implement many more filters.
-	switch f := f.Filter.(type) {
-	case *btpb.RowFilter_CellsPerColumnLimitFilter:
-		// Don't log, row-level filter
-		return true, nil
-	case *btpb.RowFilter_RowKeyRegexFilter:
-		// Don't log, row-level filter
-		return true, nil
-	case *btpb.RowFilter_StripValueTransformer:
-		// Don't log, cell-modifying filter
-		return true, nil
-	case *btpb.RowFilter_ApplyLabelTransformer:
-		// Don't log, cell-modifying filter
-		return true, nil
-	default:
-		log.Printf("WARNING: don't know how to handle filter of type %T (ignoring it)", f)
-		return true, nil
-	case *btpb.RowFilter_FamilyNameRegexFilter:
-		rx, err := newRegexp([]byte(f.FamilyNameRegexFilter))
-		if err != nil {
-			return false, status.Errorf(codes.InvalidArgument, "Error in field 'family_name_regex_filter' : %v", err)
-		}
-		return rx.MatchString(fam), nil
-	case *btpb.RowFilter_ColumnQualifierRegexFilter:
-		rx, err := newRegexp(f.ColumnQualifierRegexFilter)
-		if err != nil {
-			return false, status.Errorf(codes.InvalidArgument, "Error in field 'column_qualifier_regex_filter' : %v", err)
-		}
-		return rx.MatchString(toUTF8([]byte(col))), nil
-	case *btpb.RowFilter_ValueRegexFilter:
-		rx, err := newRegexp(f.ValueRegexFilter)
-		if err != nil {
-			return false, status.Errorf(codes.InvalidArgument, "Error in field 'value_regex_filter' : %v", err)
-		}
-		return rx.Match(cell.value), nil
-	case *btpb.RowFilter_ColumnRangeFilter:
-		if fam != f.ColumnRangeFilter.FamilyName {
-			return false, nil
-		}
-		// Start qualifier defaults to empty string closed
-		inRangeStart := func() bool { return col >= "" }
-		switch sq := f.ColumnRangeFilter.StartQualifier.(type) {
-		case *btpb.ColumnRange_StartQualifierOpen:
-			inRangeStart = func() bool { return col > string(sq.StartQualifierOpen) }
-		case *btpb.ColumnRange_StartQualifierClosed:
-			inRangeStart = func() bool { return col >= string(sq.StartQualifierClosed) }
-		}
-		// End qualifier defaults to no upper boundary
-		inRangeEnd := func() bool { return true }
-		switch eq := f.ColumnRangeFilter.EndQualifier.(type) {
-		case *btpb.ColumnRange_EndQualifierClosed:
-			inRangeEnd = func() bool { return col <= string(eq.EndQualifierClosed) }
-		case *btpb.ColumnRange_EndQualifierOpen:
-			inRangeEnd = func() bool { return col < string(eq.EndQualifierOpen) }
-		}
-		return inRangeStart() && inRangeEnd(), nil
-	case *btpb.RowFilter_TimestampRangeFilter:
-		// Lower bound is inclusive and defaults to 0, upper bound is exclusive and defaults to infinity.
-		return cell.ts >= f.TimestampRangeFilter.StartTimestampMicros &&
-			(f.TimestampRangeFilter.EndTimestampMicros == 0 || cell.ts < f.TimestampRangeFilter.EndTimestampMicros), nil
-	case *btpb.RowFilter_ValueRangeFilter:
-		v := cell.value
-		// Start value defaults to empty string closed
-		inRangeStart := func() bool { return bytes.Compare(v, []byte{}) >= 0 }
-		switch sv := f.ValueRangeFilter.StartValue.(type) {
-		case *btpb.ValueRange_StartValueOpen:
-			inRangeStart = func() bool { return bytes.Compare(v, sv.StartValueOpen) > 0 }
-		case *btpb.ValueRange_StartValueClosed:
-			inRangeStart = func() bool { return bytes.Compare(v, sv.StartValueClosed) >= 0 }
-		}
-		// End value defaults to no upper boundary
-		inRangeEnd := func() bool { return true }
-		switch ev := f.ValueRangeFilter.EndValue.(type) {
-		case *btpb.ValueRange_EndValueClosed:
-			inRangeEnd = func() bool { return bytes.Compare(v, ev.EndValueClosed) <= 0 }
-		case *btpb.ValueRange_EndValueOpen:
-			inRangeEnd = func() bool { return bytes.Compare(v, ev.EndValueOpen) < 0 }
-		}
-		return inRangeStart() && inRangeEnd(), nil
-	}
-}
-
-func toUTF8(bs []byte) string {
-	var rs []rune
-	for _, b := range bs {
-		rs = append(rs, rune(b))
-	}
-	return string(rs)
-}
-
-func newRegexp(patBytes []byte) (*regexp.Regexp, error) {
-	pat := toUTF8(patBytes)
-	re, err := regexp.Compile("^" + pat + "$") // match entire target
-	if err != nil {
-		log.Printf("Bad pattern %q: %v", pat, err)
-	}
-	return re, err
-}
-
-func (s *server) MutateRow(ctx context.Context, req *btpb.MutateRowRequest) (*btpb.MutateRowResponse, error) {
-	s.mu.Lock()
-	tbl, ok := s.tables[req.TableName]
-	s.mu.Unlock()
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.TableName)
-	}
-	fs := tbl.columnFamilies()
-	r := tbl.mutableRow(string(req.RowKey))
-	r.mu.Lock()
-	defer r.mu.Unlock()
-	if err := applyMutations(tbl, r, req.Mutations, fs); err != nil {
-		return nil, err
-	}
-	return &btpb.MutateRowResponse{}, nil
-}
-
-func (s *server) MutateRows(req *btpb.MutateRowsRequest, stream btpb.Bigtable_MutateRowsServer) error {
-	s.mu.Lock()
-	tbl, ok := s.tables[req.TableName]
-	s.mu.Unlock()
-	if !ok {
-		return status.Errorf(codes.NotFound, "table %q not found", req.TableName)
-	}
-	res := &btpb.MutateRowsResponse{Entries: make([]*btpb.MutateRowsResponse_Entry, len(req.Entries))}
-
-	fs := tbl.columnFamilies()
-
-	for i, entry := range req.Entries {
-		r := tbl.mutableRow(string(entry.RowKey))
-		r.mu.Lock()
-		code, msg := int32(codes.OK), ""
-		if err := applyMutations(tbl, r, entry.Mutations, fs); err != nil {
-			code = int32(codes.Internal)
-			msg = err.Error()
-		}
-		res.Entries[i] = &btpb.MutateRowsResponse_Entry{
-			Index:  int64(i),
-			Status: &statpb.Status{Code: code, Message: msg},
-		}
-		r.mu.Unlock()
-	}
-	return stream.Send(res)
-}
-
-func (s *server) CheckAndMutateRow(ctx context.Context, req *btpb.CheckAndMutateRowRequest) (*btpb.CheckAndMutateRowResponse, error) {
-	s.mu.Lock()
-	tbl, ok := s.tables[req.TableName]
-	s.mu.Unlock()
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.TableName)
-	}
-	res := &btpb.CheckAndMutateRowResponse{}
-
-	fs := tbl.columnFamilies()
-
-	r := tbl.mutableRow(string(req.RowKey))
-	r.mu.Lock()
-	defer r.mu.Unlock()
-
-	// Figure out which mutation to apply.
-	whichMut := false
-	if req.PredicateFilter == nil {
-		// Use true_mutations iff row contains any cells.
-		whichMut = !r.isEmpty()
-	} else {
-		// Use true_mutations iff any cells in the row match the filter.
-		// TODO(dsymonds): This could be cheaper.
-		nr := r.copy()
-		filterRow(req.PredicateFilter, nr)
-		whichMut = !nr.isEmpty()
-	}
-	res.PredicateMatched = whichMut
-	muts := req.FalseMutations
-	if whichMut {
-		muts = req.TrueMutations
-	}
-
-	if err := applyMutations(tbl, r, muts, fs); err != nil {
-		return nil, err
-	}
-	return res, nil
-}
-
-// applyMutations applies a sequence of mutations to a row.
-// fam should be a snapshot of the keys of tbl.families.
-// It assumes r.mu is locked.
-func applyMutations(tbl *table, r *row, muts []*btpb.Mutation, fs map[string]*columnFamily) error {
-	for _, mut := range muts {
-		switch mut := mut.Mutation.(type) {
-		default:
-			return fmt.Errorf("can't handle mutation type %T", mut)
-		case *btpb.Mutation_SetCell_:
-			set := mut.SetCell
-			if _, ok := fs[set.FamilyName]; !ok {
-				return fmt.Errorf("unknown family %q", set.FamilyName)
-			}
-			ts := set.TimestampMicros
-			if ts == -1 { // bigtable.ServerTime
-				ts = newTimestamp()
-			}
-			if !tbl.validTimestamp(ts) {
-				return fmt.Errorf("invalid timestamp %d", ts)
-			}
-			fam := set.FamilyName
-			col := string(set.ColumnQualifier)
-
-			newCell := cell{ts: ts, value: set.Value}
-			f := r.getOrCreateFamily(fam, fs[fam].order)
-			f.cells[col] = appendOrReplaceCell(f.cellsByColumn(col), newCell)
-		case *btpb.Mutation_DeleteFromColumn_:
-			del := mut.DeleteFromColumn
-			if _, ok := fs[del.FamilyName]; !ok {
-				return fmt.Errorf("unknown family %q", del.FamilyName)
-			}
-			fam := del.FamilyName
-			col := string(del.ColumnQualifier)
-			if _, ok := r.families[fam]; ok {
-				cs := r.families[fam].cells[col]
-				if del.TimeRange != nil {
-					tsr := del.TimeRange
-					if !tbl.validTimestamp(tsr.StartTimestampMicros) {
-						return fmt.Errorf("invalid timestamp %d", tsr.StartTimestampMicros)
-					}
-					if !tbl.validTimestamp(tsr.EndTimestampMicros) && tsr.EndTimestampMicros != 0 {
-						return fmt.Errorf("invalid timestamp %d", tsr.EndTimestampMicros)
-					}
-					if tsr.StartTimestampMicros >= tsr.EndTimestampMicros && tsr.EndTimestampMicros != 0 {
-						return fmt.Errorf("inverted or invalid timestamp range [%d, %d]", tsr.StartTimestampMicros, tsr.EndTimestampMicros)
-					}
-
-					// Find half-open interval to remove.
-					// Cells are in descending timestamp order,
-					// so the predicates to sort.Search are inverted.
-					si, ei := 0, len(cs)
-					if tsr.StartTimestampMicros > 0 {
-						ei = sort.Search(len(cs), func(i int) bool { return cs[i].ts < tsr.StartTimestampMicros })
-					}
-					if tsr.EndTimestampMicros > 0 {
-						si = sort.Search(len(cs), func(i int) bool { return cs[i].ts < tsr.EndTimestampMicros })
-					}
-					if si < ei {
-						copy(cs[si:], cs[ei:])
-						cs = cs[:len(cs)-(ei-si)]
-					}
-				} else {
-					cs = nil
-				}
-				if len(cs) == 0 {
-					delete(r.families[fam].cells, col)
-					colNames := r.families[fam].colNames
-					i := sort.Search(len(colNames), func(i int) bool { return colNames[i] >= col })
-					if i < len(colNames) && colNames[i] == col {
-						r.families[fam].colNames = append(colNames[:i], colNames[i+1:]...)
-					}
-					if len(r.families[fam].cells) == 0 {
-						delete(r.families, fam)
-					}
-				} else {
-					r.families[fam].cells[col] = cs
-				}
-			}
-		case *btpb.Mutation_DeleteFromRow_:
-			r.families = make(map[string]*family)
-		case *btpb.Mutation_DeleteFromFamily_:
-			fampre := mut.DeleteFromFamily.FamilyName
-			delete(r.families, fampre)
-		}
-	}
-	return nil
-}
-
-func maxTimestamp(x, y int64) int64 {
-	if x > y {
-		return x
-	}
-	return y
-}
-
-func newTimestamp() int64 {
-	ts := time.Now().UnixNano() / 1e3
-	ts -= ts % 1000 // round to millisecond granularity
-	return ts
-}
-
-func appendOrReplaceCell(cs []cell, newCell cell) []cell {
-	replaced := false
-	for i, cell := range cs {
-		if cell.ts == newCell.ts {
-			cs[i] = newCell
-			replaced = true
-			break
-		}
-	}
-	if !replaced {
-		cs = append(cs, newCell)
-	}
-	sort.Sort(byDescTS(cs))
-	return cs
-}
-
-func (s *server) ReadModifyWriteRow(ctx context.Context, req *btpb.ReadModifyWriteRowRequest) (*btpb.ReadModifyWriteRowResponse, error) {
-	s.mu.Lock()
-	tbl, ok := s.tables[req.TableName]
-	s.mu.Unlock()
-	if !ok {
-		return nil, status.Errorf(codes.NotFound, "table %q not found", req.TableName)
-	}
-
-	fs := tbl.columnFamilies()
-
-	rowKey := string(req.RowKey)
-	r := tbl.mutableRow(rowKey)
-	resultRow := newRow(rowKey) // copy of updated cells
-
-	// This must be done before the row lock, acquired below, is released.
-	r.mu.Lock()
-	defer r.mu.Unlock()
-	// Assume all mutations apply to the most recent version of the cell.
-	// TODO(dsymonds): Verify this assumption and document it in the proto.
-	for _, rule := range req.Rules {
-		if _, ok := fs[rule.FamilyName]; !ok {
-			return nil, fmt.Errorf("unknown family %q", rule.FamilyName)
-		}
-
-		fam := rule.FamilyName
-		col := string(rule.ColumnQualifier)
-		isEmpty := false
-		f := r.getOrCreateFamily(fam, fs[fam].order)
-		cs := f.cells[col]
-		isEmpty = len(cs) == 0
-
-		ts := newTimestamp()
-		var newCell, prevCell cell
-		if !isEmpty {
-			cells := r.families[fam].cells[col]
-			prevCell = cells[0]
-
-			// ts is the max of now or the prev cell's timestamp in case the
-			// prev cell is in the future
-			ts = maxTimestamp(ts, prevCell.ts)
-		}
-
-		switch rule := rule.Rule.(type) {
-		default:
-			return nil, fmt.Errorf("unknown RMW rule oneof %T", rule)
-		case *btpb.ReadModifyWriteRule_AppendValue:
-			newCell = cell{ts: ts, value: append(prevCell.value, rule.AppendValue...)}
-		case *btpb.ReadModifyWriteRule_IncrementAmount:
-			var v int64
-			if !isEmpty {
-				prevVal := prevCell.value
-				if len(prevVal) != 8 {
-					return nil, fmt.Errorf("increment on non-64-bit value")
-				}
-				v = int64(binary.BigEndian.Uint64(prevVal))
-			}
-			v += rule.IncrementAmount
-			var val [8]byte
-			binary.BigEndian.PutUint64(val[:], uint64(v))
-			newCell = cell{ts: ts, value: val[:]}
-		}
-
-		// Store the new cell
-		f.cells[col] = appendOrReplaceCell(f.cellsByColumn(col), newCell)
-
-		// Store a copy for the result row
-		resultFamily := resultRow.getOrCreateFamily(fam, fs[fam].order)
-		resultFamily.cellsByColumn(col)           // create the column
-		resultFamily.cells[col] = []cell{newCell} // overwrite the cells
-	}
-
-	// Build the response using the result row
-	res := &btpb.Row{
-		Key:      req.RowKey,
-		Families: make([]*btpb.Family, len(resultRow.families)),
-	}
-
-	for i, family := range resultRow.sortedFamilies() {
-		res.Families[i] = &btpb.Family{
-			Name:    family.name,
-			Columns: make([]*btpb.Column, len(family.colNames)),
-		}
-
-		for j, colName := range family.colNames {
-			res.Families[i].Columns[j] = &btpb.Column{
-				Qualifier: []byte(colName),
-				Cells: []*btpb.Cell{{
-					TimestampMicros: family.cells[colName][0].ts,
-					Value:           family.cells[colName][0].value,
-				}},
-			}
-		}
-	}
-	return &btpb.ReadModifyWriteRowResponse{Row: res}, nil
-}
-
-func (s *server) SampleRowKeys(req *btpb.SampleRowKeysRequest, stream btpb.Bigtable_SampleRowKeysServer) error {
-	s.mu.Lock()
-	tbl, ok := s.tables[req.TableName]
-	s.mu.Unlock()
-	if !ok {
-		return status.Errorf(codes.NotFound, "table %q not found", req.TableName)
-	}
-
-	tbl.mu.RLock()
-	defer tbl.mu.RUnlock()
-
-	// The return value of SampleRowKeys is very loosely defined. Return at least the
-	// final row key in the table and choose other row keys randomly.
-	var offset int64
-	var err error
-	i := 0
-	tbl.rows.Ascend(func(it btree.Item) bool {
-		row := it.(*row)
-		if i == tbl.rows.Len()-1 || rand.Int31n(100) == 0 {
-			resp := &btpb.SampleRowKeysResponse{
-				RowKey:      []byte(row.key),
-				OffsetBytes: offset,
-			}
-			err = stream.Send(resp)
-			if err != nil {
-				return false
-			}
-		}
-		offset += int64(row.size())
-		i++
-		return true
-	})
-	return err
-}
-
-// needGC is invoked whenever the server needs gcloop running.
-func (s *server) needGC() {
-	s.mu.Lock()
-	if s.gcc == nil {
-		s.gcc = make(chan int)
-		go s.gcloop(s.gcc)
-	}
-	s.mu.Unlock()
-}
-
-func (s *server) gcloop(done <-chan int) {
-	const (
-		minWait = 500  // ms
-		maxWait = 1500 // ms
-	)
-
-	for {
-		// Wait for a random time interval.
-		d := time.Duration(minWait+rand.Intn(maxWait-minWait)) * time.Millisecond
-		select {
-		case <-time.After(d):
-		case <-done:
-			return // server has been closed
-		}
-
-		// Do a GC pass over all tables.
-		var tables []*table
-		s.mu.Lock()
-		for _, tbl := range s.tables {
-			tables = append(tables, tbl)
-		}
-		s.mu.Unlock()
-		for _, tbl := range tables {
-			tbl.gc()
-		}
-	}
-}
-
-type table struct {
-	mu       sync.RWMutex
-	counter  uint64                   // increment by 1 when a new family is created
-	families map[string]*columnFamily // keyed by plain family name
-	rows     *btree.BTree             // indexed by row key
-}
-
-const btreeDegree = 16
-
-func newTable(ctr *btapb.CreateTableRequest) *table {
-	fams := make(map[string]*columnFamily)
-	c := uint64(0)
-	if ctr.Table != nil {
-		for id, cf := range ctr.Table.ColumnFamilies {
-			fams[id] = &columnFamily{
-				name:   ctr.Parent + "/columnFamilies/" + id,
-				order:  c,
-				gcRule: cf.GcRule,
-			}
-			c++
-		}
-	}
-	return &table{
-		families: fams,
-		counter:  c,
-		rows:     btree.New(btreeDegree),
-	}
-}
-
-func (t *table) validTimestamp(ts int64) bool {
-	if ts < minValidMilliSeconds || ts > maxValidMilliSeconds {
-		return false
-	}
-
-	// Assume millisecond granularity is required.
-	return ts%1000 == 0
-}
-
-func (t *table) columnFamilies() map[string]*columnFamily {
-	cp := make(map[string]*columnFamily)
-	t.mu.RLock()
-	for fam, cf := range t.families {
-		cp[fam] = cf
-	}
-	t.mu.RUnlock()
-	return cp
-}
-
-func (t *table) mutableRow(key string) *row {
-	bkey := btreeKey(key)
-	// Try fast path first.
-	t.mu.RLock()
-	i := t.rows.Get(bkey)
-	t.mu.RUnlock()
-	if i != nil {
-		return i.(*row)
-	}
-
-	// We probably need to create the row.
-	t.mu.Lock()
-	defer t.mu.Unlock()
-	i = t.rows.Get(bkey)
-	if i != nil {
-		return i.(*row)
-	}
-	r := newRow(key)
-	t.rows.ReplaceOrInsert(r)
-	return r
-}
-
-func (t *table) gc() {
-	// This method doesn't add or remove rows, so we only need a read lock for the table.
-	t.mu.RLock()
-	defer t.mu.RUnlock()
-
-	// Gather GC rules we'll apply.
-	rules := make(map[string]*btapb.GcRule) // keyed by "fam"
-	for fam, cf := range t.families {
-		if cf.gcRule != nil {
-			rules[fam] = cf.gcRule
-		}
-	}
-	if len(rules) == 0 {
-		return
-	}
-
-	t.rows.Ascend(func(i btree.Item) bool {
-		r := i.(*row)
-		r.mu.Lock()
-		r.gc(rules)
-		r.mu.Unlock()
-		return true
-	})
-}
-
-type byRowKey []*row
-
-func (b byRowKey) Len() int           { return len(b) }
-func (b byRowKey) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
-func (b byRowKey) Less(i, j int) bool { return b[i].key < b[j].key }
-
-type row struct {
-	key string
-
-	mu       sync.Mutex
-	families map[string]*family // keyed by family name
-}
-
-func newRow(key string) *row {
-	return &row{
-		key:      key,
-		families: make(map[string]*family),
-	}
-}
-
-// copy returns a copy of the row.
-// Cell values are aliased.
-// r.mu should be held.
-func (r *row) copy() *row {
-	nr := newRow(r.key)
-	for _, fam := range r.families {
-		nr.families[fam.name] = &family{
-			name:     fam.name,
-			order:    fam.order,
-			colNames: fam.colNames,
-			cells:    make(map[string][]cell),
-		}
-		for col, cs := range fam.cells {
-			// Copy the []cell slice, but not the []byte inside each cell.
-			nr.families[fam.name].cells[col] = append([]cell(nil), cs...)
-		}
-	}
-	return nr
-}
-
-// isEmpty returns true if a row doesn't contain any cell
-func (r *row) isEmpty() bool {
-	for _, fam := range r.families {
-		for _, cs := range fam.cells {
-			if len(cs) > 0 {
-				return false
-			}
-		}
-	}
-	return true
-}
-
-// sortedFamilies returns a column family set
-// sorted in ascending creation order in a row.
-func (r *row) sortedFamilies() []*family {
-	var families []*family
-	for _, fam := range r.families {
-		families = append(families, fam)
-	}
-	sort.Sort(byCreationOrder(families))
-	return families
-}
-
-func (r *row) getOrCreateFamily(name string, order uint64) *family {
-	if _, ok := r.families[name]; !ok {
-		r.families[name] = &family{
-			name:  name,
-			order: order,
-			cells: make(map[string][]cell),
-		}
-	}
-	return r.families[name]
-}
-
-// gc applies the given GC rules to the row.
-// r.mu should be held.
-func (r *row) gc(rules map[string]*btapb.GcRule) {
-	for _, fam := range r.families {
-		rule, ok := rules[fam.name]
-		if !ok {
-			continue
-		}
-		for col, cs := range fam.cells {
-			r.families[fam.name].cells[col] = applyGC(cs, rule)
-		}
-	}
-}
-
-// size returns the total size of all cell values in the row.
-func (r *row) size() int {
-	size := 0
-	for _, fam := range r.families {
-		for _, cells := range fam.cells {
-			for _, cell := range cells {
-				size += len(cell.value)
-			}
-		}
-	}
-	return size
-}
-
-// Less implements btree.Less.
-func (r *row) Less(i btree.Item) bool {
-	return r.key < i.(*row).key
-}
-
-// btreeKey returns a row for use as a key into the BTree.
-func btreeKey(s string) *row { return &row{key: s} }
-
-func (r *row) String() string {
-	return r.key
-}
-
-var gcTypeWarn sync.Once
-
-// applyGC applies the given GC rule to the cells.
-func applyGC(cells []cell, rule *btapb.GcRule) []cell {
-	switch rule := rule.Rule.(type) {
-	default:
-		// TODO(dsymonds): Support GcRule_Intersection_
-		gcTypeWarn.Do(func() {
-			log.Printf("Unsupported GC rule type %T", rule)
-		})
-	case *btapb.GcRule_Union_:
-		for _, sub := range rule.Union.Rules {
-			cells = applyGC(cells, sub)
-		}
-		return cells
-	case *btapb.GcRule_MaxAge:
-		// Timestamps are in microseconds.
-		cutoff := time.Now().UnixNano() / 1e3
-		cutoff -= rule.MaxAge.Seconds * 1e6
-		cutoff -= int64(rule.MaxAge.Nanos) / 1e3
-		// The slice of cells in in descending timestamp order.
-		// This sort.Search will return the index of the first cell whose timestamp is chronologically before the cutoff.
-		si := sort.Search(len(cells), func(i int) bool { return cells[i].ts < cutoff })
-		if si < len(cells) {
-			log.Printf("bttest: GC MaxAge(%v) deleted %d cells.", rule.MaxAge, len(cells)-si)
-		}
-		return cells[:si]
-	case *btapb.GcRule_MaxNumVersions:
-		n := int(rule.MaxNumVersions)
-		if len(cells) > n {
-			cells = cells[:n]
-		}
-		return cells
-	}
-	return cells
-}
-
-type family struct {
-	name     string            // Column family name
-	order    uint64            // Creation order of column family
-	colNames []string          // Column names are sorted in lexicographical ascending order
-	cells    map[string][]cell // Keyed by column name; cells are in descending timestamp order
-}
-
-type byCreationOrder []*family
-
-func (b byCreationOrder) Len() int           { return len(b) }
-func (b byCreationOrder) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
-func (b byCreationOrder) Less(i, j int) bool { return b[i].order < b[j].order }
-
-// cellsByColumn adds the column name to colNames set if it does not exist
-// and returns all cells within a column
-func (f *family) cellsByColumn(name string) []cell {
-	if _, ok := f.cells[name]; !ok {
-		f.colNames = append(f.colNames, name)
-		sort.Strings(f.colNames)
-	}
-	return f.cells[name]
-}
-
-type cell struct {
-	ts     int64
-	value  []byte
-	labels []string
-}
-
-type byDescTS []cell
-
-func (b byDescTS) Len() int           { return len(b) }
-func (b byDescTS) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
-func (b byDescTS) Less(i, j int) bool { return b[i].ts > b[j].ts }
-
-type columnFamily struct {
-	name   string
-	order  uint64 // Creation order of column family
-	gcRule *btapb.GcRule
-}
-
-func (c *columnFamily) proto() *btapb.ColumnFamily {
-	return &btapb.ColumnFamily{
-		GcRule: c.gcRule,
-	}
-}
-
-func toColumnFamilies(families map[string]*columnFamily) map[string]*btapb.ColumnFamily {
-	fs := make(map[string]*btapb.ColumnFamily)
-	for k, v := range families {
-		fs[k] = v.proto()
-	}
-	return fs
-}

+ 0 - 1193
vendor/cloud.google.com/go/bigtable/bttest/inmem_test.go

@@ -1,1193 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package bttest
-
-import (
-	"context"
-	"fmt"
-	"math/rand"
-	"strconv"
-	"sync"
-	"sync/atomic"
-	"testing"
-	"time"
-
-	"github.com/golang/protobuf/proto"
-	"github.com/google/go-cmp/cmp"
-	"github.com/google/go-cmp/cmp/cmpopts"
-	btapb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
-	btpb "google.golang.org/genproto/googleapis/bigtable/v2"
-	"google.golang.org/grpc"
-)
-
-func TestConcurrentMutationsReadModifyAndGC(t *testing.T) {
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
-	defer cancel()
-	if _, err := s.CreateTable(
-		ctx,
-		&btapb.CreateTableRequest{Parent: "cluster", TableId: "t"}); err != nil {
-		t.Fatal(err)
-	}
-	const name = `cluster/tables/t`
-	tbl := s.tables[name]
-	req := &btapb.ModifyColumnFamiliesRequest{
-		Name: name,
-		Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-			Id:  "cf",
-			Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Create{Create: &btapb.ColumnFamily{}},
-		}},
-	}
-	_, err := s.ModifyColumnFamilies(ctx, req)
-	if err != nil {
-		t.Fatal(err)
-	}
-	req = &btapb.ModifyColumnFamiliesRequest{
-		Name: name,
-		Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-			Id: "cf",
-			Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Update{Update: &btapb.ColumnFamily{
-				GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}},
-			}},
-		}},
-	}
-	if _, err := s.ModifyColumnFamilies(ctx, req); err != nil {
-		t.Fatal(err)
-	}
-
-	var wg sync.WaitGroup
-	var ts int64
-	ms := func() []*btpb.Mutation {
-		return []*btpb.Mutation{{
-			Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-				FamilyName:      "cf",
-				ColumnQualifier: []byte(`col`),
-				TimestampMicros: atomic.AddInt64(&ts, 1000),
-			}},
-		}}
-	}
-
-	rmw := func() *btpb.ReadModifyWriteRowRequest {
-		return &btpb.ReadModifyWriteRowRequest{
-			TableName: name,
-			RowKey:    []byte(fmt.Sprint(rand.Intn(100))),
-			Rules: []*btpb.ReadModifyWriteRule{{
-				FamilyName:      "cf",
-				ColumnQualifier: []byte("col"),
-				Rule:            &btpb.ReadModifyWriteRule_IncrementAmount{IncrementAmount: 1},
-			}},
-		}
-	}
-	for i := 0; i < 100; i++ {
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			for ctx.Err() == nil {
-				req := &btpb.MutateRowRequest{
-					TableName: name,
-					RowKey:    []byte(fmt.Sprint(rand.Intn(100))),
-					Mutations: ms(),
-				}
-				if _, err := s.MutateRow(ctx, req); err != nil {
-					panic(err) // can't use t.Fatal in goroutine
-				}
-			}
-		}()
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			for ctx.Err() == nil {
-				_, _ = s.ReadModifyWriteRow(ctx, rmw())
-			}
-		}()
-
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			tbl.gc()
-		}()
-	}
-	done := make(chan struct{})
-	go func() {
-		wg.Wait()
-		close(done)
-	}()
-	select {
-	case <-done:
-	case <-time.After(1 * time.Second):
-		t.Error("Concurrent mutations and GCs haven't completed after 1s")
-	}
-}
-
-func TestCreateTableWithFamily(t *testing.T) {
-	// The Go client currently doesn't support creating a table with column families
-	// in one operation but it is allowed by the API. This must still be supported by the
-	// fake server so this test lives here instead of in the main bigtable
-	// integration test.
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	ctx := context.Background()
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf1": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 123}}},
-			"cf2": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 456}}},
-		},
-	}
-	cTbl, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-	tbl, err := s.GetTable(ctx, &btapb.GetTableRequest{Name: cTbl.Name})
-	if err != nil {
-		t.Fatalf("Getting table: %v", err)
-	}
-	cf := tbl.ColumnFamilies["cf1"]
-	if cf == nil {
-		t.Fatalf("Missing col family cf1")
-	}
-	if got, want := cf.GcRule.GetMaxNumVersions(), int32(123); got != want {
-		t.Errorf("Invalid MaxNumVersions: wanted:%d, got:%d", want, got)
-	}
-	cf = tbl.ColumnFamilies["cf2"]
-	if cf == nil {
-		t.Fatalf("Missing col family cf2")
-	}
-	if got, want := cf.GcRule.GetMaxNumVersions(), int32(456); got != want {
-		t.Errorf("Invalid MaxNumVersions: wanted:%d, got:%d", want, got)
-	}
-}
-
-type MockSampleRowKeysServer struct {
-	responses []*btpb.SampleRowKeysResponse
-	grpc.ServerStream
-}
-
-func (s *MockSampleRowKeysServer) Send(resp *btpb.SampleRowKeysResponse) error {
-	s.responses = append(s.responses, resp)
-	return nil
-}
-
-func TestSampleRowKeys(t *testing.T) {
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	ctx := context.Background()
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tbl, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	// Populate the table
-	val := []byte("value")
-	rowCount := 1000
-	for i := 0; i < rowCount; i++ {
-		req := &btpb.MutateRowRequest{
-			TableName: tbl.Name,
-			RowKey:    []byte("row-" + strconv.Itoa(i)),
-			Mutations: []*btpb.Mutation{{
-				Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-					FamilyName:      "cf",
-					ColumnQualifier: []byte("col"),
-					TimestampMicros: 1000,
-					Value:           val,
-				}},
-			}},
-		}
-		if _, err := s.MutateRow(ctx, req); err != nil {
-			t.Fatalf("Populating table: %v", err)
-		}
-	}
-
-	mock := &MockSampleRowKeysServer{}
-	if err := s.SampleRowKeys(&btpb.SampleRowKeysRequest{TableName: tbl.Name}, mock); err != nil {
-		t.Errorf("SampleRowKeys error: %v", err)
-	}
-	if len(mock.responses) == 0 {
-		t.Fatal("Response count: got 0, want > 0")
-	}
-	// Make sure the offset of the final response is the offset of the final row
-	got := mock.responses[len(mock.responses)-1].OffsetBytes
-	want := int64((rowCount - 1) * len(val))
-	if got != want {
-		t.Errorf("Invalid offset: got %d, want %d", got, want)
-	}
-}
-
-func TestDropRowRange(t *testing.T) {
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	ctx := context.Background()
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tblInfo, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	tbl := s.tables[tblInfo.Name]
-
-	// Populate the table
-	prefixes := []string{"AAA", "BBB", "CCC", "DDD"}
-	count := 3
-	doWrite := func() {
-		for _, prefix := range prefixes {
-			for i := 0; i < count; i++ {
-				req := &btpb.MutateRowRequest{
-					TableName: tblInfo.Name,
-					RowKey:    []byte(prefix + strconv.Itoa(i)),
-					Mutations: []*btpb.Mutation{{
-						Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-							FamilyName:      "cf",
-							ColumnQualifier: []byte("col"),
-							TimestampMicros: 1000,
-							Value:           []byte{},
-						}},
-					}},
-				}
-				if _, err := s.MutateRow(ctx, req); err != nil {
-					t.Fatalf("Populating table: %v", err)
-				}
-			}
-		}
-	}
-
-	doWrite()
-	tblSize := tbl.rows.Len()
-	req := &btapb.DropRowRangeRequest{
-		Name:   tblInfo.Name,
-		Target: &btapb.DropRowRangeRequest_RowKeyPrefix{RowKeyPrefix: []byte("AAA")},
-	}
-	if _, err = s.DropRowRange(ctx, req); err != nil {
-		t.Fatalf("Dropping first range: %v", err)
-	}
-	got, want := tbl.rows.Len(), tblSize-count
-	if got != want {
-		t.Errorf("Row count after first drop: got %d (%v), want %d", got, tbl.rows, want)
-	}
-
-	req = &btapb.DropRowRangeRequest{
-		Name:   tblInfo.Name,
-		Target: &btapb.DropRowRangeRequest_RowKeyPrefix{RowKeyPrefix: []byte("DDD")},
-	}
-	if _, err = s.DropRowRange(ctx, req); err != nil {
-		t.Fatalf("Dropping second range: %v", err)
-	}
-	got, want = tbl.rows.Len(), tblSize-(2*count)
-	if got != want {
-		t.Errorf("Row count after second drop: got %d (%v), want %d", got, tbl.rows, want)
-	}
-
-	req = &btapb.DropRowRangeRequest{
-		Name:   tblInfo.Name,
-		Target: &btapb.DropRowRangeRequest_RowKeyPrefix{RowKeyPrefix: []byte("XXX")},
-	}
-	if _, err = s.DropRowRange(ctx, req); err != nil {
-		t.Fatalf("Dropping invalid range: %v", err)
-	}
-	got, want = tbl.rows.Len(), tblSize-(2*count)
-	if got != want {
-		t.Errorf("Row count after invalid drop: got %d (%v), want %d", got, tbl.rows, want)
-	}
-
-	req = &btapb.DropRowRangeRequest{
-		Name:   tblInfo.Name,
-		Target: &btapb.DropRowRangeRequest_DeleteAllDataFromTable{DeleteAllDataFromTable: true},
-	}
-	if _, err = s.DropRowRange(ctx, req); err != nil {
-		t.Fatalf("Dropping all data: %v", err)
-	}
-	got, want = tbl.rows.Len(), 0
-	if got != want {
-		t.Errorf("Row count after drop all: got %d, want %d", got, want)
-	}
-
-	// Test that we can write rows, delete some and then write them again.
-	count = 1
-	doWrite()
-
-	req = &btapb.DropRowRangeRequest{
-		Name:   tblInfo.Name,
-		Target: &btapb.DropRowRangeRequest_DeleteAllDataFromTable{DeleteAllDataFromTable: true},
-	}
-	if _, err = s.DropRowRange(ctx, req); err != nil {
-		t.Fatalf("Dropping all data: %v", err)
-	}
-	got, want = tbl.rows.Len(), 0
-	if got != want {
-		t.Errorf("Row count after drop all: got %d, want %d", got, want)
-	}
-
-	doWrite()
-	got, want = tbl.rows.Len(), len(prefixes)
-	if got != want {
-		t.Errorf("Row count after rewrite: got %d, want %d", got, want)
-	}
-
-	req = &btapb.DropRowRangeRequest{
-		Name:   tblInfo.Name,
-		Target: &btapb.DropRowRangeRequest_RowKeyPrefix{RowKeyPrefix: []byte("BBB")},
-	}
-	if _, err = s.DropRowRange(ctx, req); err != nil {
-		t.Fatalf("Dropping range: %v", err)
-	}
-	doWrite()
-	got, want = tbl.rows.Len(), len(prefixes)
-	if got != want {
-		t.Errorf("Row count after drop range: got %d, want %d", got, want)
-	}
-}
-
-type MockReadRowsServer struct {
-	responses []*btpb.ReadRowsResponse
-	grpc.ServerStream
-}
-
-func (s *MockReadRowsServer) Send(resp *btpb.ReadRowsResponse) error {
-	s.responses = append(s.responses, resp)
-	return nil
-}
-
-func TestReadRows(t *testing.T) {
-	ctx := context.Background()
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf0": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tblInfo, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-	mreq := &btpb.MutateRowRequest{
-		TableName: tblInfo.Name,
-		RowKey:    []byte("row"),
-		Mutations: []*btpb.Mutation{{
-			Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-				FamilyName:      "cf0",
-				ColumnQualifier: []byte("col"),
-				TimestampMicros: 1000,
-				Value:           []byte{},
-			}},
-		}},
-	}
-	if _, err := s.MutateRow(ctx, mreq); err != nil {
-		t.Fatalf("Populating table: %v", err)
-	}
-
-	for _, rowset := range []*btpb.RowSet{
-		{RowKeys: [][]byte{[]byte("row")}},
-		{RowRanges: []*btpb.RowRange{{StartKey: &btpb.RowRange_StartKeyClosed{StartKeyClosed: []byte("")}}}},
-		{RowRanges: []*btpb.RowRange{{StartKey: &btpb.RowRange_StartKeyClosed{StartKeyClosed: []byte("r")}}}},
-		{RowRanges: []*btpb.RowRange{{
-			StartKey: &btpb.RowRange_StartKeyClosed{StartKeyClosed: []byte("")},
-			EndKey:   &btpb.RowRange_EndKeyOpen{EndKeyOpen: []byte("s")},
-		}}},
-	} {
-		mock := &MockReadRowsServer{}
-		req := &btpb.ReadRowsRequest{TableName: tblInfo.Name, Rows: rowset}
-		if err = s.ReadRows(req, mock); err != nil {
-			t.Fatalf("ReadRows error: %v", err)
-		}
-		if got, want := len(mock.responses), 1; got != want {
-			t.Errorf("%+v: response count: got %d, want %d", rowset, got, want)
-		}
-	}
-}
-
-func TestReadRowsError(t *testing.T) {
-	ctx := context.Background()
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf0": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tblInfo, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-	mreq := &btpb.MutateRowRequest{
-		TableName: tblInfo.Name,
-		RowKey:    []byte("row"),
-		Mutations: []*btpb.Mutation{{
-			Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-				FamilyName:      "cf0",
-				ColumnQualifier: []byte("col"),
-				TimestampMicros: 1000,
-				Value:           []byte{},
-			}},
-		}},
-	}
-	if _, err := s.MutateRow(ctx, mreq); err != nil {
-		t.Fatalf("Populating table: %v", err)
-	}
-
-	mock := &MockReadRowsServer{}
-	req := &btpb.ReadRowsRequest{TableName: tblInfo.Name, Filter: &btpb.RowFilter{
-		Filter: &btpb.RowFilter_RowKeyRegexFilter{RowKeyRegexFilter: []byte("[")}}, // Invalid regex.
-	}
-	if err = s.ReadRows(req, mock); err == nil {
-		t.Fatal("ReadRows got no error, want error")
-	}
-}
-
-func TestReadRowsAfterDeletion(t *testing.T) {
-	ctx := context.Background()
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf0": {},
-		},
-	}
-	tblInfo, err := s.CreateTable(ctx, &btapb.CreateTableRequest{
-		Parent: "cluster", TableId: "t", Table: &newTbl,
-	})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-	populateTable(ctx, s)
-	dreq := &btpb.MutateRowRequest{
-		TableName: tblInfo.Name,
-		RowKey:    []byte("row"),
-		Mutations: []*btpb.Mutation{{
-			Mutation: &btpb.Mutation_DeleteFromRow_{
-				DeleteFromRow: &btpb.Mutation_DeleteFromRow{},
-			},
-		}},
-	}
-	if _, err := s.MutateRow(ctx, dreq); err != nil {
-		t.Fatalf("Deleting from table: %v", err)
-	}
-
-	mock := &MockReadRowsServer{}
-	req := &btpb.ReadRowsRequest{TableName: tblInfo.Name}
-	if err = s.ReadRows(req, mock); err != nil {
-		t.Fatalf("ReadRows error: %v", err)
-	}
-	if got, want := len(mock.responses), 0; got != want {
-		t.Errorf("response count: got %d, want %d", got, want)
-	}
-}
-
-func TestReadRowsOrder(t *testing.T) {
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	ctx := context.Background()
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf0": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tblInfo, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-	count := 3
-	mcf := func(i int) *btapb.ModifyColumnFamiliesRequest {
-		return &btapb.ModifyColumnFamiliesRequest{
-			Name: tblInfo.Name,
-			Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-				Id:  "cf" + strconv.Itoa(i),
-				Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Create{Create: &btapb.ColumnFamily{}},
-			}},
-		}
-	}
-	for i := 1; i <= count; i++ {
-		_, err = s.ModifyColumnFamilies(ctx, mcf(i))
-		if err != nil {
-			t.Fatal(err)
-		}
-	}
-	// Populate the table
-	for fc := 0; fc < count; fc++ {
-		for cc := count; cc > 0; cc-- {
-			for tc := 0; tc < count; tc++ {
-				req := &btpb.MutateRowRequest{
-					TableName: tblInfo.Name,
-					RowKey:    []byte("row"),
-					Mutations: []*btpb.Mutation{{
-						Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-							FamilyName:      "cf" + strconv.Itoa(fc),
-							ColumnQualifier: []byte("col" + strconv.Itoa(cc)),
-							TimestampMicros: int64((tc + 1) * 1000),
-							Value:           []byte{},
-						}},
-					}},
-				}
-				if _, err := s.MutateRow(ctx, req); err != nil {
-					t.Fatalf("Populating table: %v", err)
-				}
-			}
-		}
-	}
-	req := &btpb.ReadRowsRequest{
-		TableName: tblInfo.Name,
-		Rows:      &btpb.RowSet{RowKeys: [][]byte{[]byte("row")}},
-	}
-	mock := &MockReadRowsServer{}
-	if err = s.ReadRows(req, mock); err != nil {
-		t.Errorf("ReadRows error: %v", err)
-	}
-	if len(mock.responses) == 0 {
-		t.Fatal("Response count: got 0, want > 0")
-	}
-	if len(mock.responses[0].Chunks) != 27 {
-		t.Fatalf("Chunk count: got %d, want 27", len(mock.responses[0].Chunks))
-	}
-	testOrder := func(ms *MockReadRowsServer) {
-		var prevFam, prevCol string
-		var prevTime int64
-		for _, cc := range ms.responses[0].Chunks {
-			if prevFam == "" {
-				prevFam = cc.FamilyName.Value
-				prevCol = string(cc.Qualifier.Value)
-				prevTime = cc.TimestampMicros
-				continue
-			}
-			if cc.FamilyName.Value < prevFam {
-				t.Errorf("Family order is not correct: got %s < %s", cc.FamilyName.Value, prevFam)
-			} else if cc.FamilyName.Value == prevFam {
-				if string(cc.Qualifier.Value) < prevCol {
-					t.Errorf("Column order is not correct: got %s < %s", string(cc.Qualifier.Value), prevCol)
-				} else if string(cc.Qualifier.Value) == prevCol {
-					if cc.TimestampMicros > prevTime {
-						t.Errorf("cell order is not correct: got %d > %d", cc.TimestampMicros, prevTime)
-					}
-				}
-			}
-			prevFam = cc.FamilyName.Value
-			prevCol = string(cc.Qualifier.Value)
-			prevTime = cc.TimestampMicros
-		}
-	}
-	testOrder(mock)
-
-	// Read with interleave filter
-	inter := &btpb.RowFilter_Interleave{}
-	fnr := &btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{FamilyNameRegexFilter: "cf1"}}
-	cqr := &btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{ColumnQualifierRegexFilter: []byte("col2")}}
-	inter.Filters = append(inter.Filters, fnr, cqr)
-	req = &btpb.ReadRowsRequest{
-		TableName: tblInfo.Name,
-		Rows:      &btpb.RowSet{RowKeys: [][]byte{[]byte("row")}},
-		Filter: &btpb.RowFilter{
-			Filter: &btpb.RowFilter_Interleave_{Interleave: inter},
-		},
-	}
-
-	mock = &MockReadRowsServer{}
-	if err = s.ReadRows(req, mock); err != nil {
-		t.Errorf("ReadRows error: %v", err)
-	}
-	if len(mock.responses) == 0 {
-		t.Fatal("Response count: got 0, want > 0")
-	}
-	if len(mock.responses[0].Chunks) != 18 {
-		t.Fatalf("Chunk count: got %d, want 18", len(mock.responses[0].Chunks))
-	}
-	testOrder(mock)
-
-	// Check order after ReadModifyWriteRow
-	rmw := func(i int) *btpb.ReadModifyWriteRowRequest {
-		return &btpb.ReadModifyWriteRowRequest{
-			TableName: tblInfo.Name,
-			RowKey:    []byte("row"),
-			Rules: []*btpb.ReadModifyWriteRule{{
-				FamilyName:      "cf3",
-				ColumnQualifier: []byte("col" + strconv.Itoa(i)),
-				Rule:            &btpb.ReadModifyWriteRule_IncrementAmount{IncrementAmount: 1},
-			}},
-		}
-	}
-	for i := count; i > 0; i-- {
-		if _, err := s.ReadModifyWriteRow(ctx, rmw(i)); err != nil {
-			t.Fatal(err)
-		}
-	}
-	req = &btpb.ReadRowsRequest{
-		TableName: tblInfo.Name,
-		Rows:      &btpb.RowSet{RowKeys: [][]byte{[]byte("row")}},
-	}
-	mock = &MockReadRowsServer{}
-	if err = s.ReadRows(req, mock); err != nil {
-		t.Errorf("ReadRows error: %v", err)
-	}
-	if len(mock.responses) == 0 {
-		t.Fatal("Response count: got 0, want > 0")
-	}
-	if len(mock.responses[0].Chunks) != 30 {
-		t.Fatalf("Chunk count: got %d, want 30", len(mock.responses[0].Chunks))
-	}
-	testOrder(mock)
-}
-
-func TestReadRowsWithlabelTransformer(t *testing.T) {
-	ctx := context.Background()
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf0": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tblInfo, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-	mreq := &btpb.MutateRowRequest{
-		TableName: tblInfo.Name,
-		RowKey:    []byte("row"),
-		Mutations: []*btpb.Mutation{{
-			Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-				FamilyName:      "cf0",
-				ColumnQualifier: []byte("col"),
-				TimestampMicros: 1000,
-				Value:           []byte{},
-			}},
-		}},
-	}
-	if _, err := s.MutateRow(ctx, mreq); err != nil {
-		t.Fatalf("Populating table: %v", err)
-	}
-
-	mock := &MockReadRowsServer{}
-	req := &btpb.ReadRowsRequest{
-		TableName: tblInfo.Name,
-		Filter: &btpb.RowFilter{
-			Filter: &btpb.RowFilter_ApplyLabelTransformer{
-				ApplyLabelTransformer: "label",
-			},
-		},
-	}
-	if err = s.ReadRows(req, mock); err != nil {
-		t.Fatalf("ReadRows error: %v", err)
-	}
-
-	if got, want := len(mock.responses), 1; got != want {
-		t.Fatalf("response count: got %d, want %d", got, want)
-	}
-	resp := mock.responses[0]
-	if got, want := len(resp.Chunks), 1; got != want {
-		t.Fatalf("chunks count: got %d, want %d", got, want)
-	}
-	chunk := resp.Chunks[0]
-	if got, want := len(chunk.Labels), 1; got != want {
-		t.Fatalf("labels count: got %d, want %d", got, want)
-	}
-	if got, want := chunk.Labels[0], "label"; got != want {
-		t.Fatalf("label: got %s, want %s", got, want)
-	}
-
-	mock = &MockReadRowsServer{}
-	req = &btpb.ReadRowsRequest{
-		TableName: tblInfo.Name,
-		Filter: &btpb.RowFilter{
-			Filter: &btpb.RowFilter_ApplyLabelTransformer{
-				ApplyLabelTransformer: "", // invalid label
-			},
-		},
-	}
-	if err = s.ReadRows(req, mock); err == nil {
-		t.Fatal("ReadRows want invalid label error, got none")
-	}
-}
-
-func TestCheckAndMutateRowWithoutPredicate(t *testing.T) {
-	s := &server{
-		tables: make(map[string]*table),
-	}
-	ctx := context.Background()
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tbl, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	// Populate the table
-	val := []byte("value")
-	mrreq := &btpb.MutateRowRequest{
-		TableName: tbl.Name,
-		RowKey:    []byte("row-present"),
-		Mutations: []*btpb.Mutation{{
-			Mutation: &btpb.Mutation_SetCell_{SetCell: &btpb.Mutation_SetCell{
-				FamilyName:      "cf",
-				ColumnQualifier: []byte("col"),
-				TimestampMicros: 1000,
-				Value:           val,
-			}},
-		}},
-	}
-	if _, err := s.MutateRow(ctx, mrreq); err != nil {
-		t.Fatalf("Populating table: %v", err)
-	}
-
-	req := &btpb.CheckAndMutateRowRequest{
-		TableName: tbl.Name,
-		RowKey:    []byte("row-not-present"),
-	}
-	if res, err := s.CheckAndMutateRow(ctx, req); err != nil {
-		t.Errorf("CheckAndMutateRow error: %v", err)
-	} else if got, want := res.PredicateMatched, false; got != want {
-		t.Errorf("Invalid PredicateMatched value: got %t, want %t", got, want)
-	}
-
-	req = &btpb.CheckAndMutateRowRequest{
-		TableName: tbl.Name,
-		RowKey:    []byte("row-present"),
-	}
-	if res, err := s.CheckAndMutateRow(ctx, req); err != nil {
-		t.Errorf("CheckAndMutateRow error: %v", err)
-	} else if got, want := res.PredicateMatched, true; got != want {
-		t.Errorf("Invalid PredicateMatched value: got %t, want %t", got, want)
-	}
-}
-
-func TestServer_ReadModifyWriteRow(t *testing.T) {
-	s := &server{
-		tables: make(map[string]*table),
-	}
-
-	ctx := context.Background()
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{MaxNumVersions: 1}}},
-		},
-	}
-	tbl, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		t.Fatalf("Creating table: %v", err)
-	}
-
-	req := &btpb.ReadModifyWriteRowRequest{
-		TableName: tbl.Name,
-		RowKey:    []byte("row-key"),
-		Rules: []*btpb.ReadModifyWriteRule{
-			{
-				FamilyName:      "cf",
-				ColumnQualifier: []byte("q1"),
-				Rule: &btpb.ReadModifyWriteRule_AppendValue{
-					AppendValue: []byte("a"),
-				},
-			},
-			// multiple ops for same cell
-			{
-				FamilyName:      "cf",
-				ColumnQualifier: []byte("q1"),
-				Rule: &btpb.ReadModifyWriteRule_AppendValue{
-					AppendValue: []byte("b"),
-				},
-			},
-			// different cell whose qualifier should sort before the prior rules
-			{
-				FamilyName:      "cf",
-				ColumnQualifier: []byte("q0"),
-				Rule: &btpb.ReadModifyWriteRule_IncrementAmount{
-					IncrementAmount: 1,
-				},
-			},
-		},
-	}
-
-	got, err := s.ReadModifyWriteRow(ctx, req)
-
-	if err != nil {
-		t.Fatalf("ReadModifyWriteRow error: %v", err)
-	}
-
-	want := &btpb.ReadModifyWriteRowResponse{
-		Row: &btpb.Row{
-			Key: []byte("row-key"),
-			Families: []*btpb.Family{{
-				Name: "cf",
-				Columns: []*btpb.Column{
-					{
-						Qualifier: []byte("q0"),
-						Cells: []*btpb.Cell{{
-							Value: []byte{0, 0, 0, 0, 0, 0, 0, 1},
-						}},
-					},
-					{
-						Qualifier: []byte("q1"),
-						Cells: []*btpb.Cell{{
-							Value: []byte("ab"),
-						}},
-					},
-				},
-			}},
-		},
-	}
-
-	diff := cmp.Diff(got, want, cmpopts.IgnoreFields(btpb.Cell{}, "TimestampMicros"))
-	if diff != "" {
-		t.Errorf("unexpected response: %s", diff)
-	}
-}
-
-// helper function to populate table data
-func populateTable(ctx context.Context, s *server) (*btapb.Table, error) {
-	newTbl := btapb.Table{
-		ColumnFamilies: map[string]*btapb.ColumnFamily{
-			"cf0": {GcRule: &btapb.GcRule{Rule: &btapb.GcRule_MaxNumVersions{1}}},
-		},
-	}
-	tblInfo, err := s.CreateTable(ctx, &btapb.CreateTableRequest{Parent: "cluster", TableId: "t", Table: &newTbl})
-	if err != nil {
-		return nil, err
-	}
-	count := 3
-	mcf := func(i int) *btapb.ModifyColumnFamiliesRequest {
-		return &btapb.ModifyColumnFamiliesRequest{
-			Name: tblInfo.Name,
-			Modifications: []*btapb.ModifyColumnFamiliesRequest_Modification{{
-				Id:  "cf" + strconv.Itoa(i),
-				Mod: &btapb.ModifyColumnFamiliesRequest_Modification_Create{&btapb.ColumnFamily{}},
-			}},
-		}
-	}
-	for i := 1; i <= count; i++ {
-		_, err = s.ModifyColumnFamilies(ctx, mcf(i))
-		if err != nil {
-			return nil, err
-		}
-	}
-	// Populate the table
-	for fc := 0; fc < count; fc++ {
-		for cc := count; cc > 0; cc-- {
-			for tc := 0; tc < count; tc++ {
-				req := &btpb.MutateRowRequest{
-					TableName: tblInfo.Name,
-					RowKey:    []byte("row"),
-					Mutations: []*btpb.Mutation{{
-						Mutation: &btpb.Mutation_SetCell_{&btpb.Mutation_SetCell{
-							FamilyName:      "cf" + strconv.Itoa(fc),
-							ColumnQualifier: []byte("col" + strconv.Itoa(cc)),
-							TimestampMicros: int64((tc + 1) * 1000),
-							Value:           []byte{},
-						}},
-					}},
-				}
-				if _, err := s.MutateRow(ctx, req); err != nil {
-					return nil, err
-				}
-			}
-		}
-	}
-
-	return tblInfo, nil
-}
-
-func TestFilters(t *testing.T) {
-	tests := []struct {
-		in  *btpb.RowFilter
-		out int
-	}{
-		{in: &btpb.RowFilter{Filter: &btpb.RowFilter_BlockAllFilter{true}}, out: 0},
-		{in: &btpb.RowFilter{Filter: &btpb.RowFilter_BlockAllFilter{false}}, out: 1},
-		{in: &btpb.RowFilter{Filter: &btpb.RowFilter_PassAllFilter{true}}, out: 1},
-		{in: &btpb.RowFilter{Filter: &btpb.RowFilter_PassAllFilter{false}}, out: 0},
-	}
-
-	ctx := context.Background()
-
-	s := &server{
-		tables: make(map[string]*table),
-	}
-
-	tblInfo, err := populateTable(ctx, s)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	req := &btpb.ReadRowsRequest{
-		TableName: tblInfo.Name,
-		Rows:      &btpb.RowSet{RowKeys: [][]byte{[]byte("row")}},
-	}
-
-	for _, tc := range tests {
-		req.Filter = tc.in
-
-		mock := &MockReadRowsServer{}
-		if err = s.ReadRows(req, mock); err != nil {
-			t.Errorf("ReadRows error: %v", err)
-			continue
-		}
-
-		if len(mock.responses) != tc.out {
-			t.Errorf("Response count: got %d, want %d", len(mock.responses), tc.out)
-			continue
-		}
-	}
-}
-
-func Test_Mutation_DeleteFromColumn(t *testing.T) {
-	ctx := context.Background()
-
-	s := &server{
-		tables: make(map[string]*table),
-	}
-
-	tblInfo, err := populateTable(ctx, s)
-	if err != nil {
-		t.Fatal(err)
-	}
-
-	tests := []struct {
-		in   *btpb.MutateRowRequest
-		fail bool
-	}{
-		{in: &btpb.MutateRowRequest{
-			TableName: tblInfo.Name,
-			RowKey:    []byte("row"),
-			Mutations: []*btpb.Mutation{{
-				Mutation: &btpb.Mutation_DeleteFromColumn_{DeleteFromColumn: &btpb.Mutation_DeleteFromColumn{
-					FamilyName:      "cf1",
-					ColumnQualifier: []byte("col1"),
-					TimeRange: &btpb.TimestampRange{
-						StartTimestampMicros: 2000,
-						EndTimestampMicros:   1000,
-					},
-				}},
-			}},
-		},
-			fail: true,
-		},
-		{in: &btpb.MutateRowRequest{
-			TableName: tblInfo.Name,
-			RowKey:    []byte("row"),
-			Mutations: []*btpb.Mutation{{
-				Mutation: &btpb.Mutation_DeleteFromColumn_{DeleteFromColumn: &btpb.Mutation_DeleteFromColumn{
-					FamilyName:      "cf2",
-					ColumnQualifier: []byte("col2"),
-					TimeRange: &btpb.TimestampRange{
-						StartTimestampMicros: 1000,
-						EndTimestampMicros:   2000,
-					},
-				}},
-			}},
-		},
-			fail: false,
-		},
-		{in: &btpb.MutateRowRequest{
-			TableName: tblInfo.Name,
-			RowKey:    []byte("row"),
-			Mutations: []*btpb.Mutation{{
-				Mutation: &btpb.Mutation_DeleteFromColumn_{DeleteFromColumn: &btpb.Mutation_DeleteFromColumn{
-					FamilyName:      "cf3",
-					ColumnQualifier: []byte("col3"),
-					TimeRange: &btpb.TimestampRange{
-						StartTimestampMicros: 1000,
-						EndTimestampMicros:   0,
-					},
-				}},
-			}},
-		},
-			fail: false,
-		},
-		{in: &btpb.MutateRowRequest{
-			TableName: tblInfo.Name,
-			RowKey:    []byte("row"),
-			Mutations: []*btpb.Mutation{{
-				Mutation: &btpb.Mutation_DeleteFromColumn_{DeleteFromColumn: &btpb.Mutation_DeleteFromColumn{
-					FamilyName:      "cf4",
-					ColumnQualifier: []byte("col4"),
-					TimeRange: &btpb.TimestampRange{
-						StartTimestampMicros: 0,
-						EndTimestampMicros:   1000,
-					},
-				}},
-			}},
-		},
-			fail: true,
-		},
-	}
-
-	for _, tst := range tests {
-		_, err = s.MutateRow(ctx, tst.in)
-
-		if err != nil && !tst.fail {
-			t.Errorf("expected passed got failure for : %v \n with err: %v", tst.in, err)
-		}
-
-		if err == nil && tst.fail {
-			t.Errorf("expected failure got passed for : %v", tst)
-		}
-	}
-}
-
-func TestFilterRow(t *testing.T) {
-	row := &row{
-		key: "row",
-		families: map[string]*family{
-			"fam": {
-				name: "fam",
-				cells: map[string][]cell{
-					"col": {{ts: 100, value: []byte("val")}},
-				},
-			},
-		},
-	}
-	for _, test := range []struct {
-		filter *btpb.RowFilter
-		want   bool
-	}{
-		// The regexp-based filters perform whole-string, case-sensitive matches.
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_RowKeyRegexFilter{[]byte("row")}}, true},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_RowKeyRegexFilter{[]byte("ro")}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_RowKeyRegexFilter{[]byte("ROW")}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_RowKeyRegexFilter{[]byte("moo")}}, false},
-
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{"fam"}}, true},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{"f.*"}}, true},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{"[fam]+"}}, true},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{"fa"}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{"FAM"}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{"moo"}}, false},
-
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{[]byte("col")}}, true},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{[]byte("co")}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{[]byte("COL")}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{[]byte("moo")}}, false},
-
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ValueRegexFilter{[]byte("val")}}, true},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ValueRegexFilter{[]byte("va")}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ValueRegexFilter{[]byte("VAL")}}, false},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ValueRegexFilter{[]byte("moo")}}, false},
-	} {
-		got, _ := filterRow(test.filter, row.copy())
-		if got != test.want {
-			t.Errorf("%s: got %t, want %t", proto.CompactTextString(test.filter), got, test.want)
-		}
-	}
-}
-
-func TestFilterRowWithErrors(t *testing.T) {
-	row := &row{
-		key: "row",
-		families: map[string]*family{
-			"fam": {
-				name: "fam",
-				cells: map[string][]cell{
-					"col": {{ts: 100, value: []byte("val")}},
-				},
-			},
-		},
-	}
-	for _, test := range []struct {
-		badRegex *btpb.RowFilter
-	}{
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_RowKeyRegexFilter{[]byte("[")}}},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{"["}}},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{[]byte("[")}}},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_ValueRegexFilter{[]byte("[")}}},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_Chain_{
-			Chain: &btpb.RowFilter_Chain{Filters: []*btpb.RowFilter{
-				{Filter: &btpb.RowFilter_ValueRegexFilter{[]byte("[")}}},
-			},
-		}}},
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_Condition_{
-			Condition: &btpb.RowFilter_Condition{
-				PredicateFilter: &btpb.RowFilter{Filter: &btpb.RowFilter_ValueRegexFilter{[]byte("[")}},
-			},
-		}}},
-
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_RowSampleFilter{0.0}}}, // 0.0 is invalid.
-		{&btpb.RowFilter{Filter: &btpb.RowFilter_RowSampleFilter{1.0}}}, // 1.0 is invalid.
-	} {
-		got, err := filterRow(test.badRegex, row.copy())
-		if got != false {
-			t.Errorf("%s: got true, want false", proto.CompactTextString(test.badRegex))
-		}
-		if err == nil {
-			t.Errorf("%s: got no error, want error", proto.CompactTextString(test.badRegex))
-		}
-	}
-}
-
-func TestFilterRowWithRowSampleFilter(t *testing.T) {
-	prev := randFloat
-	randFloat = func() float64 { return 0.5 }
-	defer func() { randFloat = prev }()
-	for _, test := range []struct {
-		p    float64
-		want bool
-	}{
-		{0.1, false}, // Less than random float. Return no rows.
-		{0.5, false}, // Equal to random float. Return no rows.
-		{0.9, true},  // Greater than random float. Return all rows.
-	} {
-		got, err := filterRow(&btpb.RowFilter{Filter: &btpb.RowFilter_RowSampleFilter{test.p}}, &row{})
-		if err != nil {
-			t.Fatalf("%f: %v", test.p, err)
-		}
-		if got != test.want {
-			t.Errorf("%v: got %t, want %t", test.p, got, test.want)
-		}
-	}
-}
-
-func TestFilterRowWithBinaryColumnQualifier(t *testing.T) {
-	rs := []byte{128, 128}
-	row := &row{
-		key: string(rs),
-		families: map[string]*family{
-			"fam": {
-				name: "fam",
-				cells: map[string][]cell{
-					string(rs): {{ts: 100, value: []byte("val")}},
-				},
-			},
-		},
-	}
-	for _, test := range []struct {
-		filter []byte
-		want   bool
-	}{
-		{[]byte{128, 128}, true},                          // succeeds, exact match
-		{[]byte{128, 129}, false},                         // fails
-		{[]byte{128}, false},                              // fails, because the regexp must match the entire input
-		{[]byte{128, '*'}, true},                          // succeeds: 0 or more 128s
-		{[]byte{'[', 127, 128, ']', '{', '2', '}'}, true}, // succeeds: exactly two of either 127 or 128
-	} {
-		got, _ := filterRow(&btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{test.filter}}, row.copy())
-		if got != test.want {
-			t.Errorf("%v: got %t, want %t", test.filter, got, test.want)
-		}
-	}
-}

+ 0 - 1614
vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt.go

@@ -1,1614 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package main
-
-// Command docs are in cbtdoc.go.
-
-import (
-	"bytes"
-	"context"
-	"encoding/csv"
-	"flag"
-	"fmt"
-	"go/format"
-	"io"
-	"log"
-	"os"
-	"regexp"
-	"sort"
-	"strconv"
-	"strings"
-	"text/tabwriter"
-	"text/template"
-	"time"
-
-	"cloud.google.com/go/bigtable"
-	"cloud.google.com/go/bigtable/internal/cbtconfig"
-	"google.golang.org/api/iterator"
-	"google.golang.org/api/option"
-	"google.golang.org/grpc"
-)
-
-var (
-	oFlag = flag.String("o", "", "if set, redirect stdout to this file")
-
-	config              *cbtconfig.Config
-	client              *bigtable.Client
-	adminClient         *bigtable.AdminClient
-	instanceAdminClient *bigtable.InstanceAdminClient
-
-	version      = "<unknown version>"
-	revision     = "<unknown revision>"
-	revisionDate = "<unknown revision date>"
-	cliUserAgent = "cbt-cli-go/unknown"
-)
-
-func getCredentialOpts(opts []option.ClientOption) []option.ClientOption {
-	if ts := config.TokenSource; ts != nil {
-		opts = append(opts, option.WithTokenSource(ts))
-	}
-	if tlsCreds := config.TLSCreds; tlsCreds != nil {
-		opts = append(opts, option.WithGRPCDialOption(grpc.WithTransportCredentials(tlsCreds)))
-	}
-	return opts
-}
-
-func getClient(clientConf bigtable.ClientConfig) *bigtable.Client {
-	if client == nil {
-		var opts []option.ClientOption
-		if ep := config.DataEndpoint; ep != "" {
-			opts = append(opts, option.WithEndpoint(ep))
-		}
-		opts = append(opts, option.WithUserAgent(cliUserAgent))
-		opts = getCredentialOpts(opts)
-		var err error
-		client, err = bigtable.NewClientWithConfig(context.Background(), config.Project, config.Instance, clientConf, opts...)
-		if err != nil {
-			log.Fatalf("Making bigtable.Client: %v", err)
-		}
-	}
-	return client
-}
-
-func getAdminClient() *bigtable.AdminClient {
-	if adminClient == nil {
-		var opts []option.ClientOption
-		if ep := config.AdminEndpoint; ep != "" {
-			opts = append(opts, option.WithEndpoint(ep))
-		}
-		opts = append(opts, option.WithUserAgent(cliUserAgent))
-		opts = getCredentialOpts(opts)
-		var err error
-		adminClient, err = bigtable.NewAdminClient(context.Background(), config.Project, config.Instance, opts...)
-		if err != nil {
-			log.Fatalf("Making bigtable.AdminClient: %v", err)
-		}
-	}
-	return adminClient
-}
-
-func getInstanceAdminClient() *bigtable.InstanceAdminClient {
-	if instanceAdminClient == nil {
-		var opts []option.ClientOption
-		if ep := config.AdminEndpoint; ep != "" {
-			opts = append(opts, option.WithEndpoint(ep))
-		}
-		opts = getCredentialOpts(opts)
-		var err error
-		instanceAdminClient, err = bigtable.NewInstanceAdminClient(context.Background(), config.Project, opts...)
-		if err != nil {
-			log.Fatalf("Making bigtable.InstanceAdminClient: %v", err)
-		}
-	}
-	return instanceAdminClient
-}
-
-func main() {
-	var err error
-	config, err = cbtconfig.Load()
-	if err != nil {
-		log.Fatal(err)
-	}
-	config.RegisterFlags()
-
-	flag.Usage = func() { usage(os.Stderr) }
-	flag.Parse()
-	if flag.NArg() == 0 {
-		usage(os.Stderr)
-		os.Exit(1)
-	}
-
-	if *oFlag != "" {
-		f, err := os.Create(*oFlag)
-		if err != nil {
-			log.Fatal(err)
-		}
-		defer func() {
-			if err := f.Close(); err != nil {
-				log.Fatal(err)
-			}
-		}()
-		os.Stdout = f
-	}
-
-	if config.UserAgent != "" {
-		cliUserAgent = config.UserAgent
-	}
-
-	ctx := context.Background()
-	for _, cmd := range commands {
-		if cmd.Name == flag.Arg(0) {
-			if err := config.CheckFlags(cmd.Required); err != nil {
-				log.Fatal(err)
-			}
-			cmd.do(ctx, flag.Args()[1:]...)
-			return
-		}
-	}
-	log.Fatalf("Unknown command %q", flag.Arg(0))
-}
-
-func usage(w io.Writer) {
-	fmt.Fprintf(w, "Usage: %s [flags] <command> ...\n", os.Args[0])
-	flag.CommandLine.SetOutput(w)
-	flag.CommandLine.PrintDefaults()
-	fmt.Fprintf(w, "\n%s", cmdSummary)
-}
-
-var cmdSummary string // generated in init, below
-
-func init() {
-	var buf bytes.Buffer
-	tw := tabwriter.NewWriter(&buf, 10, 8, 4, '\t', 0)
-	for _, cmd := range commands {
-		fmt.Fprintf(tw, "cbt %s\t%s\n", cmd.Name, cmd.Desc)
-	}
-	tw.Flush()
-	buf.WriteString(configHelp)
-	buf.WriteString("\ncbt " + version + " " + revision + " " + revisionDate + "\n")
-	cmdSummary = buf.String()
-}
-
-var configHelp = `
-Alpha features are not currently available to most Cloud Bigtable customers. The
-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 Bigtable otherwise supports (e.g., row key, column qualifier,
-etc.).
-
-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
-
-All values are optional, and all will be overridden by flags.
-`
-
-var commands = []struct {
-	Name, Desc string
-	do         func(context.Context, ...string)
-	Usage      string
-	Required   cbtconfig.RequiredFlags
-}{
-	{
-		Name:     "count",
-		Desc:     "Count rows in a table",
-		do:       doCount,
-		Usage:    "cbt count <table>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "createinstance",
-		Desc: "Create an instance with an initial cluster",
-		do:   doCreateInstance,
-		Usage: "cbt createinstance <instance-id> <display-name> <cluster-id> <zone> <num-nodes> <storage type>\n" +
-			"  instance-id					Permanent, unique id for the instance\n" +
-			"  display-name	  			Description of the instance\n" +
-			"  cluster-id						Permanent, unique id for the cluster in the instance\n" +
-			"  zone				  				The zone in which to create the cluster\n" +
-			"  num-nodes	  				The number of nodes to create\n" +
-			"  storage-type					SSD or HDD\n",
-		Required: cbtconfig.ProjectRequired,
-	},
-	{
-		Name: "createcluster",
-		Desc: "Create a cluster in the configured instance ",
-		do:   doCreateCluster,
-		Usage: "cbt createcluster <cluster-id> <zone> <num-nodes> <storage type>\n" +
-			"  cluster-id		Permanent, unique id for the cluster in the instance\n" +
-			"  zone				  The zone in which to create the cluster\n" +
-			"  num-nodes	  The number of nodes to create\n" +
-			"  storage-type	SSD or HDD\n",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "createfamily",
-		Desc:     "Create a column family",
-		do:       doCreateFamily,
-		Usage:    "cbt createfamily <table> <family>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "createtable",
-		Desc: "Create a table",
-		do:   doCreateTable,
-		Usage: "cbt createtable <table> [families=family[:gcpolicy],...] [splits=split,...]\n" +
-			"  families: Column families and their associated GC policies. For gcpolicy,\n" +
-			"  					see \"setgcpolicy\".\n" +
-			"					Example: families=family1:maxage=1w,family2:maxversions=1\n" +
-			"  splits:   Row key to be used to initially split the table",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "updatecluster",
-		Desc: "Update a cluster in the configured instance",
-		do:   doUpdateCluster,
-		Usage: "cbt updatecluster <cluster-id> [num-nodes=num-nodes]\n" +
-			"  cluster-id		Permanent, unique id for the cluster in the instance\n" +
-			"  num-nodes		The number of nodes to update to",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "deleteinstance",
-		Desc:     "Delete an instance",
-		do:       doDeleteInstance,
-		Usage:    "cbt deleteinstance <instance>",
-		Required: cbtconfig.ProjectRequired,
-	},
-	{
-		Name:     "deletecluster",
-		Desc:     "Delete a cluster from the configured instance ",
-		do:       doDeleteCluster,
-		Usage:    "cbt deletecluster <cluster>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "deletecolumn",
-		Desc: "Delete all cells in a column",
-		do:   doDeleteColumn,
-		Usage: "cbt deletecolumn <table> <row> <family> <column> [app-profile=<app profile id>]\n" +
-			"  app-profile=<app profile id>		The app profile id to use for the request\n",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "deletefamily",
-		Desc:     "Delete a column family",
-		do:       doDeleteFamily,
-		Usage:    "cbt deletefamily <table> <family>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "deleterow",
-		Desc: "Delete a row",
-		do:   doDeleteRow,
-		Usage: "cbt deleterow <table> <row> [app-profile=<app profile id>]\n" +
-			"  app-profile=<app profile id>		The app profile id to use for the request\n",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "deletetable",
-		Desc:     "Delete a table",
-		do:       doDeleteTable,
-		Usage:    "cbt deletetable <table>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "doc",
-		Desc:     "Print godoc-suitable documentation for cbt",
-		do:       doDoc,
-		Usage:    "cbt doc",
-		Required: cbtconfig.NoneRequired,
-	},
-	{
-		Name:     "help",
-		Desc:     "Print help text",
-		do:       doHelp,
-		Usage:    "cbt help [command]",
-		Required: cbtconfig.NoneRequired,
-	},
-	{
-		Name:     "listinstances",
-		Desc:     "List instances in a project",
-		do:       doListInstances,
-		Usage:    "cbt listinstances",
-		Required: cbtconfig.ProjectRequired,
-	},
-	{
-		Name:     "listclusters",
-		Desc:     "List clusters in an instance",
-		do:       doListClusters,
-		Usage:    "cbt listclusters",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "lookup",
-		Desc: "Read from a single row",
-		do:   doLookup,
-		Usage: "cbt lookup <table> <row> [columns=[family]:[qualifier],...] [cells-per-column=<n>] " +
-			"[app-profile=<app profile id>]\n" +
-			"  columns=[family]:[qualifier],...	Read only these columns, comma-separated\n" +
-			"  cells-per-column=<n> 			Read only this many cells per column\n" +
-			"  app-profile=<app profile id>		The app profile id to use for the request\n",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "ls",
-		Desc: "List tables and column families",
-		do:   doLS,
-		Usage: "cbt ls			List tables\n" +
-			"cbt ls <table>		List column families in <table>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "mddoc",
-		Desc:     "Print documentation for cbt in Markdown format",
-		do:       doMDDoc,
-		Usage:    "cbt mddoc",
-		Required: cbtconfig.NoneRequired,
-	},
-	{
-		Name: "read",
-		Desc: "Read rows",
-		do:   doRead,
-		Usage: "cbt read <table> [start=<row>] [end=<row>] [prefix=<prefix>]" +
-			" [regex=<regex>] [columns=[family]:[qualifier],...] [count=<n>] [cells-per-column=<n>]" +
-			" [app-profile=<app profile id>]\n" +
-			"  start=<row>				Start reading at this row\n" +
-			"  end=<row>				Stop reading before this row\n" +
-			"  prefix=<prefix>			Read rows with this prefix\n" +
-			"  regex=<regex> 			Read rows with keys matching this regex\n" +
-			"  columns=[family]:[qualifier],...	Read only these columns, comma-separated\n" +
-			"  count=<n>				Read only this many rows\n" +
-			"  cells-per-column=<n>			Read only this many cells per column\n" +
-			"  app-profile=<app profile id>		The app profile id to use for the request\n",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "set",
-		Desc: "Set value of a cell",
-		do:   doSet,
-		Usage: "cbt set <table> <row> [app-profile=<app profile id>] family:column=val[@ts] ...\n" +
-			"  app-profile=<app profile id>		The app profile id to use for the request\n" +
-			"  family:column=val[@ts] may be repeated to set multiple cells.\n" +
-			"\n" +
-			"  ts is an optional integer timestamp.\n" +
-			"  If it cannot be parsed, the `@ts` part will be\n" +
-			"  interpreted as part of the value.",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "setgcpolicy",
-		Desc: "Set the GC policy for a column family",
-		do:   doSetGCPolicy,
-		Usage: "cbt setgcpolicy <table> <family> ((maxage=<d> | maxversions=<n>) [(and|or) (maxage=<d> | maxversions=<n>),...] | never)\n" +
-			"\n" +
-			`  maxage=<d>		Maximum timestamp age to preserve (e.g. "1h", "4d")` + "\n" +
-			"  maxversions=<n>	Maximum number of versions to preserve",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "waitforreplication",
-		Desc:     "Block until all the completed writes have been replicated to all the clusters",
-		do:       doWaitForReplicaiton,
-		Usage:    "cbt waitforreplication <table>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "createtablefromsnapshot",
-		Desc: "Create a table from a snapshot (snapshots alpha)",
-		do:   doCreateTableFromSnapshot,
-		Usage: "cbt createtablefromsnapshot <table> <cluster> <snapshot>\n" +
-			"  table	The name of the table to create\n" +
-			"  cluster	The cluster where the snapshot is located\n" +
-			"  snapshot	The snapshot to restore",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "createsnapshot",
-		Desc: "Create a snapshot from a source table (snapshots alpha)",
-		do:   doSnapshotTable,
-		Usage: "cbt createsnapshot <cluster> <snapshot> <table> [ttl=<d>]\n" +
-			"\n" +
-			`  [ttl=<d>]		Lifespan of the snapshot (e.g. "1h", "4d")` + "\n",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "listsnapshots",
-		Desc:     "List snapshots in a cluster (snapshots alpha)",
-		do:       doListSnapshots,
-		Usage:    "cbt listsnapshots [<cluster>]",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "getsnapshot",
-		Desc:     "Get snapshot info (snapshots alpha)",
-		do:       doGetSnapshot,
-		Usage:    "cbt getsnapshot <cluster> <snapshot>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "deletesnapshot",
-		Desc:     "Delete snapshot in a cluster (snapshots alpha)",
-		do:       doDeleteSnapshot,
-		Usage:    "cbt deletesnapshot <cluster> <snapshot>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "version",
-		Desc:     "Print the current cbt version",
-		do:       doVersion,
-		Usage:    "cbt version",
-		Required: cbtconfig.NoneRequired,
-	},
-	{
-		Name: "createappprofile",
-		Desc: "Creates app profile for an instance",
-		do:   doCreateAppProfile,
-		Usage: "usage: cbt createappprofile <instance-id> <profile-id> <description> " +
-			"(route-any | [ route-to=<cluster-id> : transactional-writes]) [optional flag] \n" +
-			"optional flags may be `force`",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "getappprofile",
-		Desc:     "Reads app profile for an instance",
-		do:       doGetAppProfile,
-		Usage:    "cbt getappprofile <instance-id> <profile-id>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "listappprofile",
-		Desc:     "Lists app profile for an instance",
-		do:       doListAppProfiles,
-		Usage:    "cbt listappprofile <instance-id> ",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name: "updateappprofile",
-		Desc: "Updates app profile for an instance",
-		do:   doUpdateAppProfile,
-		Usage: "usage: cbt updateappprofile  <instance-id> <profile-id> <description>" +
-			"(route-any | [ route-to=<cluster-id> : transactional-writes]) [optional flag] \n" +
-			"optional flags may be `force`",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-	{
-		Name:     "deleteappprofile",
-		Desc:     "Deletes app profile for an instance",
-		do:       doDeleteAppProfile,
-		Usage:    "cbt deleteappprofile <instance-id> <profile-id>",
-		Required: cbtconfig.ProjectAndInstanceRequired,
-	},
-}
-
-func doCount(ctx context.Context, args ...string) {
-	if len(args) != 1 {
-		log.Fatal("usage: cbt count <table>")
-	}
-	tbl := getClient(bigtable.ClientConfig{}).Open(args[0])
-
-	n := 0
-	err := tbl.ReadRows(ctx, bigtable.InfiniteRange(""), func(_ bigtable.Row) bool {
-		n++
-		return true
-	}, bigtable.RowFilter(bigtable.StripValueFilter()))
-	if err != nil {
-		log.Fatalf("Reading rows: %v", err)
-	}
-	fmt.Println(n)
-}
-
-func doCreateTable(ctx context.Context, args ...string) {
-	if len(args) < 1 {
-		log.Fatal("usage: cbt createtable <table> [families=family[:gcpolicy],...] [splits=split,...]")
-	}
-
-	tblConf := bigtable.TableConf{TableID: args[0]}
-	parsed, err := parseArgs(args[1:], []string{"families", "splits"})
-	if err != nil {
-		log.Fatal(err)
-	}
-	for key, val := range parsed {
-		chunks, err := csv.NewReader(strings.NewReader(val)).Read()
-		if err != nil {
-			log.Fatalf("Invalid %s arg format: %v", key, err)
-		}
-		switch key {
-		case "families":
-			tblConf.Families = make(map[string]bigtable.GCPolicy)
-			for _, family := range chunks {
-				famPolicy := strings.Split(family, ":")
-				var gcPolicy bigtable.GCPolicy
-				if len(famPolicy) < 2 {
-					gcPolicy = bigtable.MaxVersionsPolicy(1)
-					log.Printf("Using default GC Policy of %v for family %v", gcPolicy, family)
-				} else {
-					gcPolicy, err = parseGCPolicy(famPolicy[1])
-					if err != nil {
-						log.Fatal(err)
-					}
-				}
-				tblConf.Families[famPolicy[0]] = gcPolicy
-			}
-		case "splits":
-			tblConf.SplitKeys = chunks
-		}
-	}
-
-	if err := getAdminClient().CreateTableFromConf(ctx, &tblConf); err != nil {
-		log.Fatalf("Creating table: %v", err)
-	}
-}
-
-func doCreateFamily(ctx context.Context, args ...string) {
-	if len(args) != 2 {
-		log.Fatal("usage: cbt createfamily <table> <family>")
-	}
-	err := getAdminClient().CreateColumnFamily(ctx, args[0], args[1])
-	if err != nil {
-		log.Fatalf("Creating column family: %v", err)
-	}
-}
-
-func doCreateInstance(ctx context.Context, args ...string) {
-	if len(args) < 6 {
-		log.Fatal("cbt createinstance <instance-id> <display-name> <cluster-id> <zone> <num-nodes> <storage type>")
-	}
-
-	numNodes, err := strconv.ParseInt(args[4], 0, 32)
-	if err != nil {
-		log.Fatalf("Bad num-nodes %q: %v", args[4], err)
-	}
-
-	sType, err := parseStorageType(args[5])
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	ic := bigtable.InstanceWithClustersConfig{
-		InstanceID:  args[0],
-		DisplayName: args[1],
-		Clusters: []bigtable.ClusterConfig{{
-			ClusterID:   args[2],
-			Zone:        args[3],
-			NumNodes:    int32(numNodes),
-			StorageType: sType,
-		}},
-	}
-	err = getInstanceAdminClient().CreateInstanceWithClusters(ctx, &ic)
-	if err != nil {
-		log.Fatalf("Creating instance: %v", err)
-	}
-}
-
-func doCreateCluster(ctx context.Context, args ...string) {
-	if len(args) < 4 {
-		log.Fatal("usage: cbt createcluster <cluster-id> <zone> <num-nodes> <storage type>")
-	}
-
-	numNodes, err := strconv.ParseInt(args[2], 0, 32)
-	if err != nil {
-		log.Fatalf("Bad num_nodes %q: %v", args[2], err)
-	}
-
-	sType, err := parseStorageType(args[3])
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	cc := bigtable.ClusterConfig{
-		InstanceID:  config.Instance,
-		ClusterID:   args[0],
-		Zone:        args[1],
-		NumNodes:    int32(numNodes),
-		StorageType: sType,
-	}
-	err = getInstanceAdminClient().CreateCluster(ctx, &cc)
-	if err != nil {
-		log.Fatalf("Creating cluster: %v", err)
-	}
-}
-
-func doUpdateCluster(ctx context.Context, args ...string) {
-	if len(args) < 2 {
-		log.Fatal("cbt updatecluster <cluster-id> [num-nodes=num-nodes]")
-	}
-
-	numNodes := int64(0)
-	parsed, err := parseArgs(args[1:], []string{"num-nodes"})
-	if err != nil {
-		log.Fatal(err)
-	}
-	if val, ok := parsed["num-nodes"]; ok {
-		numNodes, err = strconv.ParseInt(val, 0, 32)
-		if err != nil {
-			log.Fatalf("Bad num-nodes %q: %v", val, err)
-		}
-	}
-	if numNodes > 0 {
-		err = getInstanceAdminClient().UpdateCluster(ctx, config.Instance, args[0], int32(numNodes))
-		if err != nil {
-			log.Fatalf("Updating cluster: %v", err)
-		}
-	} else {
-		log.Fatal("Updating cluster: nothing to update")
-	}
-}
-
-func doDeleteInstance(ctx context.Context, args ...string) {
-	if len(args) != 1 {
-		log.Fatal("usage: cbt deleteinstance <instance>")
-	}
-	err := getInstanceAdminClient().DeleteInstance(ctx, args[0])
-	if err != nil {
-		log.Fatalf("Deleting instance: %v", err)
-	}
-}
-
-func doDeleteCluster(ctx context.Context, args ...string) {
-	if len(args) != 1 {
-		log.Fatal("usage: cbt deletecluster <cluster>")
-	}
-	err := getInstanceAdminClient().DeleteCluster(ctx, config.Instance, args[0])
-	if err != nil {
-		log.Fatalf("Deleting cluster: %v", err)
-	}
-}
-
-func doDeleteColumn(ctx context.Context, args ...string) {
-	usage := "usage: cbt deletecolumn <table> <row> <family> <column> [app-profile=<app profile id>]"
-	if len(args) != 4 && len(args) != 5 {
-		log.Fatal(usage)
-	}
-	var appProfile string
-	if len(args) == 5 {
-		if !strings.HasPrefix(args[4], "app-profile=") {
-			log.Fatal(usage)
-		}
-		appProfile = strings.Split(args[4], "=")[1]
-	}
-	tbl := getClient(bigtable.ClientConfig{AppProfile: appProfile}).Open(args[0])
-	mut := bigtable.NewMutation()
-	mut.DeleteCellsInColumn(args[2], args[3])
-	if err := tbl.Apply(ctx, args[1], mut); err != nil {
-		log.Fatalf("Deleting cells in column: %v", err)
-	}
-}
-
-func doDeleteFamily(ctx context.Context, args ...string) {
-	if len(args) != 2 {
-		log.Fatal("usage: cbt deletefamily <table> <family>")
-	}
-	err := getAdminClient().DeleteColumnFamily(ctx, args[0], args[1])
-	if err != nil {
-		log.Fatalf("Deleting column family: %v", err)
-	}
-}
-
-func doDeleteRow(ctx context.Context, args ...string) {
-	usage := "usage: cbt deleterow <table> <row> [app-profile=<app profile id>]"
-	if len(args) != 2 && len(args) != 3 {
-		log.Fatal(usage)
-	}
-	var appProfile string
-	if len(args) == 3 {
-		if !strings.HasPrefix(args[2], "app-profile=") {
-			log.Fatal(usage)
-		}
-		appProfile = strings.Split(args[2], "=")[1]
-	}
-	tbl := getClient(bigtable.ClientConfig{AppProfile: appProfile}).Open(args[0])
-	mut := bigtable.NewMutation()
-	mut.DeleteRow()
-	if err := tbl.Apply(ctx, args[1], mut); err != nil {
-		log.Fatalf("Deleting row: %v", err)
-	}
-}
-
-func doDeleteTable(ctx context.Context, args ...string) {
-	if len(args) != 1 {
-		log.Fatalf("Can't do `cbt deletetable %s`", args)
-	}
-	err := getAdminClient().DeleteTable(ctx, args[0])
-	if err != nil {
-		log.Fatalf("Deleting table: %v", err)
-	}
-}
-
-// to break circular dependencies
-var (
-	doDocFn   func(ctx context.Context, args ...string)
-	doHelpFn  func(ctx context.Context, args ...string)
-	doMDDocFn func(ctx context.Context, args ...string)
-)
-
-func init() {
-	doDocFn = doDocReal
-	doHelpFn = doHelpReal
-	doMDDocFn = doMDDocReal
-}
-
-func doDoc(ctx context.Context, args ...string)   { doDocFn(ctx, args...) }
-func doHelp(ctx context.Context, args ...string)  { doHelpFn(ctx, args...) }
-func doMDDoc(ctx context.Context, args ...string) { doMDDocFn(ctx, args...) }
-
-func docFlags() []*flag.Flag {
-	// Only include specific flags, in a specific order.
-	var flags []*flag.Flag
-	for _, name := range []string{"project", "instance", "creds"} {
-		f := flag.Lookup(name)
-		if f == nil {
-			log.Fatalf("Flag not linked: -%s", name)
-		}
-		flags = append(flags, f)
-	}
-	return flags
-}
-
-func doDocReal(ctx context.Context, args ...string) {
-	data := map[string]interface{}{
-		"Commands":   commands,
-		"Flags":      docFlags(),
-		"ConfigHelp": configHelp,
-	}
-	var buf bytes.Buffer
-	if err := docTemplate.Execute(&buf, data); err != nil {
-		log.Fatalf("Bad doc template: %v", err)
-	}
-	out, err := format.Source(buf.Bytes())
-	if err != nil {
-		log.Fatalf("Bad doc output: %v", err)
-	}
-	os.Stdout.Write(out)
-}
-
-func indentLines(s, ind string) string {
-	ss := strings.Split(s, "\n")
-	for i, p := range ss {
-		ss[i] = ind + p
-	}
-	return strings.Join(ss, "\n")
-}
-
-var docTemplate = template.Must(template.New("doc").Funcs(template.FuncMap{
-	"indent": indentLines,
-}).
-	Parse(`
-// Copyright 2016 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
-//
-//      http://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.
-
-// DO NOT EDIT. THIS IS AUTOMATICALLY GENERATED.
-// Run "go generate" to regenerate.
-//go:generate go run cbt.go gcpolicy.go -o cbtdoc.go doc
-
-/*
-Cbt is a tool for doing basic interactions with Cloud Bigtable. To learn how to
-install the cbt tool, see the
-[cbt overview](https://cloud.google.com/bigtable/docs/cbt-overview).
-
-Usage:
-
-	cbt [options] command [arguments]
-
-The commands are:
-{{range .Commands}}
-	{{printf "%-25s %s" .Name .Desc}}{{end}}
-
-Use "cbt help <command>" for more information about a command.
-
-The options are:
-{{range .Flags}}
-	-{{.Name}} string
-		{{.Usage}}{{end}}
-
-{{.ConfigHelp}}
-
-{{range .Commands}}
-{{.Desc}}
-
-Usage:
-{{indent .Usage "\t"}}
-
-
-
-{{end}}
-*/
-package main
-`))
-
-func doHelpReal(ctx context.Context, args ...string) {
-	if len(args) == 0 {
-		usage(os.Stdout)
-		return
-	}
-	for _, cmd := range commands {
-		if cmd.Name == args[0] {
-			fmt.Println(cmd.Usage)
-			return
-		}
-	}
-	log.Fatalf("Don't know command %q", args[0])
-}
-
-func doListInstances(ctx context.Context, args ...string) {
-	if len(args) != 0 {
-		log.Fatalf("usage: cbt listinstances")
-	}
-	is, err := getInstanceAdminClient().Instances(ctx)
-	if err != nil {
-		log.Fatalf("Getting list of instances: %v", err)
-	}
-	tw := tabwriter.NewWriter(os.Stdout, 10, 8, 4, '\t', 0)
-	fmt.Fprintf(tw, "Instance Name\tInfo\n")
-	fmt.Fprintf(tw, "-------------\t----\n")
-	for _, i := range is {
-		fmt.Fprintf(tw, "%s\t%s\n", i.Name, i.DisplayName)
-	}
-	tw.Flush()
-}
-
-func doListClusters(ctx context.Context, args ...string) {
-	if len(args) != 0 {
-		log.Fatalf("usage: cbt listclusters")
-	}
-	cis, err := getInstanceAdminClient().Clusters(ctx, config.Instance)
-	if err != nil {
-		log.Fatalf("Getting list of clusters: %v", err)
-	}
-	tw := tabwriter.NewWriter(os.Stdout, 10, 8, 4, '\t', 0)
-	fmt.Fprintf(tw, "Cluster Name\tZone\tState\n")
-	fmt.Fprintf(tw, "------------\t----\t----\n")
-	for _, ci := range cis {
-		fmt.Fprintf(tw, "%s\t%s\t%s (%d serve nodes)\n", ci.Name, ci.Zone, ci.State, ci.ServeNodes)
-	}
-	tw.Flush()
-}
-
-func doLookup(ctx context.Context, args ...string) {
-	if len(args) < 2 {
-		log.Fatalf("usage: cbt lookup <table> <row> [columns=<family:qualifier>...] [cells-per-column=<n>] " +
-			"[app-profile=<app profile id>]")
-	}
-
-	parsed, err := parseArgs(args[2:], []string{"columns", "cells-per-column", "app-profile"})
-	if err != nil {
-		log.Fatal(err)
-	}
-	var opts []bigtable.ReadOption
-	var filters []bigtable.Filter
-	if cellsPerColumn := parsed["cells-per-column"]; cellsPerColumn != "" {
-		n, err := strconv.Atoi(cellsPerColumn)
-		if err != nil {
-			log.Fatalf("Bad number of cells per column %q: %v", cellsPerColumn, err)
-		}
-		filters = append(filters, bigtable.LatestNFilter(n))
-	}
-	if columns := parsed["columns"]; columns != "" {
-		columnFilters, err := parseColumnsFilter(columns)
-		if err != nil {
-			log.Fatal(err)
-		}
-		filters = append(filters, columnFilters)
-	}
-
-	if len(filters) > 1 {
-		opts = append(opts, bigtable.RowFilter(bigtable.ChainFilters(filters...)))
-	} else if len(filters) == 1 {
-		opts = append(opts, bigtable.RowFilter(filters[0]))
-	}
-
-	table, row := args[0], args[1]
-	tbl := getClient(bigtable.ClientConfig{AppProfile: parsed["app-profile"]}).Open(table)
-	r, err := tbl.ReadRow(ctx, row, opts...)
-	if err != nil {
-		log.Fatalf("Reading row: %v", err)
-	}
-	printRow(r)
-}
-
-func printRow(r bigtable.Row) {
-	fmt.Println(strings.Repeat("-", 40))
-	fmt.Println(r.Key())
-
-	var fams []string
-	for fam := range r {
-		fams = append(fams, fam)
-	}
-	sort.Strings(fams)
-	for _, fam := range fams {
-		ris := r[fam]
-		sort.Sort(byColumn(ris))
-		for _, ri := range ris {
-			ts := time.Unix(0, int64(ri.Timestamp)*1e3)
-			fmt.Printf("  %-40s @ %s\n", ri.Column, ts.Format("2006/01/02-15:04:05.000000"))
-			fmt.Printf("    %q\n", ri.Value)
-		}
-	}
-}
-
-type byColumn []bigtable.ReadItem
-
-func (b byColumn) Len() int           { return len(b) }
-func (b byColumn) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
-func (b byColumn) Less(i, j int) bool { return b[i].Column < b[j].Column }
-
-type byFamilyName []bigtable.FamilyInfo
-
-func (b byFamilyName) Len() int           { return len(b) }
-func (b byFamilyName) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
-func (b byFamilyName) Less(i, j int) bool { return b[i].Name < b[j].Name }
-
-func doLS(ctx context.Context, args ...string) {
-	switch len(args) {
-	default:
-		log.Fatalf("Can't do `cbt ls %s`", args)
-	case 0:
-		tables, err := getAdminClient().Tables(ctx)
-		if err != nil {
-			log.Fatalf("Getting list of tables: %v", err)
-		}
-		sort.Strings(tables)
-		for _, table := range tables {
-			fmt.Println(table)
-		}
-	case 1:
-		table := args[0]
-		ti, err := getAdminClient().TableInfo(ctx, table)
-		if err != nil {
-			log.Fatalf("Getting table info: %v", err)
-		}
-		sort.Sort(byFamilyName(ti.FamilyInfos))
-		tw := tabwriter.NewWriter(os.Stdout, 10, 8, 4, '\t', 0)
-		fmt.Fprintf(tw, "Family Name\tGC Policy\n")
-		fmt.Fprintf(tw, "-----------\t---------\n")
-		for _, fam := range ti.FamilyInfos {
-			fmt.Fprintf(tw, "%s\t%s\n", fam.Name, fam.GCPolicy)
-		}
-		tw.Flush()
-	}
-}
-
-func doMDDocReal(ctx context.Context, args ...string) {
-	data := map[string]interface{}{
-		"Commands":   commands,
-		"Flags":      docFlags(),
-		"ConfigHelp": configHelp,
-	}
-	var buf bytes.Buffer
-	if err := mddocTemplate.Execute(&buf, data); err != nil {
-		log.Fatalf("Bad mddoc template: %v", err)
-	}
-	io.Copy(os.Stdout, &buf)
-}
-
-var mddocTemplate = template.Must(template.New("mddoc").Funcs(template.FuncMap{
-	"indent": indentLines,
-}).
-	Parse(`
-Cbt is a tool for doing basic interactions with Cloud Bigtable. To learn how to
-install the cbt tool, see the
-[cbt overview](https://cloud.google.com/bigtable/docs/cbt-overview).
-
-Usage:
-
-	cbt [options] command [arguments]
-
-The commands are:
-{{range .Commands}}
-	{{printf "%-25s %s" .Name .Desc}}{{end}}
-
-Use "cbt help <command>" for more information about a command.
-
-The options are:
-{{range .Flags}}
-	-{{.Name}} string
-		{{.Usage}}{{end}}
-
-{{.ConfigHelp}}
-
-{{range .Commands}}
-## {{.Desc}}
-
-{{indent .Usage "\t"}}
-
-
-
-{{end}}
-`))
-
-func doRead(ctx context.Context, args ...string) {
-	if len(args) < 1 {
-		log.Fatalf("usage: cbt read <table> [args ...]")
-	}
-
-	parsed, err := parseArgs(args[1:], []string{
-		"start", "end", "prefix", "columns", "count", "cells-per-column", "regex", "app-profile", "limit",
-	})
-	if err != nil {
-		log.Fatal(err)
-	}
-	if _, ok := parsed["limit"]; ok {
-		// Be nicer; we used to support this, but renamed it to "end".
-		log.Fatal("Unknown arg key 'limit'; did you mean 'end'?")
-	}
-	if (parsed["start"] != "" || parsed["end"] != "") && parsed["prefix"] != "" {
-		log.Fatal(`"start"/"end" may not be mixed with "prefix"`)
-	}
-
-	var rr bigtable.RowRange
-	if start, end := parsed["start"], parsed["end"]; end != "" {
-		rr = bigtable.NewRange(start, end)
-	} else if start != "" {
-		rr = bigtable.InfiniteRange(start)
-	}
-	if prefix := parsed["prefix"]; prefix != "" {
-		rr = bigtable.PrefixRange(prefix)
-	}
-
-	var opts []bigtable.ReadOption
-	if count := parsed["count"]; count != "" {
-		n, err := strconv.ParseInt(count, 0, 64)
-		if err != nil {
-			log.Fatalf("Bad count %q: %v", count, err)
-		}
-		opts = append(opts, bigtable.LimitRows(n))
-	}
-
-	var filters []bigtable.Filter
-	if cellsPerColumn := parsed["cells-per-column"]; cellsPerColumn != "" {
-		n, err := strconv.Atoi(cellsPerColumn)
-		if err != nil {
-			log.Fatalf("Bad number of cells per column %q: %v", cellsPerColumn, err)
-		}
-		filters = append(filters, bigtable.LatestNFilter(n))
-	}
-	if regex := parsed["regex"]; regex != "" {
-		filters = append(filters, bigtable.RowKeyFilter(regex))
-	}
-	if columns := parsed["columns"]; columns != "" {
-		columnFilters, err := parseColumnsFilter(columns)
-		if err != nil {
-			log.Fatal(err)
-		}
-		filters = append(filters, columnFilters)
-	}
-
-	if len(filters) > 1 {
-		opts = append(opts, bigtable.RowFilter(bigtable.ChainFilters(filters...)))
-	} else if len(filters) == 1 {
-		opts = append(opts, bigtable.RowFilter(filters[0]))
-	}
-
-	// TODO(dsymonds): Support filters.
-	tbl := getClient(bigtable.ClientConfig{AppProfile: parsed["app-profile"]}).Open(args[0])
-	err = tbl.ReadRows(ctx, rr, func(r bigtable.Row) bool {
-		printRow(r)
-		return true
-	}, opts...)
-	if err != nil {
-		log.Fatalf("Reading rows: %v", err)
-	}
-}
-
-var setArg = regexp.MustCompile(`([^:]+):([^=]*)=(.*)`)
-
-func doSet(ctx context.Context, args ...string) {
-	if len(args) < 3 {
-		log.Fatalf("usage: cbt set <table> <row> [app-profile=<app profile id>] family:[column]=val[@ts] ...")
-	}
-	var appProfile string
-	row := args[1]
-	mut := bigtable.NewMutation()
-	for _, arg := range args[2:] {
-		if strings.HasPrefix(arg, "app-profile=") {
-			appProfile = strings.Split(arg, "=")[1]
-			continue
-		}
-		m := setArg.FindStringSubmatch(arg)
-		if m == nil {
-			log.Fatalf("Bad set arg %q", arg)
-		}
-		val := m[3]
-		ts := bigtable.Now()
-		if i := strings.LastIndex(val, "@"); i >= 0 {
-			// Try parsing a timestamp.
-			n, err := strconv.ParseInt(val[i+1:], 0, 64)
-			if err == nil {
-				val = val[:i]
-				ts = bigtable.Timestamp(n)
-			}
-		}
-		mut.Set(m[1], m[2], ts, []byte(val))
-	}
-	tbl := getClient(bigtable.ClientConfig{AppProfile: appProfile}).Open(args[0])
-	if err := tbl.Apply(ctx, row, mut); err != nil {
-		log.Fatalf("Applying mutation: %v", err)
-	}
-}
-
-func doSetGCPolicy(ctx context.Context, args ...string) {
-	if len(args) < 3 {
-		log.Fatalf("usage: cbt setgcpolicy <table> <family> ((maxage=<d> | maxversions=<n>) [(and|or) (maxage=<d> | maxversions=<n>),...] | never)")
-	}
-	table := args[0]
-	fam := args[1]
-	pol, err := parseGCPolicy(strings.Join(args[2:], " "))
-	if err != nil {
-		log.Fatal(err)
-	}
-	if err := getAdminClient().SetGCPolicy(ctx, table, fam, pol); err != nil {
-		log.Fatalf("Setting GC policy: %v", err)
-	}
-}
-
-func doWaitForReplicaiton(ctx context.Context, args ...string) {
-	if len(args) != 1 {
-		log.Fatalf("usage: cbt waitforreplication <table>")
-	}
-	table := args[0]
-
-	fmt.Printf("Waiting for all writes up to %s to be replicated.\n", time.Now().Format("2006/01/02-15:04:05"))
-	if err := getAdminClient().WaitForReplication(ctx, table); err != nil {
-		log.Fatalf("Waiting for replication: %v", err)
-	}
-}
-
-func parseStorageType(storageTypeStr string) (bigtable.StorageType, error) {
-	switch storageTypeStr {
-	case "SSD":
-		return bigtable.SSD, nil
-	case "HDD":
-		return bigtable.HDD, nil
-	}
-	return -1, fmt.Errorf("Invalid storage type: %v, must be SSD or HDD", storageTypeStr)
-}
-
-func doCreateTableFromSnapshot(ctx context.Context, args ...string) {
-	if len(args) != 3 {
-		log.Fatal("usage: cbt createtablefromsnapshot <table> <cluster> <snapshot>")
-	}
-	tableName := args[0]
-	clusterName := args[1]
-	snapshotName := args[2]
-	err := getAdminClient().CreateTableFromSnapshot(ctx, tableName, clusterName, snapshotName)
-
-	if err != nil {
-		log.Fatalf("Creating table: %v", err)
-	}
-}
-
-func doSnapshotTable(ctx context.Context, args ...string) {
-	if len(args) != 3 && len(args) != 4 {
-		log.Fatal("usage: cbt createsnapshot <cluster> <snapshot> <table> [ttl=<d>]")
-	}
-	clusterName := args[0]
-	snapshotName := args[1]
-	tableName := args[2]
-	ttl := bigtable.DefaultSnapshotDuration
-
-	parsed, err := parseArgs(args[3:], []string{"ttl"})
-	if err != nil {
-		log.Fatal(err)
-	}
-	if val, ok := parsed["ttl"]; ok {
-		var err error
-		ttl, err = parseDuration(val)
-		if err != nil {
-			log.Fatalf("Invalid snapshot ttl value %q: %v", val, err)
-		}
-	}
-
-	err = getAdminClient().SnapshotTable(ctx, tableName, clusterName, snapshotName, ttl)
-	if err != nil {
-		log.Fatalf("Failed to create Snapshot: %v", err)
-	}
-}
-
-func doListSnapshots(ctx context.Context, args ...string) {
-	if len(args) != 0 && len(args) != 1 {
-		log.Fatal("usage: cbt listsnapshots [<cluster>]")
-	}
-
-	var cluster string
-
-	if len(args) == 0 {
-		cluster = "-"
-	} else {
-		cluster = args[0]
-	}
-
-	it := getAdminClient().Snapshots(ctx, cluster)
-
-	tw := tabwriter.NewWriter(os.Stdout, 10, 8, 4, '\t', 0)
-	fmt.Fprintf(tw, "Snapshot\tSource Table\tCreated At\tExpires At\n")
-	fmt.Fprintf(tw, "--------\t------------\t----------\t----------\n")
-	timeLayout := "2006-01-02 15:04 MST"
-
-	for {
-		snapshot, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			log.Fatalf("Failed to fetch snapshots %v", err)
-		}
-		fmt.Fprintf(tw, "%s\t%s\t%s\t%s\n", snapshot.Name, snapshot.SourceTable, snapshot.CreateTime.Format(timeLayout), snapshot.DeleteTime.Format(timeLayout))
-	}
-	tw.Flush()
-}
-
-func doGetSnapshot(ctx context.Context, args ...string) {
-	if len(args) != 2 {
-		log.Fatalf("usage: cbt getsnapshot <cluster> <snapshot>")
-	}
-	clusterName := args[0]
-	snapshotName := args[1]
-
-	snapshot, err := getAdminClient().SnapshotInfo(ctx, clusterName, snapshotName)
-	if err != nil {
-		log.Fatalf("Failed to get snapshot: %v", err)
-	}
-
-	timeLayout := "2006-01-02 15:04 MST"
-
-	fmt.Printf("Name: %s\n", snapshot.Name)
-	fmt.Printf("Source table: %s\n", snapshot.SourceTable)
-	fmt.Printf("Created at: %s\n", snapshot.CreateTime.Format(timeLayout))
-	fmt.Printf("Expires at: %s\n", snapshot.DeleteTime.Format(timeLayout))
-}
-
-func doDeleteSnapshot(ctx context.Context, args ...string) {
-	if len(args) != 2 {
-		log.Fatal("usage: cbt deletesnapshot <cluster> <snapshot>")
-	}
-	cluster := args[0]
-	snapshot := args[1]
-
-	err := getAdminClient().DeleteSnapshot(ctx, cluster, snapshot)
-
-	if err != nil {
-		log.Fatalf("Failed to delete snapshot: %v", err)
-	}
-}
-
-func doCreateAppProfile(ctx context.Context, args ...string) {
-	if len(args) < 4 || len(args) > 6 {
-		log.Fatal("usage: cbt createappprofile <instance-id> <profile-id> <description> " +
-			" (route-any | [ route-to=<cluster-id> : transactional-writes]) [optional flag] \n" +
-			"optional flags may be `force`")
-	}
-
-	routingPolicy, clusterID, err := parseProfileRoute(args[3])
-	if err != nil {
-		log.Fatalln("Exactly one of (route-any | [route-to : transactional-writes]) must be specified.")
-	}
-
-	config := bigtable.ProfileConf{
-		RoutingPolicy: routingPolicy,
-		InstanceID:    args[0],
-		ProfileID:     args[1],
-		Description:   args[2],
-	}
-
-	opFlags := []string{"force", "transactional-writes"}
-	parseValues, err := parseArgs(args[4:], opFlags)
-	if err != nil {
-		log.Fatalf("optional flags can be specified as (force=<true>|transactional-writes=<true>) got %s ", args[4:])
-	}
-
-	for _, f := range opFlags {
-		fv, err := parseProfileOpts(f, parseValues)
-		if err != nil {
-			log.Fatalf("optional flags can be specified as (force=<true>|transactional-writes=<true>) got %s ", args[4:])
-		}
-
-		switch f {
-		case opFlags[0]:
-			config.IgnoreWarnings = fv
-		case opFlags[1]:
-			config.AllowTransactionalWrites = fv
-		default:
-
-		}
-	}
-
-	if routingPolicy == bigtable.SingleClusterRouting {
-		config.ClusterID = clusterID
-	}
-
-	profile, err := getInstanceAdminClient().CreateAppProfile(ctx, config)
-	if err != nil {
-		log.Fatalf("Failed to create app profile : %v", err)
-	}
-
-	fmt.Printf("Name: %s\n", profile.Name)
-	fmt.Printf("RoutingPolicy: %v\n", profile.RoutingPolicy)
-}
-
-func doGetAppProfile(ctx context.Context, args ...string) {
-	if len(args) != 2 {
-		log.Fatalln("usage: cbt getappprofile <instance-id> <profile-id>")
-	}
-
-	instanceID := args[0]
-	profileID := args[1]
-	profile, err := getInstanceAdminClient().GetAppProfile(ctx, instanceID, profileID)
-	if err != nil {
-		log.Fatalf("Failed to get app profile : %v", err)
-	}
-
-	fmt.Printf("Name: %s\n", profile.Name)
-	fmt.Printf("Etag: %s\n", profile.Etag)
-	fmt.Printf("Description: %s\n", profile.Description)
-	fmt.Printf("RoutingPolicy: %v\n", profile.RoutingPolicy)
-}
-
-func doListAppProfiles(ctx context.Context, args ...string) {
-	if len(args) != 1 {
-		log.Fatalln("usage: cbt listappprofile <instance-id>")
-	}
-
-	instance := args[0]
-
-	it := getInstanceAdminClient().ListAppProfiles(ctx, instance)
-
-	tw := tabwriter.NewWriter(os.Stdout, 10, 8, 4, '\t', 0)
-	fmt.Fprintf(tw, "AppProfile\tProfile Description\tProfile Etag\tProfile Routing Policy\n")
-	fmt.Fprintf(tw, "-----------\t--------------------\t------------\t----------------------\n")
-
-	for {
-		profile, err := it.Next()
-		if err == iterator.Done {
-			break
-		}
-		if err != nil {
-			log.Fatalf("Failed to fetch app profile %v", err)
-		}
-		fmt.Fprintf(tw, "%s\t%s\t%s\t%s\n", profile.Name, profile.Description, profile.Etag, profile.RoutingPolicy)
-	}
-	tw.Flush()
-}
-
-func doUpdateAppProfile(ctx context.Context, args ...string) {
-
-	if len(args) < 4 {
-		log.Fatal("usage: cbt updateappprofile  <instance-id> <profile-id> <description>" +
-			" (route-any | [ route-to=<cluster-id> : transactional-writes]) [optional flag] \n" +
-			"optional flags may be `force`")
-	}
-
-	routingPolicy, clusterID, err := parseProfileRoute(args[3])
-	if err != nil {
-		log.Fatalln("Exactly one of (route-any | [route-to : transactional-writes]) must be specified.")
-	}
-	InstanceID := args[0]
-	ProfileID := args[1]
-	config := bigtable.ProfileAttrsToUpdate{
-		RoutingPolicy: routingPolicy,
-		Description:   args[2],
-	}
-	opFlags := []string{"force", "transactional-writes"}
-	parseValues, err := parseArgs(args[4:], opFlags)
-	if err != nil {
-		log.Fatalf("optional flags can be specified as (force=<true>|transactional-writes=<true>) got %s ", args[4:])
-	}
-
-	for _, f := range opFlags {
-		fv, err := parseProfileOpts(f, parseValues)
-		if err != nil {
-			log.Fatalf("optional flags can be specified as (force=<true>|transactional-writes=<true>) got %s ", args[4:])
-		}
-
-		switch f {
-		case opFlags[0]:
-			config.IgnoreWarnings = fv
-		case opFlags[1]:
-			config.AllowTransactionalWrites = fv
-		default:
-
-		}
-	}
-	if routingPolicy == bigtable.SingleClusterRouting {
-		config.ClusterID = clusterID
-	}
-
-	err = getInstanceAdminClient().UpdateAppProfile(ctx, InstanceID, ProfileID, config)
-	if err != nil {
-		log.Fatalf("Failed to update app profile : %v", err)
-	}
-}
-
-func doDeleteAppProfile(ctx context.Context, args ...string) {
-	if len(args) != 2 {
-		log.Println("usage: cbt deleteappprofile <instance-id> <profile-id>")
-	}
-
-	err := getInstanceAdminClient().DeleteAppProfile(ctx, args[0], args[1])
-	if err != nil {
-		log.Fatalf("Failed to delete  app profile : %v", err)
-	}
-}
-
-// parseDuration parses a duration string.
-// It is similar to Go's time.ParseDuration, except with a different set of supported units,
-// and only simple formats supported.
-func parseDuration(s string) (time.Duration, error) {
-	// [0-9]+[a-z]+
-
-	// Split [0-9]+ from [a-z]+.
-	i := 0
-	for ; i < len(s); i++ {
-		c := s[i]
-		if c < '0' || c > '9' {
-			break
-		}
-	}
-	ds, u := s[:i], s[i:]
-	if ds == "" || u == "" {
-		return 0, fmt.Errorf("invalid duration %q", s)
-	}
-	// Parse them.
-	d, err := strconv.ParseUint(ds, 10, 32)
-	if err != nil {
-		return 0, fmt.Errorf("invalid duration %q: %v", s, err)
-	}
-	unit, ok := unitMap[u]
-	if !ok {
-		return 0, fmt.Errorf("unknown unit %q in duration %q", u, s)
-	}
-	if d > uint64((1<<63-1)/unit) {
-		// overflow
-		return 0, fmt.Errorf("invalid duration %q overflows", s)
-	}
-	return time.Duration(d) * unit, nil
-}
-
-var unitMap = map[string]time.Duration{
-	"ms": time.Millisecond,
-	"s":  time.Second,
-	"m":  time.Minute,
-	"h":  time.Hour,
-	"d":  24 * time.Hour,
-}
-
-func doVersion(ctx context.Context, args ...string) {
-	fmt.Printf("%s %s %s\n", version, revision, revisionDate)
-}
-
-// parseArgs takes a slice of arguments of the form key=value and returns a map from
-// key to value. It returns an error if an argument is malformed or a key is not in
-// the valid slice.
-func parseArgs(args []string, valid []string) (map[string]string, error) {
-	parsed := make(map[string]string)
-	for _, arg := range args {
-		i := strings.Index(arg, "=")
-		if i < 0 {
-			return nil, fmt.Errorf("Bad arg %q", arg)
-		}
-		key, val := arg[:i], arg[i+1:]
-		if !stringInSlice(key, valid) {
-			return nil, fmt.Errorf("Unknown arg key %q", key)
-		}
-		parsed[key] = val
-	}
-	return parsed, nil
-}
-
-func stringInSlice(s string, list []string) bool {
-	for _, e := range list {
-		if s == e {
-			return true
-		}
-	}
-	return false
-}
-
-func parseColumnsFilter(columns string) (bigtable.Filter, error) {
-	splitColumns := strings.FieldsFunc(columns, func(c rune) bool { return c == ',' })
-	if len(splitColumns) == 1 {
-		filter, err := columnFilter(splitColumns[0])
-		if err != nil {
-			return nil, err
-		}
-		return filter, nil
-	}
-
-	var columnFilters []bigtable.Filter
-	for _, column := range splitColumns {
-		filter, err := columnFilter(column)
-		if err != nil {
-			return nil, err
-		}
-		columnFilters = append(columnFilters, filter)
-	}
-	return bigtable.InterleaveFilters(columnFilters...), nil
-}
-
-func columnFilter(column string) (bigtable.Filter, error) {
-	splitColumn := strings.Split(column, ":")
-	if len(splitColumn) == 1 {
-		return bigtable.ColumnFilter(splitColumn[0]), nil
-	} else if len(splitColumn) == 2 {
-		if strings.HasSuffix(column, ":") {
-			return bigtable.FamilyFilter(splitColumn[0]), nil
-		} else if strings.HasPrefix(column, ":") {
-			return bigtable.ColumnFilter(splitColumn[1]), nil
-		} else {
-			familyFilter := bigtable.FamilyFilter(splitColumn[0])
-			qualifierFilter := bigtable.ColumnFilter(splitColumn[1])
-			return bigtable.ChainFilters(familyFilter, qualifierFilter), nil
-		}
-	} else {
-		return nil, fmt.Errorf("Bad format for column %q", column)
-	}
-}
-
-func parseProfileRoute(str string) (routingPolicy, clusterID string, err error) {
-
-	route := strings.Split(str, "=")
-	switch route[0] {
-	case "route-any":
-		if len(route) > 1 {
-			err = fmt.Errorf("got %v", route)
-			break
-		}
-		routingPolicy = bigtable.MultiClusterRouting
-
-	case "route-to":
-		if len(route) != 2 || route[1] == "" {
-			err = fmt.Errorf("got %v", route)
-			break
-		}
-		routingPolicy = bigtable.SingleClusterRouting
-		clusterID = route[1]
-	default:
-		err = fmt.Errorf("got %v", route)
-	}
-
-	return
-}
-
-func parseProfileOpts(opt string, parsedArgs map[string]string) (bool, error) {
-
-	if val, ok := parsedArgs[opt]; ok {
-		status, err := strconv.ParseBool(val)
-		if err != nil {
-			return false, fmt.Errorf("expected %s = <true> got %s ", opt, val)
-		}
-
-		return status, nil
-	}
-	return false, nil
-}

+ 0 - 173
vendor/cloud.google.com/go/bigtable/cmd/cbt/cbt_test.go

@@ -1,173 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-package main
-
-import (
-	"testing"
-	"time"
-
-	"cloud.google.com/go/bigtable"
-	"cloud.google.com/go/internal/testutil"
-	"github.com/google/go-cmp/cmp"
-)
-
-func TestParseDuration(t *testing.T) {
-	tests := []struct {
-		in string
-		// out or fail are mutually exclusive
-		out  time.Duration
-		fail bool
-	}{
-		{in: "10ms", out: 10 * time.Millisecond},
-		{in: "3s", out: 3 * time.Second},
-		{in: "60m", out: 60 * time.Minute},
-		{in: "12h", out: 12 * time.Hour},
-		{in: "7d", out: 168 * time.Hour},
-
-		{in: "", fail: true},
-		{in: "0", fail: true},
-		{in: "7ns", fail: true},
-		{in: "14mo", fail: true},
-		{in: "3.5h", fail: true},
-		{in: "106752d", fail: true}, // overflow
-	}
-	for _, tc := range tests {
-		got, err := parseDuration(tc.in)
-		if !tc.fail && err != nil {
-			t.Errorf("parseDuration(%q) unexpectedly failed: %v", tc.in, err)
-			continue
-		}
-		if tc.fail && err == nil {
-			t.Errorf("parseDuration(%q) did not fail", tc.in)
-			continue
-		}
-		if tc.fail {
-			continue
-		}
-		if got != tc.out {
-			t.Errorf("parseDuration(%q) = %v, want %v", tc.in, got, tc.out)
-		}
-	}
-}
-
-func TestParseArgs(t *testing.T) {
-	got, err := parseArgs([]string{"a=1", "b=2"}, []string{"a", "b"})
-	if err != nil {
-		t.Fatal(err)
-	}
-	want := map[string]string{"a": "1", "b": "2"}
-	if !testutil.Equal(got, want) {
-		t.Fatalf("got %v, want %v", got, want)
-	}
-
-	if _, err := parseArgs([]string{"a1"}, []string{"a1"}); err == nil {
-		t.Error("malformed: got nil, want error")
-	}
-	if _, err := parseArgs([]string{"a=1"}, []string{"b"}); err == nil {
-		t.Error("invalid: got nil, want error")
-	}
-}
-
-func TestParseColumnsFilter(t *testing.T) {
-	tests := []struct {
-		in   string
-		out  bigtable.Filter
-		fail bool
-	}{
-		{
-			in:  "columnA",
-			out: bigtable.ColumnFilter("columnA"),
-		},
-		{
-			in:  "familyA:columnA",
-			out: bigtable.ChainFilters(bigtable.FamilyFilter("familyA"), bigtable.ColumnFilter("columnA")),
-		},
-		{
-			in:  "columnA,columnB",
-			out: bigtable.InterleaveFilters(bigtable.ColumnFilter("columnA"), bigtable.ColumnFilter("columnB")),
-		},
-		{
-			in: "familyA:columnA,columnB",
-			out: bigtable.InterleaveFilters(
-				bigtable.ChainFilters(bigtable.FamilyFilter("familyA"), bigtable.ColumnFilter("columnA")),
-				bigtable.ColumnFilter("columnB"),
-			),
-		},
-		{
-			in: "columnA,familyB:columnB",
-			out: bigtable.InterleaveFilters(
-				bigtable.ColumnFilter("columnA"),
-				bigtable.ChainFilters(bigtable.FamilyFilter("familyB"), bigtable.ColumnFilter("columnB")),
-			),
-		},
-		{
-			in: "familyA:columnA,familyB:columnB",
-			out: bigtable.InterleaveFilters(
-				bigtable.ChainFilters(bigtable.FamilyFilter("familyA"), bigtable.ColumnFilter("columnA")),
-				bigtable.ChainFilters(bigtable.FamilyFilter("familyB"), bigtable.ColumnFilter("columnB")),
-			),
-		},
-		{
-			in:  "familyA:",
-			out: bigtable.FamilyFilter("familyA"),
-		},
-		{
-			in:  ":columnA",
-			out: bigtable.ColumnFilter("columnA"),
-		},
-		{
-			in: ",:columnA,,familyB:columnB,",
-			out: bigtable.InterleaveFilters(
-				bigtable.ColumnFilter("columnA"),
-				bigtable.ChainFilters(bigtable.FamilyFilter("familyB"), bigtable.ColumnFilter("columnB")),
-			),
-		},
-		{
-			in:   "familyA:columnA:cellA",
-			fail: true,
-		},
-		{
-			in:   "familyA::columnA",
-			fail: true,
-		},
-	}
-
-	for _, tc := range tests {
-		got, err := parseColumnsFilter(tc.in)
-
-		if !tc.fail && err != nil {
-			t.Errorf("parseColumnsFilter(%q) unexpectedly failed: %v", tc.in, err)
-			continue
-		}
-		if tc.fail && err == nil {
-			t.Errorf("parseColumnsFilter(%q) did not fail", tc.in)
-			continue
-		}
-		if tc.fail {
-			continue
-		}
-
-		var cmpOpts cmp.Options
-		cmpOpts =
-			append(
-				cmpOpts,
-				cmp.AllowUnexported(bigtable.ChainFilters([]bigtable.Filter{}...)),
-				cmp.AllowUnexported(bigtable.InterleaveFilters([]bigtable.Filter{}...)))
-
-		if !cmp.Equal(got, tc.out, cmpOpts) {
-			t.Errorf("parseColumnsFilter(%q) = %v, want %v", tc.in, got, tc.out)
-		}
-	}
-}

+ 0 - 425
vendor/cloud.google.com/go/bigtable/cmd/cbt/cbtdoc.go

@@ -1,425 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-// DO NOT EDIT. THIS IS AUTOMATICALLY GENERATED.
-// Run "go generate" to regenerate.
-//go:generate go run cbt.go gcpolicy.go -o cbtdoc.go doc
-
-/*
-Cbt is a tool for doing basic interactions with Cloud Bigtable. To learn how to
-install the cbt tool, see the
-[cbt overview](https://cloud.google.com/bigtable/docs/cbt-overview).
-
-Usage:
-
-	cbt [options] command [arguments]
-
-The commands are:
-
-	count                     Count rows in a table
-	createinstance            Create an instance with an initial cluster
-	createcluster             Create a cluster in the configured instance
-	createfamily              Create a column family
-	createtable               Create a table
-	updatecluster             Update a cluster in the configured instance
-	deleteinstance            Delete an instance
-	deletecluster             Delete a cluster from the configured instance
-	deletecolumn              Delete all cells in a column
-	deletefamily              Delete a column family
-	deleterow                 Delete a row
-	deletetable               Delete a table
-	doc                       Print godoc-suitable documentation for cbt
-	help                      Print help text
-	listinstances             List instances in a project
-	listclusters              List clusters in an instance
-	lookup                    Read from a single row
-	ls                        List tables and column families
-	mddoc                     Print documentation for cbt in Markdown format
-	read                      Read rows
-	set                       Set value of a cell
-	setgcpolicy               Set the GC policy for a column family
-	waitforreplication        Block until all the completed writes have been replicated to all the clusters
-	createtablefromsnapshot   Create a table from a snapshot (snapshots alpha)
-	createsnapshot            Create a snapshot from a source table (snapshots alpha)
-	listsnapshots             List snapshots in a cluster (snapshots alpha)
-	getsnapshot               Get snapshot info (snapshots alpha)
-	deletesnapshot            Delete snapshot in a cluster (snapshots alpha)
-	version                   Print the current cbt version
-	createappprofile          Creates app profile for an instance
-	getappprofile             Reads app profile for an instance
-	listappprofile            Lists app profile for an instance
-	updateappprofile          Updates app profile for an instance
-	deleteappprofile          Deletes app profile for an instance
-
-Use "cbt help <command>" for more information about a command.
-
-The options are:
-
-	-project string
-		project ID, if unset uses gcloud configured project
-	-instance string
-		Cloud Bigtable instance
-	-creds string
-		if set, use application credentials in this file
-
-
-Alpha features are not currently available to most Cloud Bigtable customers. The
-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 Bigtable otherwise supports (e.g., row key, column qualifier,
-etc.).
-
-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
-
-All values are optional, and all will be overridden by flags.
-
-
-
-Count rows in a table
-
-Usage:
-	cbt count <table>
-
-
-
-
-Create an instance with an initial cluster
-
-Usage:
-	cbt createinstance <instance-id> <display-name> <cluster-id> <zone> <num-nodes> <storage type>
-	  instance-id					Permanent, unique id for the instance
-	  display-name	  			Description of the instance
-	  cluster-id						Permanent, unique id for the cluster in the instance
-	  zone				  				The zone in which to create the cluster
-	  num-nodes	  				The number of nodes to create
-	  storage-type					SSD or HDD
-
-
-
-
-
-Create a cluster in the configured instance
-
-Usage:
-	cbt createcluster <cluster-id> <zone> <num-nodes> <storage type>
-	  cluster-id		Permanent, unique id for the cluster in the instance
-	  zone				  The zone in which to create the cluster
-	  num-nodes	  The number of nodes to create
-	  storage-type	SSD or HDD
-
-
-
-
-
-Create a column family
-
-Usage:
-	cbt createfamily <table> <family>
-
-
-
-
-Create a table
-
-Usage:
-	cbt createtable <table> [families=family[:gcpolicy],...] [splits=split,...]
-	  families: Column families and their associated GC policies. For gcpolicy,
-	  					see "setgcpolicy".
-						Example: families=family1:maxage=1w,family2:maxversions=1
-	  splits:   Row key to be used to initially split the table
-
-
-
-
-Update a cluster in the configured instance
-
-Usage:
-	cbt updatecluster <cluster-id> [num-nodes=num-nodes]
-	  cluster-id		Permanent, unique id for the cluster in the instance
-	  num-nodes		The number of nodes to update to
-
-
-
-
-Delete an instance
-
-Usage:
-	cbt deleteinstance <instance>
-
-
-
-
-Delete a cluster from the configured instance
-
-Usage:
-	cbt deletecluster <cluster>
-
-
-
-
-Delete all cells in a column
-
-Usage:
-	cbt deletecolumn <table> <row> <family> <column> [app-profile=<app profile id>]
-	  app-profile=<app profile id>		The app profile id to use for the request
-
-
-
-
-
-Delete a column family
-
-Usage:
-	cbt deletefamily <table> <family>
-
-
-
-
-Delete a row
-
-Usage:
-	cbt deleterow <table> <row> [app-profile=<app profile id>]
-	  app-profile=<app profile id>		The app profile id to use for the request
-
-
-
-
-
-Delete a table
-
-Usage:
-	cbt deletetable <table>
-
-
-
-
-Print godoc-suitable documentation for cbt
-
-Usage:
-	cbt doc
-
-
-
-
-Print help text
-
-Usage:
-	cbt help [command]
-
-
-
-
-List instances in a project
-
-Usage:
-	cbt listinstances
-
-
-
-
-List clusters in an instance
-
-Usage:
-	cbt listclusters
-
-
-
-
-Read from a single row
-
-Usage:
-	cbt lookup <table> <row> [columns=[family]:[qualifier],...] [cells-per-column=<n>] [app-profile=<app profile id>]
-	  columns=[family]:[qualifier],...	Read only these columns, comma-separated
-	  cells-per-column=<n> 			Read only this many cells per column
-	  app-profile=<app profile id>		The app profile id to use for the request
-
-
-
-
-
-List tables and column families
-
-Usage:
-	cbt ls			List tables
-	cbt ls <table>		List column families in <table>
-
-
-
-
-Print documentation for cbt in Markdown format
-
-Usage:
-	cbt mddoc
-
-
-
-
-Read rows
-
-Usage:
-	cbt read <table> [start=<row>] [end=<row>] [prefix=<prefix>] [regex=<regex>] [columns=[family]:[qualifier],...] [count=<n>] [cells-per-column=<n>] [app-profile=<app profile id>]
-	  start=<row>				Start reading at this row
-	  end=<row>				Stop reading before this row
-	  prefix=<prefix>			Read rows with this prefix
-	  regex=<regex> 			Read rows with keys matching this regex
-	  columns=[family]:[qualifier],...	Read only these columns, comma-separated
-	  count=<n>				Read only this many rows
-	  cells-per-column=<n>			Read only this many cells per column
-	  app-profile=<app profile id>		The app profile id to use for the request
-
-
-
-
-
-Set value of a cell
-
-Usage:
-	cbt set <table> <row> [app-profile=<app profile id>] family:column=val[@ts] ...
-	  app-profile=<app profile id>		The app profile id to use for the request
-	  family:column=val[@ts] may be repeated to set multiple cells.
-
-	  ts is an optional integer timestamp.
-	  If it cannot be parsed, the `@ts` part will be
-	  interpreted as part of the value.
-
-
-
-
-Set the GC policy for a column family
-
-Usage:
-	cbt setgcpolicy <table> <family> ((maxage=<d> | maxversions=<n>) [(and|or) (maxage=<d> | maxversions=<n>),...] | never)
-
-	  maxage=<d>		Maximum timestamp age to preserve (e.g. "1h", "4d")
-	  maxversions=<n>	Maximum number of versions to preserve
-
-
-
-
-Block until all the completed writes have been replicated to all the clusters
-
-Usage:
-	cbt waitforreplication <table>
-
-
-
-
-Create a table from a snapshot (snapshots alpha)
-
-Usage:
-	cbt createtablefromsnapshot <table> <cluster> <snapshot>
-	  table	The name of the table to create
-	  cluster	The cluster where the snapshot is located
-	  snapshot	The snapshot to restore
-
-
-
-
-Create a snapshot from a source table (snapshots alpha)
-
-Usage:
-	cbt createsnapshot <cluster> <snapshot> <table> [ttl=<d>]
-
-	  [ttl=<d>]		Lifespan of the snapshot (e.g. "1h", "4d")
-
-
-
-
-
-List snapshots in a cluster (snapshots alpha)
-
-Usage:
-	cbt listsnapshots [<cluster>]
-
-
-
-
-Get snapshot info (snapshots alpha)
-
-Usage:
-	cbt getsnapshot <cluster> <snapshot>
-
-
-
-
-Delete snapshot in a cluster (snapshots alpha)
-
-Usage:
-	cbt deletesnapshot <cluster> <snapshot>
-
-
-
-
-Print the current cbt version
-
-Usage:
-	cbt version
-
-
-
-
-Creates app profile for an instance
-
-Usage:
-	usage: cbt createappprofile <instance-id> <profile-id> <description> (route-any | [ route-to=<cluster-id> : transactional-writes]) [optional flag]
-	optional flags may be `force`
-
-
-
-
-Reads app profile for an instance
-
-Usage:
-	cbt getappprofile <instance-id> <profile-id>
-
-
-
-
-Lists app profile for an instance
-
-Usage:
-	cbt listappprofile <instance-id>
-
-
-
-
-Updates app profile for an instance
-
-Usage:
-	usage: cbt updateappprofile  <instance-id> <profile-id> <description>(route-any | [ route-to=<cluster-id> : transactional-writes]) [optional flag]
-	optional flags may be `force`
-
-
-
-
-Deletes app profile for an instance
-
-Usage:
-	cbt deleteappprofile <instance-id> <profile-id>
-
-
-
-
-*/
-package main

+ 0 - 215
vendor/cloud.google.com/go/bigtable/cmd/cbt/gcpolicy.go

@@ -1,215 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package main
-
-import (
-	"bytes"
-	"errors"
-	"fmt"
-	"io"
-	"strconv"
-	"strings"
-	"unicode"
-
-	"cloud.google.com/go/bigtable"
-)
-
-// Parse a GC policy. Valid policies include
-//     never
-//     maxage = 5d
-//     maxversions = 3
-//     maxage = 5d || maxversions = 3
-//     maxage=30d || (maxage=3d && maxversions=100)
-func parseGCPolicy(s string) (bigtable.GCPolicy, error) {
-	if strings.TrimSpace(s) == "never" {
-		return bigtable.NoGcPolicy(), nil
-	}
-	r := strings.NewReader(s)
-	p, err := parsePolicyExpr(r)
-	if err != nil {
-		return nil, fmt.Errorf("invalid GC policy: %v", err)
-	}
-	tok, err := getToken(r)
-	if err != nil {
-		return nil, err
-	}
-	if tok != "" {
-		return nil, fmt.Errorf("invalid GC policy: want end of input, got %q", tok)
-	}
-	return p, nil
-}
-
-// expr ::= term (op term)*
-// op ::= "and" | "or" | "&&" | "||"
-func parsePolicyExpr(r io.RuneScanner) (bigtable.GCPolicy, error) {
-	policy, err := parsePolicyTerm(r)
-	if err != nil {
-		return nil, err
-	}
-	for {
-		tok, err := getToken(r)
-		if err != nil {
-			return nil, err
-		}
-		var f func(...bigtable.GCPolicy) bigtable.GCPolicy
-		switch tok {
-		case "and", "&&":
-			f = bigtable.IntersectionPolicy
-		case "or", "||":
-			f = bigtable.UnionPolicy
-		default:
-			ungetToken(tok)
-			return policy, nil
-		}
-		p2, err := parsePolicyTerm(r)
-		if err != nil {
-			return nil, err
-		}
-		policy = f(policy, p2)
-	}
-}
-
-// term ::= "maxage" "=" duration | "maxversions" "=" int | "(" policy ")"
-func parsePolicyTerm(r io.RuneScanner) (bigtable.GCPolicy, error) {
-	tok, err := getToken(r)
-	if err != nil {
-		return nil, err
-	}
-	switch tok {
-	case "":
-		return nil, errors.New("empty GC policy term")
-
-	case "maxage", "maxversions":
-		if err := expectToken(r, "="); err != nil {
-			return nil, err
-		}
-		tok2, err := getToken(r)
-		if err != nil {
-			return nil, err
-		}
-		if tok2 == "" {
-			return nil, errors.New("expected a token after '='")
-		}
-		if tok == "maxage" {
-			dur, err := parseDuration(tok2)
-			if err != nil {
-				return nil, err
-			}
-			return bigtable.MaxAgePolicy(dur), nil
-		}
-		n, err := strconv.ParseUint(tok2, 10, 16)
-		if err != nil {
-			return nil, err
-		}
-		return bigtable.MaxVersionsPolicy(int(n)), nil
-
-	case "(":
-		p, err := parsePolicyExpr(r)
-		if err != nil {
-			return nil, err
-		}
-		if err := expectToken(r, ")"); err != nil {
-			return nil, err
-		}
-		return p, nil
-
-	default:
-		return nil, fmt.Errorf("unexpected token: %q", tok)
-	}
-
-}
-
-func expectToken(r io.RuneScanner, want string) error {
-	got, err := getToken(r)
-	if err != nil {
-		return err
-	}
-	if got != want {
-		return fmt.Errorf("expected %q, saw %q", want, got)
-	}
-	return nil
-}
-
-const noToken = "_" // empty token is valid, so use "_" instead
-
-// If not noToken, getToken will return this instead of reading a new token
-// from the input.
-var ungotToken = noToken
-
-// getToken extracts the first token from the input. Valid tokens include
-// any sequence of letters and digits, and these symbols: &&, ||, =, ( and ).
-// getToken returns ("", nil) at end of input.
-func getToken(r io.RuneScanner) (string, error) {
-	if ungotToken != noToken {
-		t := ungotToken
-		ungotToken = noToken
-		return t, nil
-	}
-	var err error
-	// Skip leading whitespace.
-	c := ' '
-	for unicode.IsSpace(c) {
-		c, _, err = r.ReadRune()
-		if err == io.EOF {
-			return "", nil
-		}
-		if err != nil {
-			return "", err
-		}
-	}
-	switch {
-	case c == '=' || c == '(' || c == ')':
-		return string(c), nil
-
-	case c == '&' || c == '|':
-		c2, _, err := r.ReadRune()
-		if err != nil && err != io.EOF {
-			return "", err
-		}
-		if c != c2 {
-			return "", fmt.Errorf("expected %c%c", c, c)
-		}
-		return string([]rune{c, c}), nil
-
-	case unicode.IsLetter(c) || unicode.IsDigit(c):
-		// Collect an alphanumeric token.
-		var b bytes.Buffer
-		for unicode.IsLetter(c) || unicode.IsDigit(c) {
-			b.WriteRune(c)
-			c, _, err = r.ReadRune()
-			if err == io.EOF {
-				break
-			}
-			if err != nil {
-				return "", err
-			}
-		}
-		r.UnreadRune()
-		return b.String(), nil
-
-	default:
-		return "", fmt.Errorf("bad rune %q", c)
-	}
-}
-
-// "unget" a token so the next call to getToken will return it.
-func ungetToken(tok string) {
-	if ungotToken != noToken {
-		panic("ungetToken called twice")
-	}
-	ungotToken = tok
-}

+ 0 - 196
vendor/cloud.google.com/go/bigtable/cmd/cbt/gcpolicy_test.go

@@ -1,196 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package main
-
-import (
-	"strings"
-	"testing"
-	"time"
-
-	"cloud.google.com/go/bigtable"
-	"github.com/google/go-cmp/cmp"
-)
-
-func TestParseGCPolicy(t *testing.T) {
-	for _, test := range []struct {
-		in   string
-		want bigtable.GCPolicy
-	}{
-		{
-			"never",
-			bigtable.NoGcPolicy(),
-		},
-		{
-			"maxage=3h",
-			bigtable.MaxAgePolicy(3 * time.Hour),
-		},
-		{
-			"maxversions=2",
-			bigtable.MaxVersionsPolicy(2),
-		},
-		{
-			"maxversions=2 and maxage=1h",
-			bigtable.IntersectionPolicy(bigtable.MaxVersionsPolicy(2), bigtable.MaxAgePolicy(time.Hour)),
-		},
-		{
-			"(((maxversions=2 and (maxage=1h))))",
-			bigtable.IntersectionPolicy(bigtable.MaxVersionsPolicy(2), bigtable.MaxAgePolicy(time.Hour)),
-		},
-		{
-			"maxversions=7 or maxage=8h",
-			bigtable.UnionPolicy(bigtable.MaxVersionsPolicy(7), bigtable.MaxAgePolicy(8*time.Hour)),
-		},
-		{
-			"maxversions = 7||maxage = 8h",
-			bigtable.UnionPolicy(bigtable.MaxVersionsPolicy(7), bigtable.MaxAgePolicy(8*time.Hour)),
-		},
-		{
-			"maxversions=7||maxage=8h",
-			bigtable.UnionPolicy(bigtable.MaxVersionsPolicy(7), bigtable.MaxAgePolicy(8*time.Hour)),
-		},
-		{
-			"maxage=30d || (maxage=3d && maxversions=100)",
-			bigtable.UnionPolicy(
-				bigtable.MaxAgePolicy(30*24*time.Hour),
-				bigtable.IntersectionPolicy(
-					bigtable.MaxAgePolicy(3*24*time.Hour),
-					bigtable.MaxVersionsPolicy(100))),
-		},
-		{
-			"maxage=30d || (maxage=3d && maxversions=100) || maxversions=7",
-			bigtable.UnionPolicy(
-				bigtable.UnionPolicy(
-					bigtable.MaxAgePolicy(30*24*time.Hour),
-					bigtable.IntersectionPolicy(
-						bigtable.MaxAgePolicy(3*24*time.Hour),
-						bigtable.MaxVersionsPolicy(100))),
-				bigtable.MaxVersionsPolicy(7)),
-		},
-		{
-			// && and || have same precedence, left associativity
-			"maxage=1h && maxage=2h || maxage=3h",
-			bigtable.UnionPolicy(
-				bigtable.IntersectionPolicy(
-					bigtable.MaxAgePolicy(1*time.Hour),
-					bigtable.MaxAgePolicy(2*time.Hour)),
-				bigtable.MaxAgePolicy(3*time.Hour)),
-		},
-	} {
-		got, err := parseGCPolicy(test.in)
-		if err != nil {
-			t.Errorf("%s: %v", test.in, err)
-			continue
-		}
-		if !cmp.Equal(got, test.want, cmp.AllowUnexported(bigtable.IntersectionPolicy(), bigtable.UnionPolicy())) {
-			t.Errorf("%s: got %+v, want %+v", test.in, got, test.want)
-		}
-	}
-}
-
-func TestParseGCPolicyErrors(t *testing.T) {
-	for _, in := range []string{
-		"",
-		"a",
-		"b = 1h",
-		"c = 1",
-		"maxage=1",       // need duration
-		"maxversions=1h", // need int
-		"maxage",
-		"maxversions",
-		"never=never",
-		"maxversions=1 && never",
-		"(((maxage=1h))",
-		"((maxage=1h)))",
-		"maxage=30d || ((maxage=3d && maxversions=100)",
-		"maxversions = 3 and",
-	} {
-		_, err := parseGCPolicy(in)
-		if err == nil {
-			t.Errorf("%s: got nil, want error", in)
-		}
-	}
-}
-
-func TestTokenizeGCPolicy(t *testing.T) {
-	for _, test := range []struct {
-		in   string
-		want []string
-	}{
-		{
-			"maxage=5d",
-			[]string{"maxage", "=", "5d"},
-		},
-		{
-			"maxage = 5d",
-			[]string{"maxage", "=", "5d"},
-		},
-		{
-			"maxage=5d or maxversions=5",
-			[]string{"maxage", "=", "5d", "or", "maxversions", "=", "5"},
-		},
-		{
-			"maxage=5d || (maxversions=5)",
-			[]string{"maxage", "=", "5d", "||", "(", "maxversions", "=", "5", ")"},
-		},
-		{
-			"maxage=5d||( maxversions=5 )",
-			[]string{"maxage", "=", "5d", "||", "(", "maxversions", "=", "5", ")"},
-		},
-	} {
-		got, err := tokenizeGCPolicy(test.in)
-		if err != nil {
-			t.Errorf("%s: %v", test.in, err)
-			continue
-		}
-		if diff := cmp.Diff(got, test.want); diff != "" {
-			t.Errorf("%s: %s", test.in, diff)
-		}
-	}
-}
-
-func TestTokenizeGCPolicyErrors(t *testing.T) {
-	for _, in := range []string{
-		"a &",
-		"a & b",
-		"a &x b",
-		"a |",
-		"a | b",
-		"a |& b",
-		"a % b",
-	} {
-		_, err := tokenizeGCPolicy(in)
-		if err == nil {
-			t.Errorf("%s: got nil, want error", in)
-		}
-	}
-}
-
-func tokenizeGCPolicy(s string) ([]string, error) {
-	var tokens []string
-	r := strings.NewReader(s)
-	for {
-		tok, err := getToken(r)
-		if err != nil {
-			return nil, err
-		}
-		if tok == "" {
-			break
-		}
-		tokens = append(tokens, tok)
-	}
-	return tokens, nil
-}

+ 0 - 52
vendor/cloud.google.com/go/bigtable/cmd/emulator/cbtemulator.go

@@ -1,52 +0,0 @@
-// Copyright 2016 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
-//
-//      http://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.
-
-/*
-cbtemulator launches the in-memory Cloud Bigtable server on the given address.
-*/
-package main
-
-import (
-	"flag"
-	"fmt"
-	"log"
-
-	"cloud.google.com/go/bigtable/bttest"
-	"google.golang.org/grpc"
-)
-
-var (
-	host = flag.String("host", "localhost", "the address to bind to on the local machine")
-	port = flag.Int("port", 9000, "the port number to bind to on the local machine")
-)
-
-const (
-	maxMsgSize = 256 * 1024 * 1024 // 256 MiB
-)
-
-func main() {
-	grpc.EnableTracing = false
-	flag.Parse()
-	opts := []grpc.ServerOption{
-		grpc.MaxRecvMsgSize(maxMsgSize),
-		grpc.MaxSendMsgSize(maxMsgSize),
-	}
-	srv, err := bttest.NewServer(fmt.Sprintf("%s:%d", *host, *port), opts...)
-	if err != nil {
-		log.Fatalf("failed to start emulator: %v", err)
-	}
-
-	fmt.Printf("Cloud Bigtable emulator running on %s\n", srv.Addr)
-	select {}
-}

+ 0 - 205
vendor/cloud.google.com/go/bigtable/cmd/loadtest/loadtest.go

@@ -1,205 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-/*
-Loadtest does some load testing through the Go client library for Cloud Bigtable.
-*/
-package main
-
-import (
-	"bytes"
-	"context"
-	"flag"
-	"fmt"
-	"log"
-	"math/rand"
-	"os"
-	"os/signal"
-	"sync"
-	"sync/atomic"
-	"time"
-
-	"cloud.google.com/go/bigtable"
-	"cloud.google.com/go/bigtable/internal/cbtconfig"
-	"cloud.google.com/go/bigtable/internal/stat"
-	"google.golang.org/api/option"
-	"google.golang.org/grpc"
-)
-
-var (
-	runFor = flag.Duration("run_for", 5*time.Second,
-		"how long to run the load test for; 0 to run forever until SIGTERM")
-	scratchTable = flag.String("scratch_table", "loadtest-scratch", "name of table to use; should not already exist")
-	csvOutput    = flag.String("csv_output", "",
-		"output path for statistics in .csv format. If this file already exists it will be overwritten.")
-	poolSize = flag.Int("pool_size", 1, "size of the gRPC connection pool to use for the data client")
-	reqCount = flag.Int("req_count", 100, "number of concurrent requests")
-
-	config      *cbtconfig.Config
-	client      *bigtable.Client
-	adminClient *bigtable.AdminClient
-)
-
-func main() {
-	var err error
-	config, err = cbtconfig.Load()
-	if err != nil {
-		log.Fatal(err)
-	}
-	config.RegisterFlags()
-
-	flag.Parse()
-	if err := config.CheckFlags(cbtconfig.ProjectAndInstanceRequired); err != nil {
-		log.Fatal(err)
-	}
-	if config.Creds != "" {
-		os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", config.Creds)
-	}
-	if flag.NArg() != 0 {
-		flag.Usage()
-		os.Exit(1)
-	}
-
-	var options []option.ClientOption
-	if *poolSize > 1 {
-		options = append(options,
-			option.WithGRPCConnectionPool(*poolSize),
-
-			// TODO(grpc/grpc-go#1388) using connection pool without WithBlock
-			// can cause RPCs to fail randomly. We can delete this after the issue is fixed.
-			option.WithGRPCDialOption(grpc.WithBlock()))
-	}
-
-	var csvFile *os.File
-	if *csvOutput != "" {
-		csvFile, err = os.Create(*csvOutput)
-		if err != nil {
-			log.Fatalf("creating csv output file: %v", err)
-		}
-		defer csvFile.Close()
-		log.Printf("Writing statistics to %q ...", *csvOutput)
-	}
-
-	log.Printf("Dialing connections...")
-	client, err = bigtable.NewClient(context.Background(), config.Project, config.Instance, options...)
-	if err != nil {
-		log.Fatalf("Making bigtable.Client: %v", err)
-	}
-	defer client.Close()
-	adminClient, err = bigtable.NewAdminClient(context.Background(), config.Project, config.Instance)
-	if err != nil {
-		log.Fatalf("Making bigtable.AdminClient: %v", err)
-	}
-	defer adminClient.Close()
-
-	// Create a scratch table.
-	log.Printf("Setting up scratch table...")
-	tblConf := bigtable.TableConf{
-		TableID:  *scratchTable,
-		Families: map[string]bigtable.GCPolicy{"f": bigtable.MaxVersionsPolicy(1)},
-	}
-	if err := adminClient.CreateTableFromConf(context.Background(), &tblConf); err != nil {
-		log.Fatalf("Making scratch table %q: %v", *scratchTable, err)
-	}
-	// Upon a successful run, delete the table. Don't bother checking for errors.
-	defer adminClient.DeleteTable(context.Background(), *scratchTable)
-
-	// Also delete the table on SIGTERM.
-	c := make(chan os.Signal, 1)
-	signal.Notify(c, os.Interrupt)
-	go func() {
-		s := <-c
-		log.Printf("Caught %v, cleaning scratch table.", s)
-		_ = adminClient.DeleteTable(context.Background(), *scratchTable)
-		os.Exit(1)
-	}()
-
-	log.Printf("Starting load test... (run for %v)", *runFor)
-	tbl := client.Open(*scratchTable)
-	sem := make(chan int, *reqCount) // limit the number of requests happening at once
-	var reads, writes stats
-	stopTime := time.Now().Add(*runFor)
-	var wg sync.WaitGroup
-	for time.Now().Before(stopTime) || *runFor == 0 {
-		sem <- 1
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			defer func() { <-sem }()
-
-			ok := true
-			opStart := time.Now()
-			var stats *stats
-			defer func() {
-				stats.Record(ok, time.Since(opStart))
-			}()
-
-			row := fmt.Sprintf("row%d", rand.Intn(100)) // operate on 1 of 100 rows
-
-			switch rand.Intn(10) {
-			default:
-				// read
-				stats = &reads
-				_, err := tbl.ReadRow(context.Background(), row, bigtable.RowFilter(bigtable.LatestNFilter(1)))
-				if err != nil {
-					log.Printf("Error doing read: %v", err)
-					ok = false
-				}
-			case 0, 1, 2, 3, 4:
-				// write
-				stats = &writes
-				mut := bigtable.NewMutation()
-				mut.Set("f", "col", bigtable.Now(), bytes.Repeat([]byte("0"), 1<<10)) // 1 KB write
-				if err := tbl.Apply(context.Background(), row, mut); err != nil {
-					log.Printf("Error doing mutation: %v", err)
-					ok = false
-				}
-			}
-		}()
-	}
-	wg.Wait()
-
-	readsAgg := stat.NewAggregate("reads", reads.ds, reads.tries-reads.ok)
-	writesAgg := stat.NewAggregate("writes", writes.ds, writes.tries-writes.ok)
-	log.Printf("Reads (%d ok / %d tries):\n%v", reads.ok, reads.tries, readsAgg)
-	log.Printf("Writes (%d ok / %d tries):\n%v", writes.ok, writes.tries, writesAgg)
-
-	if csvFile != nil {
-		stat.WriteCSV([]*stat.Aggregate{readsAgg, writesAgg}, csvFile)
-	}
-}
-
-var allStats int64 // atomic
-
-type stats struct {
-	mu        sync.Mutex
-	tries, ok int
-	ds        []time.Duration
-}
-
-func (s *stats) Record(ok bool, d time.Duration) {
-	s.mu.Lock()
-	s.tries++
-	if ok {
-		s.ok++
-	}
-	s.ds = append(s.ds, d)
-	s.mu.Unlock()
-
-	if n := atomic.AddInt64(&allStats, 1); n%1000 == 0 {
-		log.Printf("Progress: done %d ops", n)
-	}
-}

+ 0 - 155
vendor/cloud.google.com/go/bigtable/cmd/scantest/scantest.go

@@ -1,155 +0,0 @@
-/*
-Copyright 2016 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
-
-    http://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.
-*/
-
-/*
-Scantest does scan-related load testing against Cloud Bigtable. The logic here
-mimics a similar test written using the Java client.
-*/
-package main
-
-import (
-	"bytes"
-	"context"
-	"flag"
-	"fmt"
-	"log"
-	"math/rand"
-	"os"
-	"sync"
-	"sync/atomic"
-	"text/tabwriter"
-	"time"
-
-	"cloud.google.com/go/bigtable"
-	"cloud.google.com/go/bigtable/internal/cbtconfig"
-	"cloud.google.com/go/bigtable/internal/stat"
-)
-
-var (
-	runFor   = flag.Duration("run_for", 5*time.Second, "how long to run the load test for")
-	numScans = flag.Int("concurrent_scans", 1, "number of concurrent scans")
-	rowLimit = flag.Int("row_limit", 10000, "max number of records per scan")
-
-	config *cbtconfig.Config
-	client *bigtable.Client
-)
-
-func main() {
-	flag.Usage = func() {
-		fmt.Printf("Usage: scantest [options] <table_name>\n\n")
-		flag.PrintDefaults()
-	}
-
-	var err error
-	config, err = cbtconfig.Load()
-	if err != nil {
-		log.Fatal(err)
-	}
-	config.RegisterFlags()
-
-	flag.Parse()
-	if err := config.CheckFlags(cbtconfig.ProjectAndInstanceRequired); err != nil {
-		log.Fatal(err)
-	}
-	if config.Creds != "" {
-		os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", config.Creds)
-	}
-	if flag.NArg() != 1 {
-		flag.Usage()
-		os.Exit(1)
-	}
-
-	table := flag.Arg(0)
-
-	log.Printf("Dialing connections...")
-	client, err = bigtable.NewClient(context.Background(), config.Project, config.Instance)
-	if err != nil {
-		log.Fatalf("Making bigtable.Client: %v", err)
-	}
-	defer client.Close()
-
-	log.Printf("Starting scan test... (run for %v)", *runFor)
-	tbl := client.Open(table)
-	sem := make(chan int, *numScans) // limit the number of requests happening at once
-	var scans stats
-
-	stopTime := time.Now().Add(*runFor)
-	var wg sync.WaitGroup
-	for time.Now().Before(stopTime) {
-		sem <- 1
-		wg.Add(1)
-		go func() {
-			defer wg.Done()
-			defer func() { <-sem }()
-
-			ok := true
-			opStart := time.Now()
-			defer func() {
-				scans.Record(ok, time.Since(opStart))
-			}()
-
-			// Start at a random row key
-			key := fmt.Sprintf("user%d", rand.Int63())
-			limit := bigtable.LimitRows(int64(*rowLimit))
-			noop := func(bigtable.Row) bool { return true }
-			if err := tbl.ReadRows(context.Background(), bigtable.NewRange(key, ""), noop, limit); err != nil {
-				log.Printf("Error during scan: %v", err)
-				ok = false
-			}
-		}()
-	}
-	wg.Wait()
-
-	agg := stat.NewAggregate("scans", scans.ds, scans.tries-scans.ok)
-	log.Printf("Scans (%d ok / %d tries):\nscan times:\n%v\nthroughput (rows/second):\n%v",
-		scans.ok, scans.tries, agg, throughputString(agg))
-}
-
-func throughputString(agg *stat.Aggregate) string {
-	var buf bytes.Buffer
-	tw := tabwriter.NewWriter(&buf, 0, 0, 1, ' ', 0) // one-space padding
-	rowLimitF := float64(*rowLimit)
-	fmt.Fprintf(
-		tw,
-		"min:\t%.2f\nmedian:\t%.2f\nmax:\t%.2f\n",
-		rowLimitF/agg.Max.Seconds(),
-		rowLimitF/agg.Median.Seconds(),
-		rowLimitF/agg.Min.Seconds())
-	tw.Flush()
-	return buf.String()
-}
-
-var allStats int64 // atomic
-
-type stats struct {
-	mu        sync.Mutex
-	tries, ok int
-	ds        []time.Duration
-}
-
-func (s *stats) Record(ok bool, d time.Duration) {
-	s.mu.Lock()
-	s.tries++
-	if ok {
-		s.ok++
-	}
-	s.ds = append(s.ds, d)
-	s.mu.Unlock()
-
-	if n := atomic.AddInt64(&allStats, 1); n%1000 == 0 {
-		log.Printf("Progress: done %d ops", n)
-	}
-}

+ 0 - 123
vendor/cloud.google.com/go/bigtable/doc.go

@@ -1,123 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-/*
-Package bigtable is an API to Google Cloud Bigtable.
-
-See https://cloud.google.com/bigtable/docs/ for general product documentation.
-
-See https://godoc.org/cloud.google.com/go for authentication, timeouts,
-connection pooling and similar aspects of this package.
-
-
-Setup and Credentials
-
-Use NewClient or NewAdminClient to create a client that can be used to access
-the data or admin APIs respectively. Both require credentials that have permission
-to access the Cloud Bigtable API.
-
-If your program is run on Google App Engine or Google Compute Engine, using the Application Default Credentials
-(https://developers.google.com/accounts/docs/application-default-credentials)
-is the simplest option. Those credentials will be used by default when NewClient or NewAdminClient are called.
-
-To use alternate credentials, pass them to NewClient or NewAdminClient using option.WithTokenSource.
-For instance, you can use service account credentials by visiting
-https://cloud.google.com/console/project/MYPROJECT/apiui/credential,
-creating a new OAuth "Client ID", storing the JSON key somewhere accessible, and writing
-	jsonKey, err := ioutil.ReadFile(pathToKeyFile)
-	...
-	config, err := google.JWTConfigFromJSON(jsonKey, bigtable.Scope) // or bigtable.AdminScope, etc.
-	...
-	client, err := bigtable.NewClient(ctx, project, instance, option.WithTokenSource(config.TokenSource(ctx)))
-	...
-Here, `google` means the golang.org/x/oauth2/google package
-and `option` means the google.golang.org/api/option package.
-
-Reading
-
-The principal way to read from a Bigtable is to use the ReadRows method on *Table.
-A RowRange specifies a contiguous portion of a table. A Filter may be provided through
-RowFilter to limit or transform the data that is returned.
-	tbl := client.Open("mytable")
-	...
-	// Read all the rows starting with "com.google.",
-	// but only fetch the columns in the "links" family.
-	rr := bigtable.PrefixRange("com.google.")
-	err := tbl.ReadRows(ctx, rr, func(r Row) bool {
-		// do something with r
-		return true // keep going
-	}, bigtable.RowFilter(bigtable.FamilyFilter("links")))
-	...
-
-To read a single row, use the ReadRow helper method.
-	r, err := tbl.ReadRow(ctx, "com.google.cloud") // "com.google.cloud" is the entire row key
-	...
-
-Writing
-
-This API exposes two distinct forms of writing to a Bigtable: a Mutation and a ReadModifyWrite.
-The former expresses idempotent operations.
-The latter expresses non-idempotent operations and returns the new values of updated cells.
-These operations are performed by creating a Mutation or ReadModifyWrite (with NewMutation or NewReadModifyWrite),
-building up one or more operations on that, and then using the Apply or ApplyReadModifyWrite
-methods on a Table.
-
-For instance, to set a couple of cells in a table,
-	tbl := client.Open("mytable")
-	mut := bigtable.NewMutation()
-	mut.Set("links", "maps.google.com", bigtable.Now(), []byte("1"))
-	mut.Set("links", "golang.org", bigtable.Now(), []byte("1"))
-	err := tbl.Apply(ctx, "com.google.cloud", mut)
-	...
-
-To increment an encoded value in one cell,
-	tbl := client.Open("mytable")
-	rmw := bigtable.NewReadModifyWrite()
-	rmw.Increment("links", "golang.org", 12) // add 12 to the cell in column "links:golang.org"
-	r, err := tbl.ApplyReadModifyWrite(ctx, "com.google.cloud", rmw)
-	...
-
-Retries
-
-If a read or write operation encounters a transient error it will be retried until a successful
-response, an unretryable error or the context deadline is reached. Non-idempotent writes (where
-the timestamp is set to ServerTime) will not be retried. In the case of ReadRows, retried calls
-will not re-scan rows that have already been processed.
-*/
-package bigtable // import "cloud.google.com/go/bigtable"
-
-// Scope constants for authentication credentials.
-// These should be used when using credential creation functions such as oauth.NewServiceAccountFromFile.
-const (
-	// Scope is the OAuth scope for Cloud Bigtable data operations.
-	Scope = "https://www.googleapis.com/auth/bigtable.data"
-	// ReadonlyScope is the OAuth scope for Cloud Bigtable read-only data operations.
-	ReadonlyScope = "https://www.googleapis.com/auth/bigtable.readonly"
-
-	// AdminScope is the OAuth scope for Cloud Bigtable table admin operations.
-	AdminScope = "https://www.googleapis.com/auth/bigtable.admin.table"
-
-	// InstanceAdminScope is the OAuth scope for Cloud Bigtable instance (and cluster) admin operations.
-	InstanceAdminScope = "https://www.googleapis.com/auth/bigtable.admin.cluster"
-)
-
-// clientUserAgent identifies the version of this package.
-// It should be bumped upon significant changes only.
-const clientUserAgent = "cbt-go/20180601"
-
-// resourcePrefixHeader is the name of the metadata header used to indicate
-// the resource being operated on.
-const resourcePrefixHeader = "google-cloud-resource-prefix"

+ 0 - 215
vendor/cloud.google.com/go/bigtable/export_test.go

@@ -1,215 +0,0 @@
-/*
-Copyright 2016 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
-
-    http://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.
-*/
-
-package bigtable
-
-import (
-	"context"
-	"errors"
-	"flag"
-	"fmt"
-	"strings"
-	"time"
-
-	"cloud.google.com/go/bigtable/bttest"
-	"google.golang.org/api/option"
-	"google.golang.org/grpc"
-)
-
-var legacyUseProd string
-var integrationConfig IntegrationTestConfig
-
-func init() {
-	c := &integrationConfig
-
-	flag.BoolVar(&c.UseProd, "it.use-prod", false, "Use remote bigtable instead of local emulator")
-	flag.StringVar(&c.AdminEndpoint, "it.admin-endpoint", "", "Admin api host and port")
-	flag.StringVar(&c.DataEndpoint, "it.data-endpoint", "", "Data api host and port")
-	flag.StringVar(&c.Project, "it.project", "", "Project to use for integration test")
-	flag.StringVar(&c.Instance, "it.instance", "", "Bigtable instance to use")
-	flag.StringVar(&c.Cluster, "it.cluster", "", "Bigtable cluster to use")
-	flag.StringVar(&c.Table, "it.table", "", "Bigtable table to create")
-
-	// Backwards compat
-	flag.StringVar(&legacyUseProd, "use_prod", "", `DEPRECATED: if set to "proj,instance,table", run integration test against production`)
-
-}
-
-// IntegrationTestConfig contains parameters to pick and setup a IntegrationEnv for testing
-type IntegrationTestConfig struct {
-	UseProd       bool
-	AdminEndpoint string
-	DataEndpoint  string
-	Project       string
-	Instance      string
-	Cluster       string
-	Table         string
-}
-
-// IntegrationEnv represents a testing environment.
-// The environment can be implemented using production or an emulator
-type IntegrationEnv interface {
-	Config() IntegrationTestConfig
-	NewAdminClient() (*AdminClient, error)
-	// NewInstanceAdminClient will return nil if instance administration is unsupported in this environment
-	NewInstanceAdminClient() (*InstanceAdminClient, error)
-	NewClient() (*Client, error)
-	Close()
-}
-
-// NewIntegrationEnv creates a new environment based on the command line args
-func NewIntegrationEnv() (IntegrationEnv, error) {
-	c := integrationConfig
-
-	if legacyUseProd != "" {
-		fmt.Println("WARNING: using legacy commandline arg -use_prod, please switch to -it.*")
-		parts := strings.SplitN(legacyUseProd, ",", 3)
-		c.UseProd = true
-		c.Project = parts[0]
-		c.Instance = parts[1]
-		c.Table = parts[2]
-	}
-
-	if integrationConfig.UseProd {
-		return NewProdEnv(c)
-	}
-	return NewEmulatedEnv(c)
-}
-
-// EmulatedEnv encapsulates the state of an emulator
-type EmulatedEnv struct {
-	config IntegrationTestConfig
-	server *bttest.Server
-}
-
-// NewEmulatedEnv builds and starts the emulator based environment
-func NewEmulatedEnv(config IntegrationTestConfig) (*EmulatedEnv, error) {
-	srv, err := bttest.NewServer("localhost:0", grpc.MaxRecvMsgSize(200<<20), grpc.MaxSendMsgSize(100<<20))
-	if err != nil {
-		return nil, err
-	}
-
-	if config.Project == "" {
-		config.Project = "project"
-	}
-	if config.Instance == "" {
-		config.Instance = "instance"
-	}
-	if config.Table == "" {
-		config.Table = "mytable"
-	}
-	config.AdminEndpoint = srv.Addr
-	config.DataEndpoint = srv.Addr
-
-	env := &EmulatedEnv{
-		config: config,
-		server: srv,
-	}
-	return env, nil
-}
-
-// Close stops & cleans up the emulator
-func (e *EmulatedEnv) Close() {
-	e.server.Close()
-}
-
-// Config gets the config used to build this environment
-func (e *EmulatedEnv) Config() IntegrationTestConfig {
-	return e.config
-}
-
-// NewAdminClient builds a new connected admin client for this environment
-func (e *EmulatedEnv) NewAdminClient() (*AdminClient, error) {
-	timeout := 20 * time.Second
-	ctx, _ := context.WithTimeout(context.Background(), timeout)
-	conn, err := grpc.Dial(e.server.Addr, grpc.WithInsecure(), grpc.WithBlock())
-	if err != nil {
-		return nil, err
-	}
-	return NewAdminClient(ctx, e.config.Project, e.config.Instance, option.WithGRPCConn(conn))
-}
-
-// NewInstanceAdminClient returns nil for the emulated environment since the API is not implemented.
-func (e *EmulatedEnv) NewInstanceAdminClient() (*InstanceAdminClient, error) {
-	return nil, nil
-}
-
-// NewClient builds a new connected data client for this environment
-func (e *EmulatedEnv) NewClient() (*Client, error) {
-	timeout := 20 * time.Second
-	ctx, _ := context.WithTimeout(context.Background(), timeout)
-	conn, err := grpc.Dial(e.server.Addr, grpc.WithInsecure(), grpc.WithBlock(),
-		grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(100<<20), grpc.MaxCallRecvMsgSize(100<<20)))
-	if err != nil {
-		return nil, err
-	}
-	return NewClient(ctx, e.config.Project, e.config.Instance, option.WithGRPCConn(conn))
-}
-
-// ProdEnv encapsulates the state necessary to connect to the external Bigtable service
-type ProdEnv struct {
-	config IntegrationTestConfig
-}
-
-// NewProdEnv builds the environment representation
-func NewProdEnv(config IntegrationTestConfig) (*ProdEnv, error) {
-	if config.Project == "" {
-		return nil, errors.New("Project not set")
-	}
-	if config.Instance == "" {
-		return nil, errors.New("Instance not set")
-	}
-	if config.Table == "" {
-		return nil, errors.New("Table not set")
-	}
-
-	return &ProdEnv{config}, nil
-}
-
-// Close is a no-op for production environments
-func (e *ProdEnv) Close() {}
-
-// Config gets the config used to build this environment
-func (e *ProdEnv) Config() IntegrationTestConfig {
-	return e.config
-}
-
-// NewAdminClient builds a new connected admin client for this environment
-func (e *ProdEnv) NewAdminClient() (*AdminClient, error) {
-	var clientOpts []option.ClientOption
-	if endpoint := e.config.AdminEndpoint; endpoint != "" {
-		clientOpts = append(clientOpts, option.WithEndpoint(endpoint))
-	}
-	return NewAdminClient(context.Background(), e.config.Project, e.config.Instance, clientOpts...)
-}
-
-// NewInstanceAdminClient returns a new connected instance admin client for this environment
-func (e *ProdEnv) NewInstanceAdminClient() (*InstanceAdminClient, error) {
-	var clientOpts []option.ClientOption
-	if endpoint := e.config.AdminEndpoint; endpoint != "" {
-		clientOpts = append(clientOpts, option.WithEndpoint(endpoint))
-	}
-	return NewInstanceAdminClient(context.Background(), e.config.Project, clientOpts...)
-}
-
-// NewClient builds a connected data client for this environment
-func (e *ProdEnv) NewClient() (*Client, error) {
-	var clientOpts []option.ClientOption
-	if endpoint := e.config.DataEndpoint; endpoint != "" {
-		clientOpts = append(clientOpts, option.WithEndpoint(endpoint))
-	}
-	return NewClient(context.Background(), e.config.Project, e.config.Instance, clientOpts...)
-}

+ 0 - 330
vendor/cloud.google.com/go/bigtable/filter.go

@@ -1,330 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package bigtable
-
-import (
-	"fmt"
-	"strings"
-	"time"
-
-	btpb "google.golang.org/genproto/googleapis/bigtable/v2"
-)
-
-// A Filter represents a row filter.
-type Filter interface {
-	String() string
-	proto() *btpb.RowFilter
-}
-
-// ChainFilters returns a filter that applies a sequence of filters.
-func ChainFilters(sub ...Filter) Filter { return chainFilter{sub} }
-
-type chainFilter struct {
-	sub []Filter
-}
-
-func (cf chainFilter) String() string {
-	var ss []string
-	for _, sf := range cf.sub {
-		ss = append(ss, sf.String())
-	}
-	return "(" + strings.Join(ss, " | ") + ")"
-}
-
-func (cf chainFilter) proto() *btpb.RowFilter {
-	chain := &btpb.RowFilter_Chain{}
-	for _, sf := range cf.sub {
-		chain.Filters = append(chain.Filters, sf.proto())
-	}
-	return &btpb.RowFilter{
-		Filter: &btpb.RowFilter_Chain_{Chain: chain},
-	}
-}
-
-// InterleaveFilters returns a filter that applies a set of filters in parallel
-// and interleaves the results.
-func InterleaveFilters(sub ...Filter) Filter { return interleaveFilter{sub} }
-
-type interleaveFilter struct {
-	sub []Filter
-}
-
-func (ilf interleaveFilter) String() string {
-	var ss []string
-	for _, sf := range ilf.sub {
-		ss = append(ss, sf.String())
-	}
-	return "(" + strings.Join(ss, " + ") + ")"
-}
-
-func (ilf interleaveFilter) proto() *btpb.RowFilter {
-	inter := &btpb.RowFilter_Interleave{}
-	for _, sf := range ilf.sub {
-		inter.Filters = append(inter.Filters, sf.proto())
-	}
-	return &btpb.RowFilter{
-		Filter: &btpb.RowFilter_Interleave_{Interleave: inter},
-	}
-}
-
-// RowKeyFilter returns a filter that matches cells from rows whose
-// key matches the provided RE2 pattern.
-// See https://github.com/google/re2/wiki/Syntax for the accepted syntax.
-func RowKeyFilter(pattern string) Filter { return rowKeyFilter(pattern) }
-
-type rowKeyFilter string
-
-func (rkf rowKeyFilter) String() string { return fmt.Sprintf("row(%s)", string(rkf)) }
-
-func (rkf rowKeyFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_RowKeyRegexFilter{RowKeyRegexFilter: []byte(rkf)}}
-}
-
-// FamilyFilter returns a filter that matches cells whose family name
-// matches the provided RE2 pattern.
-// See https://github.com/google/re2/wiki/Syntax for the accepted syntax.
-func FamilyFilter(pattern string) Filter { return familyFilter(pattern) }
-
-type familyFilter string
-
-func (ff familyFilter) String() string { return fmt.Sprintf("col(%s:)", string(ff)) }
-
-func (ff familyFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_FamilyNameRegexFilter{FamilyNameRegexFilter: string(ff)}}
-}
-
-// ColumnFilter returns a filter that matches cells whose column name
-// matches the provided RE2 pattern.
-// See https://github.com/google/re2/wiki/Syntax for the accepted syntax.
-func ColumnFilter(pattern string) Filter { return columnFilter(pattern) }
-
-type columnFilter string
-
-func (cf columnFilter) String() string { return fmt.Sprintf("col(.*:%s)", string(cf)) }
-
-func (cf columnFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_ColumnQualifierRegexFilter{ColumnQualifierRegexFilter: []byte(cf)}}
-}
-
-// ValueFilter returns a filter that matches cells whose value
-// matches the provided RE2 pattern.
-// See https://github.com/google/re2/wiki/Syntax for the accepted syntax.
-func ValueFilter(pattern string) Filter { return valueFilter(pattern) }
-
-type valueFilter string
-
-func (vf valueFilter) String() string { return fmt.Sprintf("value_match(%s)", string(vf)) }
-
-func (vf valueFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_ValueRegexFilter{ValueRegexFilter: []byte(vf)}}
-}
-
-// LatestNFilter returns a filter that matches the most recent N cells in each column.
-func LatestNFilter(n int) Filter { return latestNFilter(n) }
-
-type latestNFilter int32
-
-func (lnf latestNFilter) String() string { return fmt.Sprintf("col(*,%d)", lnf) }
-
-func (lnf latestNFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_CellsPerColumnLimitFilter{CellsPerColumnLimitFilter: int32(lnf)}}
-}
-
-// StripValueFilter returns a filter that replaces each value with the empty string.
-func StripValueFilter() Filter { return stripValueFilter{} }
-
-type stripValueFilter struct{}
-
-func (stripValueFilter) String() string { return "strip_value()" }
-func (stripValueFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_StripValueTransformer{StripValueTransformer: true}}
-}
-
-// TimestampRangeFilter returns a filter that matches any cells whose timestamp is within the given time bounds.  A zero
-// time means no bound.
-// The timestamp will be truncated to millisecond granularity.
-func TimestampRangeFilter(startTime time.Time, endTime time.Time) Filter {
-	trf := timestampRangeFilter{}
-	if !startTime.IsZero() {
-		trf.startTime = Time(startTime)
-	}
-	if !endTime.IsZero() {
-		trf.endTime = Time(endTime)
-	}
-	return trf
-}
-
-// TimestampRangeFilterMicros returns a filter that matches any cells whose timestamp is within the given time bounds,
-// specified in units of microseconds since 1 January 1970. A zero value for the end time is interpreted as no bound.
-// The timestamp will be truncated to millisecond granularity.
-func TimestampRangeFilterMicros(startTime Timestamp, endTime Timestamp) Filter {
-	return timestampRangeFilter{startTime, endTime}
-}
-
-type timestampRangeFilter struct {
-	startTime Timestamp
-	endTime   Timestamp
-}
-
-func (trf timestampRangeFilter) String() string {
-	return fmt.Sprintf("timestamp_range(%v,%v)", trf.startTime, trf.endTime)
-}
-
-func (trf timestampRangeFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{
-		Filter: &btpb.RowFilter_TimestampRangeFilter{TimestampRangeFilter: &btpb.TimestampRange{
-			StartTimestampMicros: int64(trf.startTime.TruncateToMilliseconds()),
-			EndTimestampMicros:   int64(trf.endTime.TruncateToMilliseconds()),
-		},
-		}}
-}
-
-// ColumnRangeFilter returns a filter that matches a contiguous range of columns within a single
-// family, as specified by an inclusive start qualifier and exclusive end qualifier.
-func ColumnRangeFilter(family, start, end string) Filter {
-	return columnRangeFilter{family, start, end}
-}
-
-type columnRangeFilter struct {
-	family string
-	start  string
-	end    string
-}
-
-func (crf columnRangeFilter) String() string {
-	return fmt.Sprintf("columnRangeFilter(%s,%s,%s)", crf.family, crf.start, crf.end)
-}
-
-func (crf columnRangeFilter) proto() *btpb.RowFilter {
-	r := &btpb.ColumnRange{FamilyName: crf.family}
-	if crf.start != "" {
-		r.StartQualifier = &btpb.ColumnRange_StartQualifierClosed{StartQualifierClosed: []byte(crf.start)}
-	}
-	if crf.end != "" {
-		r.EndQualifier = &btpb.ColumnRange_EndQualifierOpen{EndQualifierOpen: []byte(crf.end)}
-	}
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_ColumnRangeFilter{ColumnRangeFilter: r}}
-}
-
-// ValueRangeFilter returns a filter that matches cells with values that fall within
-// the given range, as specified by an inclusive start value and exclusive end value.
-func ValueRangeFilter(start, end []byte) Filter {
-	return valueRangeFilter{start, end}
-}
-
-type valueRangeFilter struct {
-	start []byte
-	end   []byte
-}
-
-func (vrf valueRangeFilter) String() string {
-	return fmt.Sprintf("valueRangeFilter(%s,%s)", vrf.start, vrf.end)
-}
-
-func (vrf valueRangeFilter) proto() *btpb.RowFilter {
-	r := &btpb.ValueRange{}
-	if vrf.start != nil {
-		r.StartValue = &btpb.ValueRange_StartValueClosed{StartValueClosed: vrf.start}
-	}
-	if vrf.end != nil {
-		r.EndValue = &btpb.ValueRange_EndValueOpen{EndValueOpen: vrf.end}
-	}
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_ValueRangeFilter{ValueRangeFilter: r}}
-}
-
-// ConditionFilter returns a filter that evaluates to one of two possible filters depending
-// on whether or not the given predicate filter matches at least one cell.
-// If the matched filter is nil then no results will be returned.
-// IMPORTANT NOTE: The predicate filter does not execute atomically with the
-// true and false filters, which may lead to inconsistent or unexpected
-// results. Additionally, condition filters have poor performance, especially
-// when filters are set for the false condition.
-func ConditionFilter(predicateFilter, trueFilter, falseFilter Filter) Filter {
-	return conditionFilter{predicateFilter, trueFilter, falseFilter}
-}
-
-type conditionFilter struct {
-	predicateFilter Filter
-	trueFilter      Filter
-	falseFilter     Filter
-}
-
-func (cf conditionFilter) String() string {
-	return fmt.Sprintf("conditionFilter(%s,%s,%s)", cf.predicateFilter, cf.trueFilter, cf.falseFilter)
-}
-
-func (cf conditionFilter) proto() *btpb.RowFilter {
-	var tf *btpb.RowFilter
-	var ff *btpb.RowFilter
-	if cf.trueFilter != nil {
-		tf = cf.trueFilter.proto()
-	}
-	if cf.falseFilter != nil {
-		ff = cf.falseFilter.proto()
-	}
-	return &btpb.RowFilter{
-		Filter: &btpb.RowFilter_Condition_{Condition: &btpb.RowFilter_Condition{
-			PredicateFilter: cf.predicateFilter.proto(),
-			TrueFilter:      tf,
-			FalseFilter:     ff,
-		}}}
-}
-
-// CellsPerRowOffsetFilter returns a filter that skips the first N cells of each row, matching all subsequent cells.
-func CellsPerRowOffsetFilter(n int) Filter {
-	return cellsPerRowOffsetFilter(n)
-}
-
-type cellsPerRowOffsetFilter int32
-
-func (cof cellsPerRowOffsetFilter) String() string {
-	return fmt.Sprintf("cells_per_row_offset(%d)", cof)
-}
-
-func (cof cellsPerRowOffsetFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_CellsPerRowOffsetFilter{CellsPerRowOffsetFilter: int32(cof)}}
-}
-
-// CellsPerRowLimitFilter returns a filter that matches only the first N cells of each row.
-func CellsPerRowLimitFilter(n int) Filter {
-	return cellsPerRowLimitFilter(n)
-}
-
-type cellsPerRowLimitFilter int32
-
-func (clf cellsPerRowLimitFilter) String() string {
-	return fmt.Sprintf("cells_per_row_limit(%d)", clf)
-}
-
-func (clf cellsPerRowLimitFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_CellsPerRowLimitFilter{CellsPerRowLimitFilter: int32(clf)}}
-}
-
-// RowSampleFilter returns a filter that matches a row with a probability of p (must be in the interval (0, 1)).
-func RowSampleFilter(p float64) Filter {
-	return rowSampleFilter(p)
-}
-
-type rowSampleFilter float64
-
-func (rsf rowSampleFilter) String() string {
-	return fmt.Sprintf("filter(%f)", rsf)
-}
-
-func (rsf rowSampleFilter) proto() *btpb.RowFilter {
-	return &btpb.RowFilter{Filter: &btpb.RowFilter_RowSampleFilter{RowSampleFilter: float64(rsf)}}
-}

+ 0 - 167
vendor/cloud.google.com/go/bigtable/gc.go

@@ -1,167 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-package bigtable
-
-import (
-	"fmt"
-	"strings"
-	"time"
-
-	durpb "github.com/golang/protobuf/ptypes/duration"
-	bttdpb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
-)
-
-// A GCPolicy represents a rule that determines which cells are eligible for garbage collection.
-type GCPolicy interface {
-	String() string
-	proto() *bttdpb.GcRule
-}
-
-// IntersectionPolicy returns a GC policy that only applies when all its sub-policies apply.
-func IntersectionPolicy(sub ...GCPolicy) GCPolicy { return intersectionPolicy{sub} }
-
-type intersectionPolicy struct {
-	sub []GCPolicy
-}
-
-func (ip intersectionPolicy) String() string {
-	var ss []string
-	for _, sp := range ip.sub {
-		ss = append(ss, sp.String())
-	}
-	return "(" + strings.Join(ss, " && ") + ")"
-}
-
-func (ip intersectionPolicy) proto() *bttdpb.GcRule {
-	inter := &bttdpb.GcRule_Intersection{}
-	for _, sp := range ip.sub {
-		inter.Rules = append(inter.Rules, sp.proto())
-	}
-	return &bttdpb.GcRule{
-		Rule: &bttdpb.GcRule_Intersection_{Intersection: inter},
-	}
-}
-
-// UnionPolicy returns a GC policy that applies when any of its sub-policies apply.
-func UnionPolicy(sub ...GCPolicy) GCPolicy { return unionPolicy{sub} }
-
-type unionPolicy struct {
-	sub []GCPolicy
-}
-
-func (up unionPolicy) String() string {
-	var ss []string
-	for _, sp := range up.sub {
-		ss = append(ss, sp.String())
-	}
-	return "(" + strings.Join(ss, " || ") + ")"
-}
-
-func (up unionPolicy) proto() *bttdpb.GcRule {
-	union := &bttdpb.GcRule_Union{}
-	for _, sp := range up.sub {
-		union.Rules = append(union.Rules, sp.proto())
-	}
-	return &bttdpb.GcRule{
-		Rule: &bttdpb.GcRule_Union_{Union: union},
-	}
-}
-
-// MaxVersionsPolicy returns a GC policy that applies to all versions of a cell
-// except for the most recent n.
-func MaxVersionsPolicy(n int) GCPolicy { return maxVersionsPolicy(n) }
-
-type maxVersionsPolicy int
-
-func (mvp maxVersionsPolicy) String() string { return fmt.Sprintf("versions() > %d", int(mvp)) }
-
-func (mvp maxVersionsPolicy) proto() *bttdpb.GcRule {
-	return &bttdpb.GcRule{Rule: &bttdpb.GcRule_MaxNumVersions{MaxNumVersions: int32(mvp)}}
-}
-
-// MaxAgePolicy returns a GC policy that applies to all cells
-// older than the given age.
-func MaxAgePolicy(d time.Duration) GCPolicy { return maxAgePolicy(d) }
-
-type maxAgePolicy time.Duration
-
-var units = []struct {
-	d      time.Duration
-	suffix string
-}{
-	{24 * time.Hour, "d"},
-	{time.Hour, "h"},
-	{time.Minute, "m"},
-}
-
-func (ma maxAgePolicy) String() string {
-	d := time.Duration(ma)
-	for _, u := range units {
-		if d%u.d == 0 {
-			return fmt.Sprintf("age() > %d%s", d/u.d, u.suffix)
-		}
-	}
-	return fmt.Sprintf("age() > %d", d/time.Microsecond)
-}
-
-func (ma maxAgePolicy) proto() *bttdpb.GcRule {
-	// This doesn't handle overflows, etc.
-	// Fix this if people care about GC policies over 290 years.
-	ns := time.Duration(ma).Nanoseconds()
-	return &bttdpb.GcRule{
-		Rule: &bttdpb.GcRule_MaxAge{MaxAge: &durpb.Duration{
-			Seconds: ns / 1e9,
-			Nanos:   int32(ns % 1e9),
-		}},
-	}
-}
-
-type noGCPolicy struct{}
-
-func (n noGCPolicy) String() string { return "" }
-
-func (n noGCPolicy) proto() *bttdpb.GcRule { return &bttdpb.GcRule{Rule: nil} }
-
-// NoGcPolicy applies to all cells setting maxage and maxversions to nil implies no gc policies
-func NoGcPolicy() GCPolicy { return noGCPolicy{} }
-
-// GCRuleToString converts the given GcRule proto to a user-visible string.
-func GCRuleToString(rule *bttdpb.GcRule) string {
-	if rule == nil {
-		return "<never>"
-	}
-	switch r := rule.Rule.(type) {
-	case *bttdpb.GcRule_MaxNumVersions:
-		return MaxVersionsPolicy(int(r.MaxNumVersions)).String()
-	case *bttdpb.GcRule_MaxAge:
-		return MaxAgePolicy(time.Duration(r.MaxAge.Seconds) * time.Second).String()
-	case *bttdpb.GcRule_Intersection_:
-		return joinRules(r.Intersection.Rules, " && ")
-	case *bttdpb.GcRule_Union_:
-		return joinRules(r.Union.Rules, " || ")
-	default:
-		return ""
-	}
-}
-
-func joinRules(rules []*bttdpb.GcRule, sep string) string {
-	var chunks []string
-	for _, r := range rules {
-		chunks = append(chunks, GCRuleToString(r))
-	}
-	return "(" + strings.Join(chunks, sep) + ")"
-}

+ 0 - 46
vendor/cloud.google.com/go/bigtable/gc_test.go

@@ -1,46 +0,0 @@
-/*
-Copyright 2017 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
-
-    http://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.
-*/
-package bigtable
-
-import (
-	"testing"
-	"time"
-
-	bttdpb "google.golang.org/genproto/googleapis/bigtable/admin/v2"
-)
-
-func TestGcRuleToString(t *testing.T) {
-
-	intersection := IntersectionPolicy(MaxVersionsPolicy(5), MaxVersionsPolicy(10), MaxAgePolicy(16*time.Hour))
-
-	var tests = []struct {
-		proto *bttdpb.GcRule
-		want  string
-	}{
-		{MaxAgePolicy(72 * time.Hour).proto(), "age() > 3d"},
-		{MaxVersionsPolicy(5).proto(), "versions() > 5"},
-		{intersection.proto(), "(versions() > 5 && versions() > 10 && age() > 16h)"},
-		{UnionPolicy(intersection, MaxAgePolicy(72*time.Hour)).proto(),
-			"((versions() > 5 && versions() > 10 && age() > 16h) || age() > 3d)"},
-	}
-
-	for _, test := range tests {
-		got := GCRuleToString(test.proto)
-		if got != test.want {
-			t.Errorf("got gc rule string: %v, wanted: %v", got, test.want)
-		}
-	}
-}

+ 0 - 262
vendor/cloud.google.com/go/bigtable/internal/cbtconfig/cbtconfig.go

@@ -1,262 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-// Package cbtconfig encapsulates common code for reading configuration from .cbtrc and gcloud.
-package cbtconfig
-
-import (
-	"bufio"
-	"bytes"
-	"crypto/tls"
-	"crypto/x509"
-	"encoding/json"
-	"flag"
-	"fmt"
-	"io/ioutil"
-	"log"
-	"os"
-	"os/exec"
-	"path/filepath"
-	"runtime"
-	"strings"
-	"time"
-
-	"golang.org/x/oauth2"
-	"google.golang.org/grpc/credentials"
-)
-
-// Config represents a configuration.
-type Config struct {
-	Project, Instance string                           // required
-	Creds             string                           // optional
-	AdminEndpoint     string                           // optional
-	DataEndpoint      string                           // optional
-	CertFile          string                           // optional
-	UserAgent         string                           // optional
-	TokenSource       oauth2.TokenSource               // derived
-	TLSCreds          credentials.TransportCredentials // derived
-}
-
-// RequiredFlags describes the flag requirements for a cbt command.
-type RequiredFlags uint
-
-const (
-	// NoneRequired specifies that not flags are required.
-	NoneRequired RequiredFlags = 0
-	// ProjectRequired specifies that the -project flag is required.
-	ProjectRequired RequiredFlags = 1 << iota
-	// InstanceRequired specifies that the -instance flag is required.
-	InstanceRequired
-	// ProjectAndInstanceRequired specifies that both -project and -instance is required.
-	ProjectAndInstanceRequired = ProjectRequired | InstanceRequired
-)
-
-// RegisterFlags registers a set of standard flags for this config.
-// It should be called before flag.Parse.
-func (c *Config) RegisterFlags() {
-	flag.StringVar(&c.Project, "project", c.Project, "project ID, if unset uses gcloud configured project")
-	flag.StringVar(&c.Instance, "instance", c.Instance, "Cloud Bigtable instance")
-	flag.StringVar(&c.Creds, "creds", c.Creds, "if set, use application credentials in this file")
-	flag.StringVar(&c.AdminEndpoint, "admin-endpoint", c.AdminEndpoint, "Override the admin api endpoint")
-	flag.StringVar(&c.DataEndpoint, "data-endpoint", c.DataEndpoint, "Override the data api endpoint")
-	flag.StringVar(&c.CertFile, "cert-file", c.CertFile, "Override the TLS certificates file")
-	flag.StringVar(&c.UserAgent, "user-agent", c.UserAgent, "Override the user agent string")
-}
-
-// CheckFlags checks that the required config values are set.
-func (c *Config) CheckFlags(required RequiredFlags) error {
-	var missing []string
-	if c.CertFile != "" {
-		b, err := ioutil.ReadFile(c.CertFile)
-		if err != nil {
-			return fmt.Errorf("Failed to load certificates from %s: %v", c.CertFile, err)
-		}
-
-		cp := x509.NewCertPool()
-		if !cp.AppendCertsFromPEM(b) {
-			return fmt.Errorf("Failed to append certificates from %s", c.CertFile)
-		}
-
-		c.TLSCreds = credentials.NewTLS(&tls.Config{RootCAs: cp})
-	}
-	if required != NoneRequired {
-		c.SetFromGcloud()
-	}
-	if required&ProjectRequired != 0 && c.Project == "" {
-		missing = append(missing, "-project")
-	}
-	if required&InstanceRequired != 0 && c.Instance == "" {
-		missing = append(missing, "-instance")
-	}
-	if len(missing) > 0 {
-		return fmt.Errorf("Missing %s", strings.Join(missing, " and "))
-	}
-	return nil
-}
-
-// Filename returns the filename consulted for standard configuration.
-func Filename() string {
-	// TODO(dsymonds): Might need tweaking for Windows.
-	return filepath.Join(os.Getenv("HOME"), ".cbtrc")
-}
-
-// Load loads a .cbtrc file.
-// If the file is not present, an empty config is returned.
-func Load() (*Config, error) {
-	filename := Filename()
-	data, err := ioutil.ReadFile(filename)
-	if err != nil {
-		// silent fail if the file isn't there
-		if os.IsNotExist(err) {
-			return &Config{}, nil
-		}
-		return nil, fmt.Errorf("Reading %s: %v", filename, err)
-	}
-	c := new(Config)
-	s := bufio.NewScanner(bytes.NewReader(data))
-	for s.Scan() {
-		line := s.Text()
-		i := strings.Index(line, "=")
-		if i < 0 {
-			return nil, fmt.Errorf("Bad line in %s: %q", filename, line)
-		}
-		key, val := strings.TrimSpace(line[:i]), strings.TrimSpace(line[i+1:])
-		switch key {
-		default:
-			return nil, fmt.Errorf("Unknown key in %s: %q", filename, key)
-		case "project":
-			c.Project = val
-		case "instance":
-			c.Instance = val
-		case "creds":
-			c.Creds = val
-		case "admin-endpoint":
-			c.AdminEndpoint = val
-		case "data-endpoint":
-			c.DataEndpoint = val
-		case "cert-file":
-			c.CertFile = val
-		case "user-agent":
-			c.UserAgent = val
-		}
-
-	}
-	return c, s.Err()
-}
-
-// GcloudCredential holds gcloud credential information.
-type GcloudCredential struct {
-	AccessToken string    `json:"access_token"`
-	Expiry      time.Time `json:"token_expiry"`
-}
-
-// Token creates an oauth2 token using gcloud credentials.
-func (cred *GcloudCredential) Token() *oauth2.Token {
-	return &oauth2.Token{AccessToken: cred.AccessToken, TokenType: "Bearer", Expiry: cred.Expiry}
-}
-
-// GcloudConfig holds gcloud configuration values.
-type GcloudConfig struct {
-	Configuration struct {
-		Properties struct {
-			Core struct {
-				Project string `json:"project"`
-			} `json:"core"`
-		} `json:"properties"`
-	} `json:"configuration"`
-	Credential GcloudCredential `json:"credential"`
-}
-
-// GcloudCmdTokenSource holds the comamnd arguments. It is only intended to be set by the program.
-// TODO(deklerk) Can this be unexported?
-type GcloudCmdTokenSource struct {
-	Command string
-	Args    []string
-}
-
-// Token implements the oauth2.TokenSource interface
-func (g *GcloudCmdTokenSource) Token() (*oauth2.Token, error) {
-	gcloudConfig, err := LoadGcloudConfig(g.Command, g.Args)
-	if err != nil {
-		return nil, err
-	}
-	return gcloudConfig.Credential.Token(), nil
-}
-
-// LoadGcloudConfig retrieves the gcloud configuration values we need use via the
-// 'config-helper' command
-func LoadGcloudConfig(gcloudCmd string, gcloudCmdArgs []string) (*GcloudConfig, error) {
-	out, err := exec.Command(gcloudCmd, gcloudCmdArgs...).Output()
-	if err != nil {
-		return nil, fmt.Errorf("Could not retrieve gcloud configuration")
-	}
-
-	var gcloudConfig GcloudConfig
-	if err := json.Unmarshal(out, &gcloudConfig); err != nil {
-		return nil, fmt.Errorf("Could not parse gcloud configuration")
-	}
-
-	return &gcloudConfig, nil
-}
-
-// SetFromGcloud retrieves and sets any missing config values from the gcloud
-// configuration if possible possible
-func (c *Config) SetFromGcloud() error {
-
-	if c.Creds == "" {
-		c.Creds = os.Getenv("GOOGLE_APPLICATION_CREDENTIALS")
-		if c.Creds == "" {
-			log.Printf("-creds flag unset, will use gcloud credential")
-		}
-	} else {
-		os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", c.Creds)
-	}
-
-	if c.Project == "" {
-		log.Printf("-project flag unset, will use gcloud active project")
-	}
-
-	if c.Creds != "" && c.Project != "" {
-		return nil
-	}
-
-	gcloudCmd := "gcloud"
-	if runtime.GOOS == "windows" {
-		gcloudCmd = gcloudCmd + ".cmd"
-	}
-
-	gcloudCmdArgs := []string{"config", "config-helper",
-		"--format=json(configuration.properties.core.project,credential)"}
-
-	gcloudConfig, err := LoadGcloudConfig(gcloudCmd, gcloudCmdArgs)
-	if err != nil {
-		return err
-	}
-
-	if c.Project == "" && gcloudConfig.Configuration.Properties.Core.Project != "" {
-		log.Printf("gcloud active project is \"%s\"",
-			gcloudConfig.Configuration.Properties.Core.Project)
-		c.Project = gcloudConfig.Configuration.Properties.Core.Project
-	}
-
-	if c.Creds == "" {
-		c.TokenSource = oauth2.ReuseTokenSource(
-			gcloudConfig.Credential.Token(),
-			&GcloudCmdTokenSource{Command: gcloudCmd, Args: gcloudCmdArgs})
-	}
-
-	return nil
-}

+ 0 - 110
vendor/cloud.google.com/go/bigtable/internal/gax/call_option.go

@@ -1,110 +0,0 @@
-/*
-Copyright 2016 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
-
-    http://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.
-*/
-
-// Package gax is a snapshot from github.com/googleapis/gax-go/v2 with minor modifications.
-package gax
-
-import (
-	"time"
-
-	"google.golang.org/grpc/codes"
-)
-
-// CallOption is a generic interface for modifying the behavior of outbound calls.
-type CallOption interface {
-	Resolve(*CallSettings)
-}
-
-type callOptions []CallOption
-
-// Resolve resolves all call options individually.
-func (opts callOptions) Resolve(s *CallSettings) *CallSettings {
-	for _, opt := range opts {
-		opt.Resolve(s)
-	}
-	return s
-}
-
-// CallSettings encapsulates the call settings for a particular API call.
-type CallSettings struct {
-	Timeout       time.Duration
-	RetrySettings RetrySettings
-}
-
-// RetrySettings are per-call configurable settings for retrying upon transient failure.
-type RetrySettings struct {
-	RetryCodes      map[codes.Code]bool
-	BackoffSettings BackoffSettings
-}
-
-// BackoffSettings are parameters to the exponential backoff algorithm for retrying.
-type BackoffSettings struct {
-	DelayTimeoutSettings MultipliableDuration
-	RPCTimeoutSettings   MultipliableDuration
-}
-
-// MultipliableDuration defines parameters for backoff settings.
-type MultipliableDuration struct {
-	Initial    time.Duration
-	Max        time.Duration
-	Multiplier float64
-}
-
-// Resolve merges the receiver CallSettings into the given CallSettings.
-func (w CallSettings) Resolve(s *CallSettings) {
-	s.Timeout = w.Timeout
-	s.RetrySettings = w.RetrySettings
-
-	s.RetrySettings.RetryCodes = make(map[codes.Code]bool, len(w.RetrySettings.RetryCodes))
-	for key, value := range w.RetrySettings.RetryCodes {
-		s.RetrySettings.RetryCodes[key] = value
-	}
-}
-
-type withRetryCodes []codes.Code
-
-func (w withRetryCodes) Resolve(s *CallSettings) {
-	s.RetrySettings.RetryCodes = make(map[codes.Code]bool)
-	for _, code := range w {
-		s.RetrySettings.RetryCodes[code] = true
-	}
-}
-
-// WithRetryCodes sets a list of Google API canonical error codes upon which a
-// retry should be attempted.
-func WithRetryCodes(retryCodes []codes.Code) CallOption {
-	return withRetryCodes(retryCodes)
-}
-
-type withDelayTimeoutSettings MultipliableDuration
-
-func (w withDelayTimeoutSettings) Resolve(s *CallSettings) {
-	s.RetrySettings.BackoffSettings.DelayTimeoutSettings = MultipliableDuration(w)
-}
-
-// WithDelayTimeoutSettings specifies:
-// - The initial delay time, in milliseconds, between the completion of
-//   the first failed request and the initiation of the first retrying
-//   request.
-// - The multiplier by which to increase the delay time between the
-//   completion of failed requests, and the initiation of the subsequent
-//   retrying request.
-// - The maximum delay time, in milliseconds, between requests. When this
-//   value is reached, `RetryDelayMultiplier` will no longer be used to
-//   increase delay time.
-func WithDelayTimeoutSettings(initial time.Duration, max time.Duration, multiplier float64) CallOption {
-	return withDelayTimeoutSettings(MultipliableDuration{initial, max, multiplier})
-}

+ 0 - 87
vendor/cloud.google.com/go/bigtable/internal/gax/invoke.go

@@ -1,87 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-// Package gax is a snapshot from github.com/googleapis/gax-go/v2 with minor modifications.
-package gax
-
-import (
-	"context"
-	"log"
-	"math/rand"
-	"os"
-	"time"
-
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/codes"
-)
-
-// Logger is a logger that logs to stderr.
-var Logger = log.New(os.Stderr, "", log.LstdFlags)
-
-// APICall is a user defined call stub.
-type APICall func(context.Context) error
-
-// scaleDuration returns the product of a and mult.
-func scaleDuration(a time.Duration, mult float64) time.Duration {
-	ns := float64(a) * mult
-	return time.Duration(ns)
-}
-
-// invokeWithRetry calls stub using an exponential backoff retry mechanism
-// based on the values provided in callSettings.
-func invokeWithRetry(ctx context.Context, stub APICall, callSettings CallSettings) error {
-	retrySettings := callSettings.RetrySettings
-	backoffSettings := callSettings.RetrySettings.BackoffSettings
-	delay := backoffSettings.DelayTimeoutSettings.Initial
-	for {
-		// If the deadline is exceeded...
-		if ctx.Err() != nil {
-			return ctx.Err()
-		}
-		err := stub(ctx)
-		code := grpc.Code(err)
-		if code == codes.OK {
-			return nil
-		}
-
-		if !retrySettings.RetryCodes[code] {
-			return err
-		}
-
-		// Sleep a random amount up to the current delay
-		d := time.Duration(rand.Int63n(int64(delay)))
-		delayCtx, _ := context.WithTimeout(ctx, delay)
-		if Logger != nil {
-			Logger.Printf("Retryable error: %v, retrying in %v", err, d)
-		}
-		<-delayCtx.Done()
-
-		delay = scaleDuration(delay, backoffSettings.DelayTimeoutSettings.Multiplier)
-		if delay > backoffSettings.DelayTimeoutSettings.Max {
-			delay = backoffSettings.DelayTimeoutSettings.Max
-		}
-	}
-}
-
-// Invoke calls stub with a child of context modified by the specified options.
-func Invoke(ctx context.Context, stub APICall, opts ...CallOption) error {
-	settings := &CallSettings{}
-	callOptions(opts).Resolve(settings)
-	if len(settings.RetrySettings.RetryCodes) > 0 {
-		return invokeWithRetry(ctx, stub, *settings)
-	}
-	return stub(ctx)
-}

+ 0 - 49
vendor/cloud.google.com/go/bigtable/internal/gax/invoke_test.go

@@ -1,49 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-package gax
-
-import (
-	"context"
-	"testing"
-	"time"
-
-	"google.golang.org/grpc/codes"
-	"google.golang.org/grpc/status"
-)
-
-func TestRandomizedDelays(t *testing.T) {
-	max := 200 * time.Millisecond
-	settings := []CallOption{
-		WithRetryCodes([]codes.Code{codes.Unavailable, codes.DeadlineExceeded}),
-		WithDelayTimeoutSettings(10*time.Millisecond, max, 1.5),
-	}
-
-	deadline := time.Now().Add(1 * time.Second)
-	ctx, _ := context.WithDeadline(context.Background(), deadline)
-	var invokeTime time.Time
-	_ = Invoke(ctx, func(childCtx context.Context) error {
-		// Keep failing, make sure we never slept more than max (plus a fudge factor)
-		if !invokeTime.IsZero() {
-			if got, want := time.Since(invokeTime), max; got > (want + 20*time.Millisecond) {
-				t.Logf("Slept too long. Got: %v, want: %v", got, max)
-			}
-		}
-		invokeTime = time.Now()
-		// Workaround for `go vet`: https://github.com/grpc/grpc-go/issues/90
-		errf := status.Errorf
-		return errf(codes.Unavailable, "")
-	}, settings...)
-}

+ 0 - 48
vendor/cloud.google.com/go/bigtable/internal/option/option.go

@@ -1,48 +0,0 @@
-/*
-Copyright 2015 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
-
-    http://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.
-*/
-
-// Package option contains common code for dealing with client options.
-package option
-
-import (
-	"fmt"
-	"os"
-
-	"google.golang.org/api/option"
-	"google.golang.org/grpc"
-)
-
-// DefaultClientOptions returns the default client options to use for the
-// client's gRPC connection.
-func DefaultClientOptions(endpoint, scope, userAgent string) ([]option.ClientOption, error) {
-	var o []option.ClientOption
-	// Check the environment variables for the bigtable emulator.
-	// Dial it directly and don't pass any credentials.
-	if addr := os.Getenv("BIGTABLE_EMULATOR_HOST"); addr != "" {
-		conn, err := grpc.Dial(addr, grpc.WithInsecure())
-		if err != nil {
-			return nil, fmt.Errorf("emulator grpc.Dial: %v", err)
-		}
-		o = []option.ClientOption{option.WithGRPCConn(conn)}
-	} else {
-		o = []option.ClientOption{
-			option.WithEndpoint(endpoint),
-			option.WithScopes(scope),
-			option.WithUserAgent(userAgent),
-		}
-	}
-	return o, nil
-}

Некоторые файлы не были показаны из-за большого количества измененных файлов