diff --git a/clouddms/apiv1/doc.go b/clouddms/apiv1/doc.go index 28090a3225e8..7c92d8459501 100644 --- a/clouddms/apiv1/doc.go +++ b/clouddms/apiv1/doc.go @@ -51,7 +51,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210602" +const versionClient = "20210603" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/documentai/apiv1beta3/doc.go b/documentai/apiv1beta3/doc.go index c7d758280025..5bf04a44c4ce 100644 --- a/documentai/apiv1beta3/doc.go +++ b/documentai/apiv1beta3/doc.go @@ -52,7 +52,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210602" +const versionClient = "20210603" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/go.mod b/go.mod index 04ee0cb44304..96c0459deb2d 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( golang.org/x/text v0.3.6 golang.org/x/tools v0.1.2 google.golang.org/api v0.47.0 - google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c + google.golang.org/genproto v0.0.0-20210603172842-58e84a565dcf google.golang.org/grpc v1.38.0 google.golang.org/protobuf v1.26.0 ) diff --git a/go.sum b/go.sum index 6ed2bf87a31b..cb0e7bcae9fb 100644 --- a/go.sum +++ b/go.sum @@ -443,8 +443,8 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210603172842-58e84a565dcf h1:3oVOonZQld/0ddUsMXCnkhem95RnnQEUMZQLJP1s3jQ= +google.golang.org/genproto v0.0.0-20210603172842-58e84a565dcf/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/internal/generated/snippets/go.mod b/internal/generated/snippets/go.mod index d65450331aaa..123407d67334 100644 --- a/internal/generated/snippets/go.mod +++ b/internal/generated/snippets/go.mod @@ -32,5 +32,5 @@ require ( cloud.google.com/go/pubsublite v0.82.0 cloud.google.com/go/spanner v0.82.0 google.golang.org/api v0.47.0 - google.golang.org/genproto v0.0.0-20210601144548-a796c710e9b6 + google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c ) diff --git a/internal/generated/snippets/go.sum b/internal/generated/snippets/go.sum index d1a5629f0bba..5098b6626286 100644 --- a/internal/generated/snippets/go.sum +++ b/internal/generated/snippets/go.sum @@ -143,8 +143,9 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210601144548-a796c710e9b6 h1:zWmI+1Z2ZiKs1ceiAn4gjBd1v/d/AuWf/b+bLPe9aNw= google.golang.org/genproto v0.0.0-20210601144548-a796c710e9b6/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/internal/generated/snippets/pubsublite/apiv1/AdminClient/CreateReservation/main.go b/internal/generated/snippets/pubsublite/apiv1/AdminClient/CreateReservation/main.go new file mode 100644 index 000000000000..37f4a92079fd --- /dev/null +++ b/internal/generated/snippets/pubsublite/apiv1/AdminClient/CreateReservation/main.go @@ -0,0 +1,45 @@ +// Copyright 2021 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. + +// [START pubsublite_v1_generated_AdminService_CreateReservation_sync] + +package main + +import ( + "context" + + pubsublite "cloud.google.com/go/pubsublite/apiv1" + pubsublitepb "google.golang.org/genproto/googleapis/cloud/pubsublite/v1" +) + +func main() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.CreateReservationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.CreateReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END pubsublite_v1_generated_AdminService_CreateReservation_sync] diff --git a/internal/generated/snippets/pubsublite/apiv1/AdminClient/DeleteReservation/main.go b/internal/generated/snippets/pubsublite/apiv1/AdminClient/DeleteReservation/main.go new file mode 100644 index 000000000000..557997f4ea5c --- /dev/null +++ b/internal/generated/snippets/pubsublite/apiv1/AdminClient/DeleteReservation/main.go @@ -0,0 +1,43 @@ +// Copyright 2021 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. + +// [START pubsublite_v1_generated_AdminService_DeleteReservation_sync] + +package main + +import ( + "context" + + pubsublite "cloud.google.com/go/pubsublite/apiv1" + pubsublitepb "google.golang.org/genproto/googleapis/cloud/pubsublite/v1" +) + +func main() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.DeleteReservationRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END pubsublite_v1_generated_AdminService_DeleteReservation_sync] diff --git a/internal/generated/snippets/pubsublite/apiv1/AdminClient/GetReservation/main.go b/internal/generated/snippets/pubsublite/apiv1/AdminClient/GetReservation/main.go new file mode 100644 index 000000000000..8d0614ad00b6 --- /dev/null +++ b/internal/generated/snippets/pubsublite/apiv1/AdminClient/GetReservation/main.go @@ -0,0 +1,45 @@ +// Copyright 2021 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. + +// [START pubsublite_v1_generated_AdminService_GetReservation_sync] + +package main + +import ( + "context" + + pubsublite "cloud.google.com/go/pubsublite/apiv1" + pubsublitepb "google.golang.org/genproto/googleapis/cloud/pubsublite/v1" +) + +func main() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.GetReservationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END pubsublite_v1_generated_AdminService_GetReservation_sync] diff --git a/internal/generated/snippets/pubsublite/apiv1/AdminClient/ListReservationTopics/main.go b/internal/generated/snippets/pubsublite/apiv1/AdminClient/ListReservationTopics/main.go new file mode 100644 index 000000000000..b0b69e7825da --- /dev/null +++ b/internal/generated/snippets/pubsublite/apiv1/AdminClient/ListReservationTopics/main.go @@ -0,0 +1,52 @@ +// Copyright 2021 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. + +// [START pubsublite_v1_generated_AdminService_ListReservationTopics_sync] + +package main + +import ( + "context" + + pubsublite "cloud.google.com/go/pubsublite/apiv1" + "google.golang.org/api/iterator" + pubsublitepb "google.golang.org/genproto/googleapis/cloud/pubsublite/v1" +) + +func main() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.ListReservationTopicsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListReservationTopics(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END pubsublite_v1_generated_AdminService_ListReservationTopics_sync] diff --git a/internal/generated/snippets/pubsublite/apiv1/AdminClient/ListReservations/main.go b/internal/generated/snippets/pubsublite/apiv1/AdminClient/ListReservations/main.go new file mode 100644 index 000000000000..0bfb5c15fa52 --- /dev/null +++ b/internal/generated/snippets/pubsublite/apiv1/AdminClient/ListReservations/main.go @@ -0,0 +1,52 @@ +// Copyright 2021 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. + +// [START pubsublite_v1_generated_AdminService_ListReservations_sync] + +package main + +import ( + "context" + + pubsublite "cloud.google.com/go/pubsublite/apiv1" + "google.golang.org/api/iterator" + pubsublitepb "google.golang.org/genproto/googleapis/cloud/pubsublite/v1" +) + +func main() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.ListReservationsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListReservations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END pubsublite_v1_generated_AdminService_ListReservations_sync] diff --git a/internal/generated/snippets/pubsublite/apiv1/AdminClient/UpdateReservation/main.go b/internal/generated/snippets/pubsublite/apiv1/AdminClient/UpdateReservation/main.go new file mode 100644 index 000000000000..e17138400c7e --- /dev/null +++ b/internal/generated/snippets/pubsublite/apiv1/AdminClient/UpdateReservation/main.go @@ -0,0 +1,45 @@ +// Copyright 2021 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. + +// [START pubsublite_v1_generated_AdminService_UpdateReservation_sync] + +package main + +import ( + "context" + + pubsublite "cloud.google.com/go/pubsublite/apiv1" + pubsublitepb "google.golang.org/genproto/googleapis/cloud/pubsublite/v1" +) + +func main() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.UpdateReservationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END pubsublite_v1_generated_AdminService_UpdateReservation_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/CreateNode/main.go b/internal/generated/snippets/tpu/apiv1/Client/CreateNode/main.go new file mode 100644 index 000000000000..003093622552 --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/CreateNode/main.go @@ -0,0 +1,50 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_CreateNode_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.CreateNodeRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateNode(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_CreateNode_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/DeleteNode/main.go b/internal/generated/snippets/tpu/apiv1/Client/DeleteNode/main.go new file mode 100644 index 000000000000..7999c0c5cd30 --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/DeleteNode/main.go @@ -0,0 +1,50 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_DeleteNode_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.DeleteNodeRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteNode(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_DeleteNode_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/GetAcceleratorType/main.go b/internal/generated/snippets/tpu/apiv1/Client/GetAcceleratorType/main.go new file mode 100644 index 000000000000..ff68c718a7bb --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/GetAcceleratorType/main.go @@ -0,0 +1,45 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_GetAcceleratorType_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.GetAcceleratorTypeRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetAcceleratorType(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_GetAcceleratorType_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/GetNode/main.go b/internal/generated/snippets/tpu/apiv1/Client/GetNode/main.go new file mode 100644 index 000000000000..5f4e43c80969 --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/GetNode/main.go @@ -0,0 +1,45 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_GetNode_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.GetNodeRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetNode(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_GetNode_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/GetTensorFlowVersion/main.go b/internal/generated/snippets/tpu/apiv1/Client/GetTensorFlowVersion/main.go new file mode 100644 index 000000000000..d2ffe16ebd83 --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/GetTensorFlowVersion/main.go @@ -0,0 +1,45 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_GetTensorFlowVersion_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.GetTensorFlowVersionRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetTensorFlowVersion(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_GetTensorFlowVersion_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/ListAcceleratorTypes/main.go b/internal/generated/snippets/tpu/apiv1/Client/ListAcceleratorTypes/main.go new file mode 100644 index 000000000000..a1fc31ca12df --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/ListAcceleratorTypes/main.go @@ -0,0 +1,52 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_ListAcceleratorTypes_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + "google.golang.org/api/iterator" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.ListAcceleratorTypesRequest{ + // TODO: Fill request struct fields. + } + it := c.ListAcceleratorTypes(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END tpu_v1_generated_Tpu_ListAcceleratorTypes_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/ListNodes/main.go b/internal/generated/snippets/tpu/apiv1/Client/ListNodes/main.go new file mode 100644 index 000000000000..bff90362b572 --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/ListNodes/main.go @@ -0,0 +1,52 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_ListNodes_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + "google.golang.org/api/iterator" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.ListNodesRequest{ + // TODO: Fill request struct fields. + } + it := c.ListNodes(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END tpu_v1_generated_Tpu_ListNodes_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/ListTensorFlowVersions/main.go b/internal/generated/snippets/tpu/apiv1/Client/ListTensorFlowVersions/main.go new file mode 100644 index 000000000000..a62577ac8ad1 --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/ListTensorFlowVersions/main.go @@ -0,0 +1,52 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_ListTensorFlowVersions_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + "google.golang.org/api/iterator" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.ListTensorFlowVersionsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListTensorFlowVersions(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END tpu_v1_generated_Tpu_ListTensorFlowVersions_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/ReimageNode/main.go b/internal/generated/snippets/tpu/apiv1/Client/ReimageNode/main.go new file mode 100644 index 000000000000..e62477d28b4b --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/ReimageNode/main.go @@ -0,0 +1,50 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_ReimageNode_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.ReimageNodeRequest{ + // TODO: Fill request struct fields. + } + op, err := c.ReimageNode(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_ReimageNode_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/StartNode/main.go b/internal/generated/snippets/tpu/apiv1/Client/StartNode/main.go new file mode 100644 index 000000000000..bd3fa9f24e02 --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/StartNode/main.go @@ -0,0 +1,50 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_StartNode_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.StartNodeRequest{ + // TODO: Fill request struct fields. + } + op, err := c.StartNode(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_StartNode_sync] diff --git a/internal/generated/snippets/tpu/apiv1/Client/StopNode/main.go b/internal/generated/snippets/tpu/apiv1/Client/StopNode/main.go new file mode 100644 index 000000000000..deb408e0fd5e --- /dev/null +++ b/internal/generated/snippets/tpu/apiv1/Client/StopNode/main.go @@ -0,0 +1,50 @@ +// Copyright 2021 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. + +// [START tpu_v1_generated_Tpu_StopNode_sync] + +package main + +import ( + "context" + + tpu "cloud.google.com/go/tpu/apiv1" + tpupb "google.golang.org/genproto/googleapis/cloud/tpu/v1" +) + +func main() { + ctx := context.Background() + c, err := tpu.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &tpupb.StopNodeRequest{ + // TODO: Fill request struct fields. + } + op, err := c.StopNode(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END tpu_v1_generated_Tpu_StopNode_sync] diff --git a/pubsublite/apiv1/admin_client.go b/pubsublite/apiv1/admin_client.go index 824c8b29e9bb..81339cdfd025 100644 --- a/pubsublite/apiv1/admin_client.go +++ b/pubsublite/apiv1/admin_client.go @@ -51,6 +51,12 @@ type AdminCallOptions struct { ListSubscriptions []gax.CallOption UpdateSubscription []gax.CallOption DeleteSubscription []gax.CallOption + CreateReservation []gax.CallOption + GetReservation []gax.CallOption + ListReservations []gax.CallOption + UpdateReservation []gax.CallOption + DeleteReservation []gax.CallOption + ListReservationTopics []gax.CallOption } func defaultAdminGRPCClientOptions() []option.ClientOption { @@ -247,6 +253,96 @@ func defaultAdminCallOptions() *AdminCallOptions { }) }), }, + CreateReservation: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + codes.Aborted, + codes.Internal, + codes.Unknown, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetReservation: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + codes.Aborted, + codes.Internal, + codes.Unknown, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListReservations: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + codes.Aborted, + codes.Internal, + codes.Unknown, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateReservation: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + codes.Aborted, + codes.Internal, + codes.Unknown, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + DeleteReservation: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + codes.Aborted, + codes.Internal, + codes.Unknown, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListReservationTopics: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + codes.Aborted, + codes.Internal, + codes.Unknown, + }, gax.Backoff{ + Initial: 100 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, } } @@ -267,6 +363,12 @@ type internalAdminClient interface { ListSubscriptions(context.Context, *pubsublitepb.ListSubscriptionsRequest, ...gax.CallOption) *SubscriptionIterator UpdateSubscription(context.Context, *pubsublitepb.UpdateSubscriptionRequest, ...gax.CallOption) (*pubsublitepb.Subscription, error) DeleteSubscription(context.Context, *pubsublitepb.DeleteSubscriptionRequest, ...gax.CallOption) error + CreateReservation(context.Context, *pubsublitepb.CreateReservationRequest, ...gax.CallOption) (*pubsublitepb.Reservation, error) + GetReservation(context.Context, *pubsublitepb.GetReservationRequest, ...gax.CallOption) (*pubsublitepb.Reservation, error) + ListReservations(context.Context, *pubsublitepb.ListReservationsRequest, ...gax.CallOption) *ReservationIterator + UpdateReservation(context.Context, *pubsublitepb.UpdateReservationRequest, ...gax.CallOption) (*pubsublitepb.Reservation, error) + DeleteReservation(context.Context, *pubsublitepb.DeleteReservationRequest, ...gax.CallOption) error + ListReservationTopics(context.Context, *pubsublitepb.ListReservationTopicsRequest, ...gax.CallOption) *StringIterator } // AdminClient is a client for interacting with Pub/Sub Lite API. @@ -364,6 +466,36 @@ func (c *AdminClient) DeleteSubscription(ctx context.Context, req *pubsublitepb. return c.internalClient.DeleteSubscription(ctx, req, opts...) } +// CreateReservation creates a new reservation. +func (c *AdminClient) CreateReservation(ctx context.Context, req *pubsublitepb.CreateReservationRequest, opts ...gax.CallOption) (*pubsublitepb.Reservation, error) { + return c.internalClient.CreateReservation(ctx, req, opts...) +} + +// GetReservation returns the reservation configuration. +func (c *AdminClient) GetReservation(ctx context.Context, req *pubsublitepb.GetReservationRequest, opts ...gax.CallOption) (*pubsublitepb.Reservation, error) { + return c.internalClient.GetReservation(ctx, req, opts...) +} + +// ListReservations returns the list of reservations for the given project. +func (c *AdminClient) ListReservations(ctx context.Context, req *pubsublitepb.ListReservationsRequest, opts ...gax.CallOption) *ReservationIterator { + return c.internalClient.ListReservations(ctx, req, opts...) +} + +// UpdateReservation updates properties of the specified reservation. +func (c *AdminClient) UpdateReservation(ctx context.Context, req *pubsublitepb.UpdateReservationRequest, opts ...gax.CallOption) (*pubsublitepb.Reservation, error) { + return c.internalClient.UpdateReservation(ctx, req, opts...) +} + +// DeleteReservation deletes the specified reservation. +func (c *AdminClient) DeleteReservation(ctx context.Context, req *pubsublitepb.DeleteReservationRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteReservation(ctx, req, opts...) +} + +// ListReservationTopics lists the topics attached to the specified reservation. +func (c *AdminClient) ListReservationTopics(ctx context.Context, req *pubsublitepb.ListReservationTopicsRequest, opts ...gax.CallOption) *StringIterator { + return c.internalClient.ListReservationTopics(ctx, req, opts...) +} + // adminGRPCClient is a client for interacting with Pub/Sub Lite API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. @@ -746,6 +878,213 @@ func (c *adminGRPCClient) DeleteSubscription(ctx context.Context, req *pubsublit return err } +func (c *adminGRPCClient) CreateReservation(ctx context.Context, req *pubsublitepb.CreateReservationRequest, opts ...gax.CallOption) (*pubsublitepb.Reservation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).CreateReservation[0:len((*c.CallOptions).CreateReservation):len((*c.CallOptions).CreateReservation)], opts...) + var resp *pubsublitepb.Reservation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.adminClient.CreateReservation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *adminGRPCClient) GetReservation(ctx context.Context, req *pubsublitepb.GetReservationRequest, opts ...gax.CallOption) (*pubsublitepb.Reservation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetReservation[0:len((*c.CallOptions).GetReservation):len((*c.CallOptions).GetReservation)], opts...) + var resp *pubsublitepb.Reservation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.adminClient.GetReservation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *adminGRPCClient) ListReservations(ctx context.Context, req *pubsublitepb.ListReservationsRequest, opts ...gax.CallOption) *ReservationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListReservations[0:len((*c.CallOptions).ListReservations):len((*c.CallOptions).ListReservations)], opts...) + it := &ReservationIterator{} + req = proto.Clone(req).(*pubsublitepb.ListReservationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*pubsublitepb.Reservation, string, error) { + var resp *pubsublitepb.ListReservationsResponse + 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.adminClient.ListReservations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetReservations(), resp.GetNextPageToken(), 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.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +func (c *adminGRPCClient) UpdateReservation(ctx context.Context, req *pubsublitepb.UpdateReservationRequest, opts ...gax.CallOption) (*pubsublitepb.Reservation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "reservation.name", url.QueryEscape(req.GetReservation().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).UpdateReservation[0:len((*c.CallOptions).UpdateReservation):len((*c.CallOptions).UpdateReservation)], opts...) + var resp *pubsublitepb.Reservation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.adminClient.UpdateReservation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *adminGRPCClient) DeleteReservation(ctx context.Context, req *pubsublitepb.DeleteReservationRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).DeleteReservation[0:len((*c.CallOptions).DeleteReservation):len((*c.CallOptions).DeleteReservation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.adminClient.DeleteReservation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *adminGRPCClient) ListReservationTopics(ctx context.Context, req *pubsublitepb.ListReservationTopicsRequest, opts ...gax.CallOption) *StringIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListReservationTopics[0:len((*c.CallOptions).ListReservationTopics):len((*c.CallOptions).ListReservationTopics)], opts...) + it := &StringIterator{} + req = proto.Clone(req).(*pubsublitepb.ListReservationTopicsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]string, string, error) { + var resp *pubsublitepb.ListReservationTopicsResponse + 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.adminClient.ListReservationTopics(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetTopics(), resp.GetNextPageToken(), 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.GetPageSize()) + it.pageInfo.Token = req.GetPageToken() + return it +} + +// ReservationIterator manages a stream of *pubsublitepb.Reservation. +type ReservationIterator struct { + items []*pubsublitepb.Reservation + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // 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 []*pubsublitepb.Reservation, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ReservationIterator) 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 *ReservationIterator) Next() (*pubsublitepb.Reservation, error) { + var item *pubsublitepb.Reservation + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ReservationIterator) bufLen() int { + return len(it.items) +} + +func (it *ReservationIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + // StringIterator manages a stream of string. type StringIterator struct { items []string diff --git a/pubsublite/apiv1/admin_client_example_test.go b/pubsublite/apiv1/admin_client_example_test.go index a7d22f1014a8..dcec2c2a66fb 100644 --- a/pubsublite/apiv1/admin_client_example_test.go +++ b/pubsublite/apiv1/admin_client_example_test.go @@ -277,3 +277,127 @@ func ExampleAdminClient_DeleteSubscription() { // TODO: Handle error. } } + +func ExampleAdminClient_CreateReservation() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.CreateReservationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.CreateReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleAdminClient_GetReservation() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.GetReservationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleAdminClient_ListReservations() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.ListReservationsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListReservations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleAdminClient_UpdateReservation() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.UpdateReservationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleAdminClient_DeleteReservation() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.DeleteReservationRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteReservation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleAdminClient_ListReservationTopics() { + ctx := context.Background() + c, err := pubsublite.NewAdminClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &pubsublitepb.ListReservationTopicsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListReservationTopics(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} diff --git a/pubsublite/apiv1/doc.go b/pubsublite/apiv1/doc.go index 4f7a8ed77019..40b0105defea 100644 --- a/pubsublite/apiv1/doc.go +++ b/pubsublite/apiv1/doc.go @@ -48,7 +48,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20210602" +const versionClient = "20210603" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/pubsublite/apiv1/gapic_metadata.json b/pubsublite/apiv1/gapic_metadata.json index 3c188b82dac2..3c04ceb94cff 100644 --- a/pubsublite/apiv1/gapic_metadata.json +++ b/pubsublite/apiv1/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "AdminClient", "rpcs": { + "CreateReservation": { + "methods": [ + "CreateReservation" + ] + }, "CreateSubscription": { "methods": [ "CreateSubscription" @@ -20,6 +25,11 @@ "CreateTopic" ] }, + "DeleteReservation": { + "methods": [ + "DeleteReservation" + ] + }, "DeleteSubscription": { "methods": [ "DeleteSubscription" @@ -30,6 +40,11 @@ "DeleteTopic" ] }, + "GetReservation": { + "methods": [ + "GetReservation" + ] + }, "GetSubscription": { "methods": [ "GetSubscription" @@ -45,6 +60,16 @@ "GetTopicPartitions" ] }, + "ListReservationTopics": { + "methods": [ + "ListReservationTopics" + ] + }, + "ListReservations": { + "methods": [ + "ListReservations" + ] + }, "ListSubscriptions": { "methods": [ "ListSubscriptions" @@ -60,6 +85,11 @@ "ListTopics" ] }, + "UpdateReservation": { + "methods": [ + "UpdateReservation" + ] + }, "UpdateSubscription": { "methods": [ "UpdateSubscription" diff --git a/pubsublite/go.mod b/pubsublite/go.mod index 718a5efa1426..d08d223d58d3 100644 --- a/pubsublite/go.mod +++ b/pubsublite/go.mod @@ -12,7 +12,7 @@ require ( golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 google.golang.org/api v0.47.0 - google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c + google.golang.org/genproto v0.0.0-20210603172842-58e84a565dcf google.golang.org/grpc v1.38.0 google.golang.org/protobuf v1.26.0 ) diff --git a/pubsublite/go.sum b/pubsublite/go.sum index 374a080323af..d6bfe465d867 100644 --- a/pubsublite/go.sum +++ b/pubsublite/go.sum @@ -452,8 +452,8 @@ google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaE google.golang.org/genproto v0.0.0-20210429181445-86c259c2b4ab/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210517163617-5e0236093d7a/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210603172842-58e84a565dcf h1:3oVOonZQld/0ddUsMXCnkhem95RnnQEUMZQLJP1s3jQ= +google.golang.org/genproto v0.0.0-20210603172842-58e84a565dcf/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=