From 3a972e1fa35b9e055b9fec65aa8b7a1c9c1f15e0 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 7 Apr 2022 14:13:32 +0000 Subject: [PATCH] chore(all): auto-regenerate gapics This is an auto-generated regeneration of the gapic clients by cloud.google.com/go/internal/gapicgen. Once the corresponding genproto PR is submitted, genbot will update this PR with a newer dependency to the newer version of genproto and assign reviewers to this PR. If you have been assigned to review this PR, please: - Ensure that the version of genproto in go.mod has been updated. - Ensure that CI is passing. If it's failing, it requires your manual attention. - Approve and submit this PR if you believe it's ready to ship. Corresponding genproto PR: https://github.com/googleapis/go-genproto/pull/791 Changes: feat(securitycenter): Add iam_binding field to findings attributes. It represents particular IAM bindings, which captures a member's role addition, removal, or state PiperOrigin-RevId: 439976914 Source-Link: https://github.com/googleapis/googleapis/commit/f83787ed5e7985e1eceefb56e5fb685dd8eaadf2 chore(dialogflow/cx): remove unused imports PiperOrigin-RevId: 439948451 Source-Link: https://github.com/googleapis/googleapis/commit/1a8770e28e2ddfe4e0d2294bf96a07809fb39246 feat(compute): update compute API to revision 20220322 (#710) Source-Link: https://github.com/googleapis/googleapis/commit/68ad73b682843a999107f30d18ac42d13593a31a docs(bigquery/reservation): Mark v1beta1 API as deprecated PiperOrigin-RevId: 439847134 Source-Link: https://github.com/googleapis/googleapis/commit/3255022a9f4f45f3504a14180e72dd45878665f8 --- bigquery/go.mod | 2 +- bigquery/go.sum | 4 +- .../apiv1beta1/reservation_client.go | 6 + compute/apiv1/gapic_metadata.json | 261 ++++ compute/apiv1/instances_client.go | 4 +- .../network_edge_security_services_client.go | 599 ++++++++ ...e_security_services_client_example_test.go | 152 ++ .../apiv1/network_firewall_policies_client.go | 1245 ++++++++++++++++ ...k_firewall_policies_client_example_test.go | 390 +++++ ...region_network_firewall_policies_client.go | 1310 +++++++++++++++++ ...k_firewall_policies_client_example_test.go | 410 ++++++ .../apiv1/region_security_policies_client.go | 576 ++++++++ ...n_security_policies_client_example_test.go | 152 ++ .../region_target_https_proxies_client.go | 73 + ...arget_https_proxies_client_example_test.go | 23 + compute/apiv1/security_policies_client.go | 132 +- .../security_policies_client_example_test.go | 26 + compute/go.mod | 2 +- compute/go.sum | 3 +- go.mod | 2 +- go.sum | 4 +- .../Client/CreateMigrationWorkflow/main.go | 48 + .../Client/DeleteMigrationWorkflow/main.go | 46 + .../apiv2/Client/GetMigrationSubtask/main.go | 48 + .../apiv2/Client/GetMigrationWorkflow/main.go | 48 + .../Client/ListMigrationSubtasks/main.go | 55 + .../Client/ListMigrationWorkflows/main.go | 55 + .../Client/StartMigrationWorkflow/main.go | 46 + .../AggregatedList/main.go | 55 + .../Delete/main.go | 51 + .../Get/main.go | 48 + .../Insert/main.go | 51 + .../Patch/main.go | 51 + .../AddAssociation/main.go | 51 + .../AddRule/main.go | 51 + .../CloneRules/main.go | 51 + .../Delete/main.go | 51 + .../NetworkFirewallPoliciesClient/Get/main.go | 48 + .../GetAssociation/main.go | 48 + .../GetIamPolicy/main.go | 48 + .../GetRule/main.go | 48 + .../Insert/main.go | 51 + .../List/main.go | 55 + .../Patch/main.go | 51 + .../PatchRule/main.go | 51 + .../RemoveAssociation/main.go | 51 + .../RemoveRule/main.go | 51 + .../SetIamPolicy/main.go | 48 + .../TestIamPermissions/main.go | 48 + .../AddAssociation/main.go | 51 + .../AddRule/main.go | 51 + .../CloneRules/main.go | 51 + .../Delete/main.go | 51 + .../Get/main.go | 48 + .../GetAssociation/main.go | 48 + .../GetEffectiveFirewalls/main.go | 48 + .../GetIamPolicy/main.go | 48 + .../GetRule/main.go | 48 + .../Insert/main.go | 51 + .../List/main.go | 55 + .../Patch/main.go | 51 + .../PatchRule/main.go | 51 + .../RemoveAssociation/main.go | 51 + .../RemoveRule/main.go | 51 + .../SetIamPolicy/main.go | 48 + .../TestIamPermissions/main.go | 48 + .../Delete/main.go | 51 + .../RegionSecurityPoliciesClient/Get/main.go | 48 + .../Insert/main.go | 51 + .../RegionSecurityPoliciesClient/List/main.go | 55 + .../Patch/main.go | 51 + .../Patch/main.go | 51 + .../AggregatedList/main.go | 55 + internal/generated/snippets/go.mod | 2 +- internal/generated/snippets/go.sum | 3 +- internal/godocfx/go.sum | 4 +- storage/go.sum | 1 - 77 files changed, 7978 insertions(+), 24 deletions(-) create mode 100644 compute/apiv1/network_edge_security_services_client.go create mode 100644 compute/apiv1/network_edge_security_services_client_example_test.go create mode 100644 compute/apiv1/network_firewall_policies_client.go create mode 100644 compute/apiv1/network_firewall_policies_client_example_test.go create mode 100644 compute/apiv1/region_network_firewall_policies_client.go create mode 100644 compute/apiv1/region_network_firewall_policies_client_example_test.go create mode 100644 compute/apiv1/region_security_policies_client.go create mode 100644 compute/apiv1/region_security_policies_client_example_test.go create mode 100644 internal/generated/snippets/bigquery/migration/apiv2/Client/CreateMigrationWorkflow/main.go create mode 100644 internal/generated/snippets/bigquery/migration/apiv2/Client/DeleteMigrationWorkflow/main.go create mode 100644 internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationSubtask/main.go create mode 100644 internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationWorkflow/main.go create mode 100644 internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationSubtasks/main.go create mode 100644 internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationWorkflows/main.go create mode 100644 internal/generated/snippets/bigquery/migration/apiv2/Client/StartMigrationWorkflow/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/AggregatedList/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Delete/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Get/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Insert/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Patch/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddAssociation/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/CloneRules/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Delete/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Get/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetAssociation/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetIamPolicy/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Insert/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/List/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Patch/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/PatchRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveAssociation/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/SetIamPolicy/main.go create mode 100644 internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/TestIamPermissions/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddAssociation/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/CloneRules/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Delete/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Get/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetAssociation/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetEffectiveFirewalls/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetIamPolicy/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Insert/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/List/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Patch/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/PatchRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveAssociation/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveRule/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/SetIamPolicy/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/TestIamPermissions/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Delete/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Get/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Insert/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/List/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Patch/main.go create mode 100644 internal/generated/snippets/compute/apiv1/RegionTargetHttpsProxiesClient/Patch/main.go create mode 100644 internal/generated/snippets/compute/apiv1/SecurityPoliciesClient/AggregatedList/main.go diff --git a/bigquery/go.mod b/bigquery/go.mod index 51f7bbef864..a136679fa20 100644 --- a/bigquery/go.mod +++ b/bigquery/go.mod @@ -14,7 +14,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.74.0 - google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de + google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac google.golang.org/grpc v1.45.0 google.golang.org/protobuf v1.28.0 ) diff --git a/bigquery/go.sum b/bigquery/go.sum index ac859b54671..0cbe68ce78e 100644 --- a/bigquery/go.sum +++ b/bigquery/go.sum @@ -561,8 +561,8 @@ google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2 google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de h1:9Ti5SG2U4cAcluryUo/sFay3TQKoxiFMfaT0pbizU7k= -google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= 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/bigquery/reservation/apiv1beta1/reservation_client.go b/bigquery/reservation/apiv1beta1/reservation_client.go index d0fe4dfa18e..c9a2082874c 100644 --- a/bigquery/reservation/apiv1beta1/reservation_client.go +++ b/bigquery/reservation/apiv1beta1/reservation_client.go @@ -235,6 +235,7 @@ type internalClient interface { // Client is a client for interacting with BigQuery Reservation API. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. // +// Deprecated: Please use the v1 api instead. // This API allows users to manage their flat-rate BigQuery reservations. // // A reservation provides computational resource guarantees, in the form of @@ -250,6 +251,8 @@ type internalClient interface { // commitment resource exists as a child resource of the admin project and // location, e.g.: // projects/myproject/locations/US/capacityCommitments/id. +// +// Deprecated: ReservationService may be removed in a future version. type Client struct { // The internal transport-dependent client. internalClient internalClient @@ -526,6 +529,7 @@ type gRPCClient struct { // NewClient creates a new reservation service client based on gRPC. // The returned client must be Closed when it is done being used to clean up its underlying connections. // +// Deprecated: Please use the v1 api instead. // This API allows users to manage their flat-rate BigQuery reservations. // // A reservation provides computational resource guarantees, in the form of @@ -541,6 +545,8 @@ type gRPCClient struct { // commitment resource exists as a child resource of the admin project and // location, e.g.: // projects/myproject/locations/US/capacityCommitments/id. +// +// Deprecated: ReservationService may be removed in a future version. func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { clientOpts := defaultGRPCClientOptions() if newClientHook != nil { diff --git a/compute/apiv1/gapic_metadata.json b/compute/apiv1/gapic_metadata.json index 2f512b0d0f5..0cb48099150 100644 --- a/compute/apiv1/gapic_metadata.json +++ b/compute/apiv1/gapic_metadata.json @@ -1554,6 +1554,40 @@ } } }, + "NetworkEdgeSecurityServices": { + "clients": { + "rest": { + "libraryClient": "NetworkEdgeSecurityServicesClient", + "rpcs": { + "AggregatedList": { + "methods": [ + "AggregatedList" + ] + }, + "Delete": { + "methods": [ + "Delete" + ] + }, + "Get": { + "methods": [ + "Get" + ] + }, + "Insert": { + "methods": [ + "Insert" + ] + }, + "Patch": { + "methods": [ + "Patch" + ] + } + } + } + } + }, "NetworkEndpointGroups": { "clients": { "rest": { @@ -1608,6 +1642,95 @@ } } }, + "NetworkFirewallPolicies": { + "clients": { + "rest": { + "libraryClient": "NetworkFirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "AddAssociation" + ] + }, + "AddRule": { + "methods": [ + "AddRule" + ] + }, + "CloneRules": { + "methods": [ + "CloneRules" + ] + }, + "Delete": { + "methods": [ + "Delete" + ] + }, + "Get": { + "methods": [ + "Get" + ] + }, + "GetAssociation": { + "methods": [ + "GetAssociation" + ] + }, + "GetIamPolicy": { + "methods": [ + "GetIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "GetRule" + ] + }, + "Insert": { + "methods": [ + "Insert" + ] + }, + "List": { + "methods": [ + "List" + ] + }, + "Patch": { + "methods": [ + "Patch" + ] + }, + "PatchRule": { + "methods": [ + "PatchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "RemoveAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "RemoveRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "SetIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "TestIamPermissions" + ] + } + } + } + } + }, "Networks": { "clients": { "rest": { @@ -2464,6 +2587,100 @@ } } }, + "RegionNetworkFirewallPolicies": { + "clients": { + "rest": { + "libraryClient": "RegionNetworkFirewallPoliciesClient", + "rpcs": { + "AddAssociation": { + "methods": [ + "AddAssociation" + ] + }, + "AddRule": { + "methods": [ + "AddRule" + ] + }, + "CloneRules": { + "methods": [ + "CloneRules" + ] + }, + "Delete": { + "methods": [ + "Delete" + ] + }, + "Get": { + "methods": [ + "Get" + ] + }, + "GetAssociation": { + "methods": [ + "GetAssociation" + ] + }, + "GetEffectiveFirewalls": { + "methods": [ + "GetEffectiveFirewalls" + ] + }, + "GetIamPolicy": { + "methods": [ + "GetIamPolicy" + ] + }, + "GetRule": { + "methods": [ + "GetRule" + ] + }, + "Insert": { + "methods": [ + "Insert" + ] + }, + "List": { + "methods": [ + "List" + ] + }, + "Patch": { + "methods": [ + "Patch" + ] + }, + "PatchRule": { + "methods": [ + "PatchRule" + ] + }, + "RemoveAssociation": { + "methods": [ + "RemoveAssociation" + ] + }, + "RemoveRule": { + "methods": [ + "RemoveRule" + ] + }, + "SetIamPolicy": { + "methods": [ + "SetIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "TestIamPermissions" + ] + } + } + } + } + }, "RegionNotificationEndpoints": { "clients": { "rest": { @@ -2522,6 +2739,40 @@ } } }, + "RegionSecurityPolicies": { + "clients": { + "rest": { + "libraryClient": "RegionSecurityPoliciesClient", + "rpcs": { + "Delete": { + "methods": [ + "Delete" + ] + }, + "Get": { + "methods": [ + "Get" + ] + }, + "Insert": { + "methods": [ + "Insert" + ] + }, + "List": { + "methods": [ + "List" + ] + }, + "Patch": { + "methods": [ + "Patch" + ] + } + } + } + } + }, "RegionSslCertificates": { "clients": { "rest": { @@ -2610,6 +2861,11 @@ "List" ] }, + "Patch": { + "methods": [ + "Patch" + ] + }, "SetSslCertificates": { "methods": [ "SetSslCertificates" @@ -2893,6 +3149,11 @@ "AddRule" ] }, + "AggregatedList": { + "methods": [ + "AggregatedList" + ] + }, "Delete": { "methods": [ "Delete" diff --git a/compute/apiv1/instances_client.go b/compute/apiv1/instances_client.go index 84597bb929d..15cc0500f38 100644 --- a/compute/apiv1/instances_client.go +++ b/compute/apiv1/instances_client.go @@ -271,7 +271,7 @@ func (c *InstancesClient) RemoveResourcePolicies(ctx context.Context, req *compu return c.internalClient.RemoveResourcePolicies(ctx, req, opts...) } -// Reset performs a reset on the instance. This is a hard reset the VM does not do a graceful shutdown. For more information, see Resetting an instance. +// Reset performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance. func (c *InstancesClient) Reset(ctx context.Context, req *computepb.ResetInstanceRequest, opts ...gax.CallOption) (*Operation, error) { return c.internalClient.Reset(ctx, req, opts...) } @@ -1687,7 +1687,7 @@ func (c *instancesRESTClient) RemoveResourcePolicies(ctx context.Context, req *c return op, nil } -// Reset performs a reset on the instance. This is a hard reset the VM does not do a graceful shutdown. For more information, see Resetting an instance. +// Reset performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance. func (c *instancesRESTClient) Reset(ctx context.Context, req *computepb.ResetInstanceRequest, opts ...gax.CallOption) (*Operation, error) { baseUrl, _ := url.Parse(c.endpoint) baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instances/%v/reset", req.GetProject(), req.GetZone(), req.GetInstance()) diff --git a/compute/apiv1/network_edge_security_services_client.go b/compute/apiv1/network_edge_security_services_client.go new file mode 100644 index 00000000000..ed3577584a7 --- /dev/null +++ b/compute/apiv1/network_edge_security_services_client.go @@ -0,0 +1,599 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute + +import ( + "bytes" + "context" + "fmt" + "io/ioutil" + "math" + "net/http" + "net/url" + "sort" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/googleapi" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + httptransport "google.golang.org/api/transport/http" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" +) + +var newNetworkEdgeSecurityServicesClientHook clientHook + +// NetworkEdgeSecurityServicesCallOptions contains the retry settings for each method of NetworkEdgeSecurityServicesClient. +type NetworkEdgeSecurityServicesCallOptions struct { + AggregatedList []gax.CallOption + Delete []gax.CallOption + Get []gax.CallOption + Insert []gax.CallOption + Patch []gax.CallOption +} + +// internalNetworkEdgeSecurityServicesClient is an interface that defines the methods availaible from Google Compute Engine API. +type internalNetworkEdgeSecurityServicesClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + AggregatedList(context.Context, *computepb.AggregatedListNetworkEdgeSecurityServicesRequest, ...gax.CallOption) *NetworkEdgeSecurityServicesScopedListPairIterator + Delete(context.Context, *computepb.DeleteNetworkEdgeSecurityServiceRequest, ...gax.CallOption) (*Operation, error) + Get(context.Context, *computepb.GetNetworkEdgeSecurityServiceRequest, ...gax.CallOption) (*computepb.NetworkEdgeSecurityService, error) + Insert(context.Context, *computepb.InsertNetworkEdgeSecurityServiceRequest, ...gax.CallOption) (*Operation, error) + Patch(context.Context, *computepb.PatchNetworkEdgeSecurityServiceRequest, ...gax.CallOption) (*Operation, error) +} + +// NetworkEdgeSecurityServicesClient is a client for interacting with Google Compute Engine API. +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +// +// The NetworkEdgeSecurityServices API. +type NetworkEdgeSecurityServicesClient struct { + // The internal transport-dependent client. + internalClient internalNetworkEdgeSecurityServicesClient + + // The call options for this service. + CallOptions *NetworkEdgeSecurityServicesCallOptions +} + +// Wrapper methods routed to the internal client. + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *NetworkEdgeSecurityServicesClient) Close() error { + return c.internalClient.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 *NetworkEdgeSecurityServicesClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *NetworkEdgeSecurityServicesClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// AggregatedList retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. +func (c *NetworkEdgeSecurityServicesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListNetworkEdgeSecurityServicesRequest, opts ...gax.CallOption) *NetworkEdgeSecurityServicesScopedListPairIterator { + return c.internalClient.AggregatedList(ctx, req, opts...) +} + +// Delete deletes the specified service. +func (c *NetworkEdgeSecurityServicesClient) Delete(ctx context.Context, req *computepb.DeleteNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Delete(ctx, req, opts...) +} + +// Get gets a specified NetworkEdgeSecurityService. +func (c *NetworkEdgeSecurityServicesClient) Get(ctx context.Context, req *computepb.GetNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*computepb.NetworkEdgeSecurityService, error) { + return c.internalClient.Get(ctx, req, opts...) +} + +// Insert creates a new service in the specified project using the data included in the request. +func (c *NetworkEdgeSecurityServicesClient) Insert(ctx context.Context, req *computepb.InsertNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Insert(ctx, req, opts...) +} + +// Patch patches the specified policy with the data included in the request. +func (c *NetworkEdgeSecurityServicesClient) Patch(ctx context.Context, req *computepb.PatchNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Patch(ctx, req, opts...) +} + +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type networkEdgeSecurityServicesRESTClient struct { + // The http endpoint to connect to. + endpoint string + + // The http client. + httpClient *http.Client + + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewNetworkEdgeSecurityServicesRESTClient creates a new network edge security services rest client. +// +// The NetworkEdgeSecurityServices API. +func NewNetworkEdgeSecurityServicesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkEdgeSecurityServicesClient, error) { + clientOpts := append(defaultNetworkEdgeSecurityServicesRESTClientOptions(), opts...) + httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) + if err != nil { + return nil, err + } + + c := &networkEdgeSecurityServicesRESTClient{ + endpoint: endpoint, + httpClient: httpClient, + } + c.setGoogleClientInfo() + + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + + return &NetworkEdgeSecurityServicesClient{internalClient: c, CallOptions: &NetworkEdgeSecurityServicesCallOptions{}}, nil +} + +func defaultNetworkEdgeSecurityServicesRESTClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("https://compute.googleapis.com"), + internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"), + internaloption.WithDefaultAudience("https://compute.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + } +} + +// 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 *networkEdgeSecurityServicesRESTClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN") + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *networkEdgeSecurityServicesRESTClient) Close() error { + // Replace httpClient with nil to force cleanup. + c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } + return nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *networkEdgeSecurityServicesRESTClient) Connection() *grpc.ClientConn { + return nil +} + +// AggregatedList retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. +func (c *networkEdgeSecurityServicesRESTClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListNetworkEdgeSecurityServicesRequest, opts ...gax.CallOption) *NetworkEdgeSecurityServicesScopedListPairIterator { + it := &NetworkEdgeSecurityServicesScopedListPairIterator{} + req = proto.Clone(req).(*computepb.AggregatedListNetworkEdgeSecurityServicesRequest) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + it.InternalFetch = func(pageSize int, pageToken string) ([]NetworkEdgeSecurityServicesScopedListPair, string, error) { + resp := &computepb.NetworkEdgeSecurityServiceAggregatedList{} + if pageToken != "" { + req.PageToken = proto.String(pageToken) + } + if pageSize > math.MaxInt32 { + req.MaxResults = proto.Uint32(math.MaxInt32) + } else if pageSize != 0 { + req.MaxResults = proto.Uint32(uint32(pageSize)) + } + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/aggregated/networkEdgeSecurityServices", req.GetProject()) + + params := url.Values{} + if req != nil && req.Filter != nil { + params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) + } + if req != nil && req.IncludeAllScopes != nil { + params.Add("includeAllScopes", fmt.Sprintf("%v", req.GetIncludeAllScopes())) + } + if req != nil && req.MaxResults != nil { + params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults())) + } + if req != nil && req.OrderBy != nil { + params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) + } + if req != nil && req.PageToken != nil { + params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) + } + if req != nil && req.ReturnPartialSuccess != nil { + params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, "", e + } + it.Response = resp + + elems := make([]NetworkEdgeSecurityServicesScopedListPair, 0, len(resp.GetItems())) + for k, v := range resp.GetItems() { + elems = append(elems, NetworkEdgeSecurityServicesScopedListPair{k, v}) + } + sort.Slice(elems, func(i, j int) bool { return elems[i].Key < elems[j].Key }) + + return elems, 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.GetMaxResults()) + it.pageInfo.Token = req.GetPageToken() + + return it +} + +// Delete deletes the specified service. +func (c *networkEdgeSecurityServicesRESTClient) Delete(ctx context.Context, req *computepb.DeleteNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/networkEdgeSecurityServices/%v", req.GetProject(), req.GetRegion(), req.GetNetworkEdgeSecurityService()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// Get gets a specified NetworkEdgeSecurityService. +func (c *networkEdgeSecurityServicesRESTClient) Get(ctx context.Context, req *computepb.GetNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*computepb.NetworkEdgeSecurityService, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/networkEdgeSecurityServices/%v", req.GetProject(), req.GetRegion(), req.GetNetworkEdgeSecurityService()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.NetworkEdgeSecurityService{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// Insert creates a new service in the specified project using the data included in the request. +func (c *networkEdgeSecurityServicesRESTClient) Insert(ctx context.Context, req *computepb.InsertNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetNetworkEdgeSecurityServiceResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/networkEdgeSecurityServices", req.GetProject(), req.GetRegion()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + if req != nil && req.ValidateOnly != nil { + params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// Patch patches the specified policy with the data included in the request. +func (c *networkEdgeSecurityServicesRESTClient) Patch(ctx context.Context, req *computepb.PatchNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetNetworkEdgeSecurityServiceResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/networkEdgeSecurityServices/%v", req.GetProject(), req.GetRegion(), req.GetNetworkEdgeSecurityService()) + + params := url.Values{} + if req != nil && req.Paths != nil { + params.Add("paths", fmt.Sprintf("%v", req.GetPaths())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + if req != nil && req.UpdateMask != nil { + params.Add("updateMask", fmt.Sprintf("%v", req.GetUpdateMask())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// NetworkEdgeSecurityServicesScopedListPair is a holder type for string/*computepb.NetworkEdgeSecurityServicesScopedList map entries +type NetworkEdgeSecurityServicesScopedListPair struct { + Key string + Value *computepb.NetworkEdgeSecurityServicesScopedList +} + +// NetworkEdgeSecurityServicesScopedListPairIterator manages a stream of NetworkEdgeSecurityServicesScopedListPair. +type NetworkEdgeSecurityServicesScopedListPairIterator struct { + items []NetworkEdgeSecurityServicesScopedListPair + 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 []NetworkEdgeSecurityServicesScopedListPair, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *NetworkEdgeSecurityServicesScopedListPairIterator) 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 *NetworkEdgeSecurityServicesScopedListPairIterator) Next() (NetworkEdgeSecurityServicesScopedListPair, error) { + var item NetworkEdgeSecurityServicesScopedListPair + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *NetworkEdgeSecurityServicesScopedListPairIterator) bufLen() int { + return len(it.items) +} + +func (it *NetworkEdgeSecurityServicesScopedListPairIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/compute/apiv1/network_edge_security_services_client_example_test.go b/compute/apiv1/network_edge_security_services_client_example_test.go new file mode 100644 index 00000000000..018bf3c85a5 --- /dev/null +++ b/compute/apiv1/network_edge_security_services_client_example_test.go @@ -0,0 +1,152 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute_test + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func ExampleNewNetworkEdgeSecurityServicesRESTClient() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleNetworkEdgeSecurityServicesClient_AggregatedList() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AggregatedListNetworkEdgeSecurityServicesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AggregatedListNetworkEdgeSecurityServicesRequest. + } + it := c.AggregatedList(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleNetworkEdgeSecurityServicesClient_Delete() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNetworkEdgeSecurityServiceRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkEdgeSecurityServicesClient_Get() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetNetworkEdgeSecurityServiceRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleNetworkEdgeSecurityServicesClient_Insert() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNetworkEdgeSecurityServiceRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkEdgeSecurityServicesClient_Patch() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchNetworkEdgeSecurityServiceRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} diff --git a/compute/apiv1/network_firewall_policies_client.go b/compute/apiv1/network_firewall_policies_client.go new file mode 100644 index 00000000000..94de6acc2fc --- /dev/null +++ b/compute/apiv1/network_firewall_policies_client.go @@ -0,0 +1,1245 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute + +import ( + "bytes" + "context" + "fmt" + "io/ioutil" + "math" + "net/http" + "net/url" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/googleapi" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + httptransport "google.golang.org/api/transport/http" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" +) + +var newNetworkFirewallPoliciesClientHook clientHook + +// NetworkFirewallPoliciesCallOptions contains the retry settings for each method of NetworkFirewallPoliciesClient. +type NetworkFirewallPoliciesCallOptions struct { + AddAssociation []gax.CallOption + AddRule []gax.CallOption + CloneRules []gax.CallOption + Delete []gax.CallOption + Get []gax.CallOption + GetAssociation []gax.CallOption + GetIamPolicy []gax.CallOption + GetRule []gax.CallOption + Insert []gax.CallOption + List []gax.CallOption + Patch []gax.CallOption + PatchRule []gax.CallOption + RemoveAssociation []gax.CallOption + RemoveRule []gax.CallOption + SetIamPolicy []gax.CallOption + TestIamPermissions []gax.CallOption +} + +// internalNetworkFirewallPoliciesClient is an interface that defines the methods availaible from Google Compute Engine API. +type internalNetworkFirewallPoliciesClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + AddAssociation(context.Context, *computepb.AddAssociationNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + AddRule(context.Context, *computepb.AddRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + CloneRules(context.Context, *computepb.CloneRulesNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + Delete(context.Context, *computepb.DeleteNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + Get(context.Context, *computepb.GetNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicy, error) + GetAssociation(context.Context, *computepb.GetAssociationNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) + GetIamPolicy(context.Context, *computepb.GetIamPolicyNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error) + GetRule(context.Context, *computepb.GetRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyRule, error) + Insert(context.Context, *computepb.InsertNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + List(context.Context, *computepb.ListNetworkFirewallPoliciesRequest, ...gax.CallOption) *FirewallPolicyIterator + Patch(context.Context, *computepb.PatchNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + PatchRule(context.Context, *computepb.PatchRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + RemoveAssociation(context.Context, *computepb.RemoveAssociationNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + RemoveRule(context.Context, *computepb.RemoveRuleNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + SetIamPolicy(context.Context, *computepb.SetIamPolicyNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error) + TestIamPermissions(context.Context, *computepb.TestIamPermissionsNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error) +} + +// NetworkFirewallPoliciesClient is a client for interacting with Google Compute Engine API. +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +// +// The NetworkFirewallPolicies API. +type NetworkFirewallPoliciesClient struct { + // The internal transport-dependent client. + internalClient internalNetworkFirewallPoliciesClient + + // The call options for this service. + CallOptions *NetworkFirewallPoliciesCallOptions +} + +// Wrapper methods routed to the internal client. + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *NetworkFirewallPoliciesClient) Close() error { + return c.internalClient.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 *NetworkFirewallPoliciesClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *NetworkFirewallPoliciesClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// AddAssociation inserts an association for the specified firewall policy. +func (c *NetworkFirewallPoliciesClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.AddAssociation(ctx, req, opts...) +} + +// AddRule inserts a rule into a firewall policy. +func (c *NetworkFirewallPoliciesClient) AddRule(ctx context.Context, req *computepb.AddRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.AddRule(ctx, req, opts...) +} + +// CloneRules copies rules to the specified firewall policy. +func (c *NetworkFirewallPoliciesClient) CloneRules(ctx context.Context, req *computepb.CloneRulesNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.CloneRules(ctx, req, opts...) +} + +// Delete deletes the specified policy. +func (c *NetworkFirewallPoliciesClient) Delete(ctx context.Context, req *computepb.DeleteNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Delete(ctx, req, opts...) +} + +// Get returns the specified network firewall policy. +func (c *NetworkFirewallPoliciesClient) Get(ctx context.Context, req *computepb.GetNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error) { + return c.internalClient.Get(ctx, req, opts...) +} + +// GetAssociation gets an association with the specified name. +func (c *NetworkFirewallPoliciesClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) { + return c.internalClient.GetAssociation(ctx, req, opts...) +} + +// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists. +func (c *NetworkFirewallPoliciesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + return c.internalClient.GetIamPolicy(ctx, req, opts...) +} + +// GetRule gets a rule of the specified priority. +func (c *NetworkFirewallPoliciesClient) GetRule(ctx context.Context, req *computepb.GetRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) { + return c.internalClient.GetRule(ctx, req, opts...) +} + +// Insert creates a new policy in the specified project using the data included in the request. +func (c *NetworkFirewallPoliciesClient) Insert(ctx context.Context, req *computepb.InsertNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Insert(ctx, req, opts...) +} + +// List lists all the policies that have been configured for the specified project. +func (c *NetworkFirewallPoliciesClient) List(ctx context.Context, req *computepb.ListNetworkFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator { + return c.internalClient.List(ctx, req, opts...) +} + +// Patch patches the specified policy with the data included in the request. +func (c *NetworkFirewallPoliciesClient) Patch(ctx context.Context, req *computepb.PatchNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Patch(ctx, req, opts...) +} + +// PatchRule patches a rule of the specified priority. +func (c *NetworkFirewallPoliciesClient) PatchRule(ctx context.Context, req *computepb.PatchRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.PatchRule(ctx, req, opts...) +} + +// RemoveAssociation removes an association for the specified firewall policy. +func (c *NetworkFirewallPoliciesClient) RemoveAssociation(ctx context.Context, req *computepb.RemoveAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.RemoveAssociation(ctx, req, opts...) +} + +// RemoveRule deletes a rule of the specified priority. +func (c *NetworkFirewallPoliciesClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.RemoveRule(ctx, req, opts...) +} + +// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy. +func (c *NetworkFirewallPoliciesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + return c.internalClient.SetIamPolicy(ctx, req, opts...) +} + +// TestIamPermissions returns permissions that a caller has on the specified resource. +func (c *NetworkFirewallPoliciesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) { + return c.internalClient.TestIamPermissions(ctx, req, opts...) +} + +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type networkFirewallPoliciesRESTClient struct { + // The http endpoint to connect to. + endpoint string + + // The http client. + httpClient *http.Client + + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewNetworkFirewallPoliciesRESTClient creates a new network firewall policies rest client. +// +// The NetworkFirewallPolicies API. +func NewNetworkFirewallPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkFirewallPoliciesClient, error) { + clientOpts := append(defaultNetworkFirewallPoliciesRESTClientOptions(), opts...) + httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) + if err != nil { + return nil, err + } + + c := &networkFirewallPoliciesRESTClient{ + endpoint: endpoint, + httpClient: httpClient, + } + c.setGoogleClientInfo() + + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + + return &NetworkFirewallPoliciesClient{internalClient: c, CallOptions: &NetworkFirewallPoliciesCallOptions{}}, nil +} + +func defaultNetworkFirewallPoliciesRESTClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("https://compute.googleapis.com"), + internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"), + internaloption.WithDefaultAudience("https://compute.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + } +} + +// 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 *networkFirewallPoliciesRESTClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN") + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *networkFirewallPoliciesRESTClient) Close() error { + // Replace httpClient with nil to force cleanup. + c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } + return nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *networkFirewallPoliciesRESTClient) Connection() *grpc.ClientConn { + return nil +} + +// AddAssociation inserts an association for the specified firewall policy. +func (c *networkFirewallPoliciesRESTClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyAssociationResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/addAssociation", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.ReplaceExistingAssociation != nil { + params.Add("replaceExistingAssociation", fmt.Sprintf("%v", req.GetReplaceExistingAssociation())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// AddRule inserts a rule into a firewall policy. +func (c *networkFirewallPoliciesRESTClient) AddRule(ctx context.Context, req *computepb.AddRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyRuleResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/addRule", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.MaxPriority != nil { + params.Add("maxPriority", fmt.Sprintf("%v", req.GetMaxPriority())) + } + if req != nil && req.MinPriority != nil { + params.Add("minPriority", fmt.Sprintf("%v", req.GetMinPriority())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// CloneRules copies rules to the specified firewall policy. +func (c *networkFirewallPoliciesRESTClient) CloneRules(ctx context.Context, req *computepb.CloneRulesNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/cloneRules", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + if req != nil && req.SourceFirewallPolicy != nil { + params.Add("sourceFirewallPolicy", fmt.Sprintf("%v", req.GetSourceFirewallPolicy())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// Delete deletes the specified policy. +func (c *networkFirewallPoliciesRESTClient) Delete(ctx context.Context, req *computepb.DeleteNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// Get returns the specified network firewall policy. +func (c *networkFirewallPoliciesRESTClient) Get(ctx context.Context, req *computepb.GetNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v", req.GetProject(), req.GetFirewallPolicy()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.FirewallPolicy{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// GetAssociation gets an association with the specified name. +func (c *networkFirewallPoliciesRESTClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/getAssociation", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Name != nil { + params.Add("name", fmt.Sprintf("%v", req.GetName())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.FirewallPolicyAssociation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists. +func (c *networkFirewallPoliciesRESTClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/getIamPolicy", req.GetProject(), req.GetResource()) + + params := url.Values{} + if req != nil && req.OptionsRequestedPolicyVersion != nil { + params.Add("optionsRequestedPolicyVersion", fmt.Sprintf("%v", req.GetOptionsRequestedPolicyVersion())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Policy{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// GetRule gets a rule of the specified priority. +func (c *networkFirewallPoliciesRESTClient) GetRule(ctx context.Context, req *computepb.GetRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/getRule", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Priority != nil { + params.Add("priority", fmt.Sprintf("%v", req.GetPriority())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.FirewallPolicyRule{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// Insert creates a new policy in the specified project using the data included in the request. +func (c *networkFirewallPoliciesRESTClient) Insert(ctx context.Context, req *computepb.InsertNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies", req.GetProject()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// List lists all the policies that have been configured for the specified project. +func (c *networkFirewallPoliciesRESTClient) List(ctx context.Context, req *computepb.ListNetworkFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator { + it := &FirewallPolicyIterator{} + req = proto.Clone(req).(*computepb.ListNetworkFirewallPoliciesRequest) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.FirewallPolicy, string, error) { + resp := &computepb.FirewallPolicyList{} + if pageToken != "" { + req.PageToken = proto.String(pageToken) + } + if pageSize > math.MaxInt32 { + req.MaxResults = proto.Uint32(math.MaxInt32) + } else if pageSize != 0 { + req.MaxResults = proto.Uint32(uint32(pageSize)) + } + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies", req.GetProject()) + + params := url.Values{} + if req != nil && req.Filter != nil { + params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) + } + if req != nil && req.MaxResults != nil { + params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults())) + } + if req != nil && req.OrderBy != nil { + params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) + } + if req != nil && req.PageToken != nil { + params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) + } + if req != nil && req.ReturnPartialSuccess != nil { + params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, "", e + } + it.Response = resp + return resp.GetItems(), 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.GetMaxResults()) + it.pageInfo.Token = req.GetPageToken() + + return it +} + +// Patch patches the specified policy with the data included in the request. +func (c *networkFirewallPoliciesRESTClient) Patch(ctx context.Context, req *computepb.PatchNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// PatchRule patches a rule of the specified priority. +func (c *networkFirewallPoliciesRESTClient) PatchRule(ctx context.Context, req *computepb.PatchRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyRuleResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/patchRule", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Priority != nil { + params.Add("priority", fmt.Sprintf("%v", req.GetPriority())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// RemoveAssociation removes an association for the specified firewall policy. +func (c *networkFirewallPoliciesRESTClient) RemoveAssociation(ctx context.Context, req *computepb.RemoveAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/removeAssociation", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Name != nil { + params.Add("name", fmt.Sprintf("%v", req.GetName())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// RemoveRule deletes a rule of the specified priority. +func (c *networkFirewallPoliciesRESTClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/removeRule", req.GetProject(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Priority != nil { + params.Add("priority", fmt.Sprintf("%v", req.GetPriority())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } + return op, nil +} + +// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy. +func (c *networkFirewallPoliciesRESTClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetGlobalSetPolicyRequestResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/setIamPolicy", req.GetProject(), req.GetResource()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Policy{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// TestIamPermissions returns permissions that a caller has on the specified resource. +func (c *networkFirewallPoliciesRESTClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetTestPermissionsRequestResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/firewallPolicies/%v/testIamPermissions", req.GetProject(), req.GetResource()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.TestPermissionsResponse{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} diff --git a/compute/apiv1/network_firewall_policies_client_example_test.go b/compute/apiv1/network_firewall_policies_client_example_test.go new file mode 100644 index 00000000000..4a484816657 --- /dev/null +++ b/compute/apiv1/network_firewall_policies_client_example_test.go @@ -0,0 +1,390 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute_test + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func ExampleNewNetworkFirewallPoliciesRESTClient() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleNetworkFirewallPoliciesClient_AddAssociation() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddAssociationNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddAssociationNetworkFirewallPolicyRequest. + } + op, err := c.AddAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_AddRule() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddRuleNetworkFirewallPolicyRequest. + } + op, err := c.AddRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_CloneRules() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.CloneRulesNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CloneRulesNetworkFirewallPolicyRequest. + } + op, err := c.CloneRules(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_Delete() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNetworkFirewallPolicyRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_Get() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetNetworkFirewallPolicyRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleNetworkFirewallPoliciesClient_GetAssociation() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetAssociationNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetAssociationNetworkFirewallPolicyRequest. + } + resp, err := c.GetAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleNetworkFirewallPoliciesClient_GetIamPolicy() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetIamPolicyNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetIamPolicyNetworkFirewallPolicyRequest. + } + resp, err := c.GetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleNetworkFirewallPoliciesClient_GetRule() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRuleNetworkFirewallPolicyRequest. + } + resp, err := c.GetRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleNetworkFirewallPoliciesClient_Insert() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNetworkFirewallPolicyRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_List() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.ListNetworkFirewallPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListNetworkFirewallPoliciesRequest. + } + it := c.List(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleNetworkFirewallPoliciesClient_Patch() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchNetworkFirewallPolicyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_PatchRule() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRuleNetworkFirewallPolicyRequest. + } + op, err := c.PatchRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_RemoveAssociation() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveAssociationNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveAssociationNetworkFirewallPolicyRequest. + } + op, err := c.RemoveAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_RemoveRule() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveRuleNetworkFirewallPolicyRequest. + } + op, err := c.RemoveRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleNetworkFirewallPoliciesClient_SetIamPolicy() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.SetIamPolicyNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetIamPolicyNetworkFirewallPolicyRequest. + } + resp, err := c.SetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleNetworkFirewallPoliciesClient_TestIamPermissions() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.TestIamPermissionsNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#TestIamPermissionsNetworkFirewallPolicyRequest. + } + resp, err := c.TestIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/compute/apiv1/region_network_firewall_policies_client.go b/compute/apiv1/region_network_firewall_policies_client.go new file mode 100644 index 00000000000..91a3beb9026 --- /dev/null +++ b/compute/apiv1/region_network_firewall_policies_client.go @@ -0,0 +1,1310 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute + +import ( + "bytes" + "context" + "fmt" + "io/ioutil" + "math" + "net/http" + "net/url" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/googleapi" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + httptransport "google.golang.org/api/transport/http" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" +) + +var newRegionNetworkFirewallPoliciesClientHook clientHook + +// RegionNetworkFirewallPoliciesCallOptions contains the retry settings for each method of RegionNetworkFirewallPoliciesClient. +type RegionNetworkFirewallPoliciesCallOptions struct { + AddAssociation []gax.CallOption + AddRule []gax.CallOption + CloneRules []gax.CallOption + Delete []gax.CallOption + Get []gax.CallOption + GetAssociation []gax.CallOption + GetEffectiveFirewalls []gax.CallOption + GetIamPolicy []gax.CallOption + GetRule []gax.CallOption + Insert []gax.CallOption + List []gax.CallOption + Patch []gax.CallOption + PatchRule []gax.CallOption + RemoveAssociation []gax.CallOption + RemoveRule []gax.CallOption + SetIamPolicy []gax.CallOption + TestIamPermissions []gax.CallOption +} + +// internalRegionNetworkFirewallPoliciesClient is an interface that defines the methods availaible from Google Compute Engine API. +type internalRegionNetworkFirewallPoliciesClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + AddAssociation(context.Context, *computepb.AddAssociationRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + AddRule(context.Context, *computepb.AddRuleRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + CloneRules(context.Context, *computepb.CloneRulesRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + Delete(context.Context, *computepb.DeleteRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + Get(context.Context, *computepb.GetRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicy, error) + GetAssociation(context.Context, *computepb.GetAssociationRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) + GetEffectiveFirewalls(context.Context, *computepb.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, error) + GetIamPolicy(context.Context, *computepb.GetIamPolicyRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error) + GetRule(context.Context, *computepb.GetRuleRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyRule, error) + Insert(context.Context, *computepb.InsertRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + List(context.Context, *computepb.ListRegionNetworkFirewallPoliciesRequest, ...gax.CallOption) *FirewallPolicyIterator + Patch(context.Context, *computepb.PatchRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + PatchRule(context.Context, *computepb.PatchRuleRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + RemoveAssociation(context.Context, *computepb.RemoveAssociationRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + RemoveRule(context.Context, *computepb.RemoveRuleRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*Operation, error) + SetIamPolicy(context.Context, *computepb.SetIamPolicyRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error) + TestIamPermissions(context.Context, *computepb.TestIamPermissionsRegionNetworkFirewallPolicyRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error) +} + +// RegionNetworkFirewallPoliciesClient is a client for interacting with Google Compute Engine API. +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +// +// The RegionNetworkFirewallPolicies API. +type RegionNetworkFirewallPoliciesClient struct { + // The internal transport-dependent client. + internalClient internalRegionNetworkFirewallPoliciesClient + + // The call options for this service. + CallOptions *RegionNetworkFirewallPoliciesCallOptions +} + +// Wrapper methods routed to the internal client. + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *RegionNetworkFirewallPoliciesClient) Close() error { + return c.internalClient.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 *RegionNetworkFirewallPoliciesClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *RegionNetworkFirewallPoliciesClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// AddAssociation inserts an association for the specified network firewall policy. +func (c *RegionNetworkFirewallPoliciesClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.AddAssociation(ctx, req, opts...) +} + +// AddRule inserts a rule into a network firewall policy. +func (c *RegionNetworkFirewallPoliciesClient) AddRule(ctx context.Context, req *computepb.AddRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.AddRule(ctx, req, opts...) +} + +// CloneRules copies rules to the specified network firewall policy. +func (c *RegionNetworkFirewallPoliciesClient) CloneRules(ctx context.Context, req *computepb.CloneRulesRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.CloneRules(ctx, req, opts...) +} + +// Delete deletes the specified network firewall policy. +func (c *RegionNetworkFirewallPoliciesClient) Delete(ctx context.Context, req *computepb.DeleteRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Delete(ctx, req, opts...) +} + +// Get returns the specified network firewall policy. +func (c *RegionNetworkFirewallPoliciesClient) Get(ctx context.Context, req *computepb.GetRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error) { + return c.internalClient.Get(ctx, req, opts...) +} + +// GetAssociation gets an association with the specified name. +func (c *RegionNetworkFirewallPoliciesClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) { + return c.internalClient.GetAssociation(ctx, req, opts...) +} + +// GetEffectiveFirewalls returns the effective firewalls on a given network. +func (c *RegionNetworkFirewallPoliciesClient) GetEffectiveFirewalls(ctx context.Context, req *computepb.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, error) { + return c.internalClient.GetEffectiveFirewalls(ctx, req, opts...) +} + +// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists. +func (c *RegionNetworkFirewallPoliciesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + return c.internalClient.GetIamPolicy(ctx, req, opts...) +} + +// GetRule gets a rule of the specified priority. +func (c *RegionNetworkFirewallPoliciesClient) GetRule(ctx context.Context, req *computepb.GetRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) { + return c.internalClient.GetRule(ctx, req, opts...) +} + +// Insert creates a new network firewall policy in the specified project and region. +func (c *RegionNetworkFirewallPoliciesClient) Insert(ctx context.Context, req *computepb.InsertRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Insert(ctx, req, opts...) +} + +// List lists all the network firewall policies that have been configured for the specified project in the given region. +func (c *RegionNetworkFirewallPoliciesClient) List(ctx context.Context, req *computepb.ListRegionNetworkFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator { + return c.internalClient.List(ctx, req, opts...) +} + +// Patch patches the specified network firewall policy. +func (c *RegionNetworkFirewallPoliciesClient) Patch(ctx context.Context, req *computepb.PatchRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Patch(ctx, req, opts...) +} + +// PatchRule patches a rule of the specified priority. +func (c *RegionNetworkFirewallPoliciesClient) PatchRule(ctx context.Context, req *computepb.PatchRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.PatchRule(ctx, req, opts...) +} + +// RemoveAssociation removes an association for the specified network firewall policy. +func (c *RegionNetworkFirewallPoliciesClient) RemoveAssociation(ctx context.Context, req *computepb.RemoveAssociationRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.RemoveAssociation(ctx, req, opts...) +} + +// RemoveRule deletes a rule of the specified priority. +func (c *RegionNetworkFirewallPoliciesClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.RemoveRule(ctx, req, opts...) +} + +// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy. +func (c *RegionNetworkFirewallPoliciesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + return c.internalClient.SetIamPolicy(ctx, req, opts...) +} + +// TestIamPermissions returns permissions that a caller has on the specified resource. +func (c *RegionNetworkFirewallPoliciesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) { + return c.internalClient.TestIamPermissions(ctx, req, opts...) +} + +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type regionNetworkFirewallPoliciesRESTClient struct { + // The http endpoint to connect to. + endpoint string + + // The http client. + httpClient *http.Client + + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewRegionNetworkFirewallPoliciesRESTClient creates a new region network firewall policies rest client. +// +// The RegionNetworkFirewallPolicies API. +func NewRegionNetworkFirewallPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*RegionNetworkFirewallPoliciesClient, error) { + clientOpts := append(defaultRegionNetworkFirewallPoliciesRESTClientOptions(), opts...) + httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) + if err != nil { + return nil, err + } + + c := ®ionNetworkFirewallPoliciesRESTClient{ + endpoint: endpoint, + httpClient: httpClient, + } + c.setGoogleClientInfo() + + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + + return &RegionNetworkFirewallPoliciesClient{internalClient: c, CallOptions: &RegionNetworkFirewallPoliciesCallOptions{}}, nil +} + +func defaultRegionNetworkFirewallPoliciesRESTClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("https://compute.googleapis.com"), + internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"), + internaloption.WithDefaultAudience("https://compute.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + } +} + +// 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 *regionNetworkFirewallPoliciesRESTClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN") + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *regionNetworkFirewallPoliciesRESTClient) Close() error { + // Replace httpClient with nil to force cleanup. + c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } + return nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *regionNetworkFirewallPoliciesRESTClient) Connection() *grpc.ClientConn { + return nil +} + +// AddAssociation inserts an association for the specified network firewall policy. +func (c *regionNetworkFirewallPoliciesRESTClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyAssociationResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/addAssociation", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.ReplaceExistingAssociation != nil { + params.Add("replaceExistingAssociation", fmt.Sprintf("%v", req.GetReplaceExistingAssociation())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// AddRule inserts a rule into a network firewall policy. +func (c *regionNetworkFirewallPoliciesRESTClient) AddRule(ctx context.Context, req *computepb.AddRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyRuleResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/addRule", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.MaxPriority != nil { + params.Add("maxPriority", fmt.Sprintf("%v", req.GetMaxPriority())) + } + if req != nil && req.MinPriority != nil { + params.Add("minPriority", fmt.Sprintf("%v", req.GetMinPriority())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// CloneRules copies rules to the specified network firewall policy. +func (c *regionNetworkFirewallPoliciesRESTClient) CloneRules(ctx context.Context, req *computepb.CloneRulesRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/cloneRules", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + if req != nil && req.SourceFirewallPolicy != nil { + params.Add("sourceFirewallPolicy", fmt.Sprintf("%v", req.GetSourceFirewallPolicy())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// Delete deletes the specified network firewall policy. +func (c *regionNetworkFirewallPoliciesRESTClient) Delete(ctx context.Context, req *computepb.DeleteRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// Get returns the specified network firewall policy. +func (c *regionNetworkFirewallPoliciesRESTClient) Get(ctx context.Context, req *computepb.GetRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.FirewallPolicy{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// GetAssociation gets an association with the specified name. +func (c *regionNetworkFirewallPoliciesRESTClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/getAssociation", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Name != nil { + params.Add("name", fmt.Sprintf("%v", req.GetName())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.FirewallPolicyAssociation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// GetEffectiveFirewalls returns the effective firewalls on a given network. +func (c *regionNetworkFirewallPoliciesRESTClient) GetEffectiveFirewalls(ctx context.Context, req *computepb.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/getEffectiveFirewalls", req.GetProject(), req.GetRegion()) + + params := url.Values{} + params.Add("network", fmt.Sprintf("%v", req.GetNetwork())) + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.RegionNetworkFirewallPoliciesGetEffectiveFirewallsResponse{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists. +func (c *regionNetworkFirewallPoliciesRESTClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/getIamPolicy", req.GetProject(), req.GetRegion(), req.GetResource()) + + params := url.Values{} + if req != nil && req.OptionsRequestedPolicyVersion != nil { + params.Add("optionsRequestedPolicyVersion", fmt.Sprintf("%v", req.GetOptionsRequestedPolicyVersion())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Policy{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// GetRule gets a rule of the specified priority. +func (c *regionNetworkFirewallPoliciesRESTClient) GetRule(ctx context.Context, req *computepb.GetRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/getRule", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Priority != nil { + params.Add("priority", fmt.Sprintf("%v", req.GetPriority())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.FirewallPolicyRule{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// Insert creates a new network firewall policy in the specified project and region. +func (c *regionNetworkFirewallPoliciesRESTClient) Insert(ctx context.Context, req *computepb.InsertRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies", req.GetProject(), req.GetRegion()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// List lists all the network firewall policies that have been configured for the specified project in the given region. +func (c *regionNetworkFirewallPoliciesRESTClient) List(ctx context.Context, req *computepb.ListRegionNetworkFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator { + it := &FirewallPolicyIterator{} + req = proto.Clone(req).(*computepb.ListRegionNetworkFirewallPoliciesRequest) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.FirewallPolicy, string, error) { + resp := &computepb.FirewallPolicyList{} + if pageToken != "" { + req.PageToken = proto.String(pageToken) + } + if pageSize > math.MaxInt32 { + req.MaxResults = proto.Uint32(math.MaxInt32) + } else if pageSize != 0 { + req.MaxResults = proto.Uint32(uint32(pageSize)) + } + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies", req.GetProject(), req.GetRegion()) + + params := url.Values{} + if req != nil && req.Filter != nil { + params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) + } + if req != nil && req.MaxResults != nil { + params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults())) + } + if req != nil && req.OrderBy != nil { + params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) + } + if req != nil && req.PageToken != nil { + params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) + } + if req != nil && req.ReturnPartialSuccess != nil { + params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, "", e + } + it.Response = resp + return resp.GetItems(), 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.GetMaxResults()) + it.pageInfo.Token = req.GetPageToken() + + return it +} + +// Patch patches the specified network firewall policy. +func (c *regionNetworkFirewallPoliciesRESTClient) Patch(ctx context.Context, req *computepb.PatchRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// PatchRule patches a rule of the specified priority. +func (c *regionNetworkFirewallPoliciesRESTClient) PatchRule(ctx context.Context, req *computepb.PatchRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetFirewallPolicyRuleResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/patchRule", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Priority != nil { + params.Add("priority", fmt.Sprintf("%v", req.GetPriority())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// RemoveAssociation removes an association for the specified network firewall policy. +func (c *regionNetworkFirewallPoliciesRESTClient) RemoveAssociation(ctx context.Context, req *computepb.RemoveAssociationRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/removeAssociation", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Name != nil { + params.Add("name", fmt.Sprintf("%v", req.GetName())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// RemoveRule deletes a rule of the specified priority. +func (c *regionNetworkFirewallPoliciesRESTClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/removeRule", req.GetProject(), req.GetRegion(), req.GetFirewallPolicy()) + + params := url.Values{} + if req != nil && req.Priority != nil { + params.Add("priority", fmt.Sprintf("%v", req.GetPriority())) + } + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy. +func (c *regionNetworkFirewallPoliciesRESTClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetRegionSetPolicyRequestResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/setIamPolicy", req.GetProject(), req.GetRegion(), req.GetResource()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Policy{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// TestIamPermissions returns permissions that a caller has on the specified resource. +func (c *regionNetworkFirewallPoliciesRESTClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsRegionNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetTestPermissionsRequestResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/firewallPolicies/%v/testIamPermissions", req.GetProject(), req.GetRegion(), req.GetResource()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.TestPermissionsResponse{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} diff --git a/compute/apiv1/region_network_firewall_policies_client_example_test.go b/compute/apiv1/region_network_firewall_policies_client_example_test.go new file mode 100644 index 00000000000..460c85a4869 --- /dev/null +++ b/compute/apiv1/region_network_firewall_policies_client_example_test.go @@ -0,0 +1,410 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute_test + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func ExampleNewRegionNetworkFirewallPoliciesRESTClient() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleRegionNetworkFirewallPoliciesClient_AddAssociation() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddAssociationRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddAssociationRegionNetworkFirewallPolicyRequest. + } + op, err := c.AddAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_AddRule() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddRuleRegionNetworkFirewallPolicyRequest. + } + op, err := c.AddRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_CloneRules() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.CloneRulesRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CloneRulesRegionNetworkFirewallPolicyRequest. + } + op, err := c.CloneRules(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_Delete() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionNetworkFirewallPolicyRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_Get() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRegionNetworkFirewallPolicyRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRegionNetworkFirewallPoliciesClient_GetAssociation() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetAssociationRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetAssociationRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRegionNetworkFirewallPoliciesClient_GetEffectiveFirewalls() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetEffectiveFirewalls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRegionNetworkFirewallPoliciesClient_GetIamPolicy() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetIamPolicyRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetIamPolicyRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRegionNetworkFirewallPoliciesClient_GetRule() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRuleRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRegionNetworkFirewallPoliciesClient_Insert() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionNetworkFirewallPolicyRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_List() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.ListRegionNetworkFirewallPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListRegionNetworkFirewallPoliciesRequest. + } + it := c.List(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_Patch() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionNetworkFirewallPolicyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_PatchRule() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRuleRegionNetworkFirewallPolicyRequest. + } + op, err := c.PatchRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_RemoveAssociation() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveAssociationRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveAssociationRegionNetworkFirewallPolicyRequest. + } + op, err := c.RemoveAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_RemoveRule() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveRuleRegionNetworkFirewallPolicyRequest. + } + op, err := c.RemoveRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionNetworkFirewallPoliciesClient_SetIamPolicy() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.SetIamPolicyRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetIamPolicyRegionNetworkFirewallPolicyRequest. + } + resp, err := c.SetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRegionNetworkFirewallPoliciesClient_TestIamPermissions() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.TestIamPermissionsRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#TestIamPermissionsRegionNetworkFirewallPolicyRequest. + } + resp, err := c.TestIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/compute/apiv1/region_security_policies_client.go b/compute/apiv1/region_security_policies_client.go new file mode 100644 index 00000000000..56fea671ff1 --- /dev/null +++ b/compute/apiv1/region_security_policies_client.go @@ -0,0 +1,576 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute + +import ( + "bytes" + "context" + "fmt" + "io/ioutil" + "math" + "net/http" + "net/url" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/googleapi" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + httptransport "google.golang.org/api/transport/http" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" +) + +var newRegionSecurityPoliciesClientHook clientHook + +// RegionSecurityPoliciesCallOptions contains the retry settings for each method of RegionSecurityPoliciesClient. +type RegionSecurityPoliciesCallOptions struct { + Delete []gax.CallOption + Get []gax.CallOption + Insert []gax.CallOption + List []gax.CallOption + Patch []gax.CallOption +} + +// internalRegionSecurityPoliciesClient is an interface that defines the methods availaible from Google Compute Engine API. +type internalRegionSecurityPoliciesClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + Delete(context.Context, *computepb.DeleteRegionSecurityPolicyRequest, ...gax.CallOption) (*Operation, error) + Get(context.Context, *computepb.GetRegionSecurityPolicyRequest, ...gax.CallOption) (*computepb.SecurityPolicy, error) + Insert(context.Context, *computepb.InsertRegionSecurityPolicyRequest, ...gax.CallOption) (*Operation, error) + List(context.Context, *computepb.ListRegionSecurityPoliciesRequest, ...gax.CallOption) *SecurityPolicyIterator + Patch(context.Context, *computepb.PatchRegionSecurityPolicyRequest, ...gax.CallOption) (*Operation, error) +} + +// RegionSecurityPoliciesClient is a client for interacting with Google Compute Engine API. +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +// +// The RegionSecurityPolicies API. +type RegionSecurityPoliciesClient struct { + // The internal transport-dependent client. + internalClient internalRegionSecurityPoliciesClient + + // The call options for this service. + CallOptions *RegionSecurityPoliciesCallOptions +} + +// Wrapper methods routed to the internal client. + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *RegionSecurityPoliciesClient) Close() error { + return c.internalClient.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 *RegionSecurityPoliciesClient) setGoogleClientInfo(keyval ...string) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *RegionSecurityPoliciesClient) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// Delete deletes the specified policy. +func (c *RegionSecurityPoliciesClient) Delete(ctx context.Context, req *computepb.DeleteRegionSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Delete(ctx, req, opts...) +} + +// Get list all of the ordered rules present in a single specified policy. +func (c *RegionSecurityPoliciesClient) Get(ctx context.Context, req *computepb.GetRegionSecurityPolicyRequest, opts ...gax.CallOption) (*computepb.SecurityPolicy, error) { + return c.internalClient.Get(ctx, req, opts...) +} + +// Insert creates a new policy in the specified project using the data included in the request. +func (c *RegionSecurityPoliciesClient) Insert(ctx context.Context, req *computepb.InsertRegionSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Insert(ctx, req, opts...) +} + +// List list all the policies that have been configured for the specified project and region. +func (c *RegionSecurityPoliciesClient) List(ctx context.Context, req *computepb.ListRegionSecurityPoliciesRequest, opts ...gax.CallOption) *SecurityPolicyIterator { + return c.internalClient.List(ctx, req, opts...) +} + +// Patch patches the specified policy with the data included in the request. +func (c *RegionSecurityPoliciesClient) Patch(ctx context.Context, req *computepb.PatchRegionSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Patch(ctx, req, opts...) +} + +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type regionSecurityPoliciesRESTClient struct { + // The http endpoint to connect to. + endpoint string + + // The http client. + httpClient *http.Client + + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewRegionSecurityPoliciesRESTClient creates a new region security policies rest client. +// +// The RegionSecurityPolicies API. +func NewRegionSecurityPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*RegionSecurityPoliciesClient, error) { + clientOpts := append(defaultRegionSecurityPoliciesRESTClientOptions(), opts...) + httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) + if err != nil { + return nil, err + } + + c := ®ionSecurityPoliciesRESTClient{ + endpoint: endpoint, + httpClient: httpClient, + } + c.setGoogleClientInfo() + + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + + return &RegionSecurityPoliciesClient{internalClient: c, CallOptions: &RegionSecurityPoliciesCallOptions{}}, nil +} + +func defaultRegionSecurityPoliciesRESTClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("https://compute.googleapis.com"), + internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"), + internaloption.WithDefaultAudience("https://compute.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + } +} + +// 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 *regionSecurityPoliciesRESTClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN") + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *regionSecurityPoliciesRESTClient) Close() error { + // Replace httpClient with nil to force cleanup. + c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } + return nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *regionSecurityPoliciesRESTClient) Connection() *grpc.ClientConn { + return nil +} + +// Delete deletes the specified policy. +func (c *regionSecurityPoliciesRESTClient) Delete(ctx context.Context, req *computepb.DeleteRegionSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/securityPolicies/%v", req.GetProject(), req.GetRegion(), req.GetSecurityPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// Get list all of the ordered rules present in a single specified policy. +func (c *regionSecurityPoliciesRESTClient) Get(ctx context.Context, req *computepb.GetRegionSecurityPolicyRequest, opts ...gax.CallOption) (*computepb.SecurityPolicy, error) { + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/securityPolicies/%v", req.GetProject(), req.GetRegion(), req.GetSecurityPolicy()) + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.SecurityPolicy{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + return resp, nil +} + +// Insert creates a new policy in the specified project using the data included in the request. +func (c *regionSecurityPoliciesRESTClient) Insert(ctx context.Context, req *computepb.InsertRegionSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetSecurityPolicyResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/securityPolicies", req.GetProject(), req.GetRegion()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + if req != nil && req.ValidateOnly != nil { + params.Add("validateOnly", fmt.Sprintf("%v", req.GetValidateOnly())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// List list all the policies that have been configured for the specified project and region. +func (c *regionSecurityPoliciesRESTClient) List(ctx context.Context, req *computepb.ListRegionSecurityPoliciesRequest, opts ...gax.CallOption) *SecurityPolicyIterator { + it := &SecurityPolicyIterator{} + req = proto.Clone(req).(*computepb.ListRegionSecurityPoliciesRequest) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.SecurityPolicy, string, error) { + resp := &computepb.SecurityPolicyList{} + if pageToken != "" { + req.PageToken = proto.String(pageToken) + } + if pageSize > math.MaxInt32 { + req.MaxResults = proto.Uint32(math.MaxInt32) + } else if pageSize != 0 { + req.MaxResults = proto.Uint32(uint32(pageSize)) + } + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/securityPolicies", req.GetProject(), req.GetRegion()) + + params := url.Values{} + if req != nil && req.Filter != nil { + params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) + } + if req != nil && req.MaxResults != nil { + params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults())) + } + if req != nil && req.OrderBy != nil { + params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) + } + if req != nil && req.PageToken != nil { + params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) + } + if req != nil && req.ReturnPartialSuccess != nil { + params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, "", e + } + it.Response = resp + return resp.GetItems(), 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.GetMaxResults()) + it.pageInfo.Token = req.GetPageToken() + + return it +} + +// Patch patches the specified policy with the data included in the request. +func (c *regionSecurityPoliciesRESTClient) Patch(ctx context.Context, req *computepb.PatchRegionSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetSecurityPolicyResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/securityPolicies/%v", req.GetProject(), req.GetRegion(), req.GetSecurityPolicy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + +// SecurityPolicyIterator manages a stream of *computepb.SecurityPolicy. +type SecurityPolicyIterator struct { + items []*computepb.SecurityPolicy + 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 []*computepb.SecurityPolicy, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *SecurityPolicyIterator) 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 *SecurityPolicyIterator) Next() (*computepb.SecurityPolicy, error) { + var item *computepb.SecurityPolicy + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *SecurityPolicyIterator) bufLen() int { + return len(it.items) +} + +func (it *SecurityPolicyIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/compute/apiv1/region_security_policies_client_example_test.go b/compute/apiv1/region_security_policies_client_example_test.go new file mode 100644 index 00000000000..8755b540b6d --- /dev/null +++ b/compute/apiv1/region_security_policies_client_example_test.go @@ -0,0 +1,152 @@ +// Copyright 2022 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 protoc-gen-go_gapic. DO NOT EDIT. + +package compute_test + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func ExampleNewRegionSecurityPoliciesRESTClient() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleRegionSecurityPoliciesClient_Delete() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionSecurityPolicyRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionSecurityPoliciesClient_Get() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRegionSecurityPolicyRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRegionSecurityPoliciesClient_Insert() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionSecurityPolicyRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRegionSecurityPoliciesClient_List() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.ListRegionSecurityPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListRegionSecurityPoliciesRequest. + } + it := c.List(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleRegionSecurityPoliciesClient_Patch() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionSecurityPolicyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} diff --git a/compute/apiv1/region_target_https_proxies_client.go b/compute/apiv1/region_target_https_proxies_client.go index 357226c335e..90688888eba 100644 --- a/compute/apiv1/region_target_https_proxies_client.go +++ b/compute/apiv1/region_target_https_proxies_client.go @@ -46,6 +46,7 @@ type RegionTargetHttpsProxiesCallOptions struct { Get []gax.CallOption Insert []gax.CallOption List []gax.CallOption + Patch []gax.CallOption SetSslCertificates []gax.CallOption SetUrlMap []gax.CallOption } @@ -59,6 +60,7 @@ type internalRegionTargetHttpsProxiesClient interface { Get(context.Context, *computepb.GetRegionTargetHttpsProxyRequest, ...gax.CallOption) (*computepb.TargetHttpsProxy, error) Insert(context.Context, *computepb.InsertRegionTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) List(context.Context, *computepb.ListRegionTargetHttpsProxiesRequest, ...gax.CallOption) *TargetHttpsProxyIterator + Patch(context.Context, *computepb.PatchRegionTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) SetSslCertificates(context.Context, *computepb.SetSslCertificatesRegionTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) SetUrlMap(context.Context, *computepb.SetUrlMapRegionTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) } @@ -117,6 +119,11 @@ func (c *RegionTargetHttpsProxiesClient) List(ctx context.Context, req *computep return c.internalClient.List(ctx, req, opts...) } +// Patch patches the specified regional TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. +func (c *RegionTargetHttpsProxiesClient) Patch(ctx context.Context, req *computepb.PatchRegionTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { + return c.internalClient.Patch(ctx, req, opts...) +} + // SetSslCertificates replaces SslCertificates for TargetHttpsProxy. func (c *RegionTargetHttpsProxiesClient) SetSslCertificates(ctx context.Context, req *computepb.SetSslCertificatesRegionTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { return c.internalClient.SetSslCertificates(ctx, req, opts...) @@ -466,6 +473,72 @@ func (c *regionTargetHttpsProxiesRESTClient) List(ctx context.Context, req *comp return it } +// Patch patches the specified regional TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. +func (c *regionTargetHttpsProxiesRESTClient) Patch(ctx context.Context, req *computepb.PatchRegionTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { + m := protojson.MarshalOptions{AllowPartial: true} + body := req.GetTargetHttpsProxyResource() + jsonReq, err := m.Marshal(body) + if err != nil { + return nil, err + } + + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/targetHttpsProxies/%v", req.GetProject(), req.GetRegion(), req.GetTargetHttpsProxy()) + + params := url.Values{} + if req != nil && req.RequestId != nil { + params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + resp := &computepb.Operation{} + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) + if err != nil { + return err + } + httpReq = httpReq.WithContext(ctx) + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, e + } + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } + return op, nil +} + // SetSslCertificates replaces SslCertificates for TargetHttpsProxy. func (c *regionTargetHttpsProxiesRESTClient) SetSslCertificates(ctx context.Context, req *computepb.SetSslCertificatesRegionTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { m := protojson.MarshalOptions{AllowPartial: true} diff --git a/compute/apiv1/region_target_https_proxies_client_example_test.go b/compute/apiv1/region_target_https_proxies_client_example_test.go index a679eea2b52..b6ccb9441ea 100644 --- a/compute/apiv1/region_target_https_proxies_client_example_test.go +++ b/compute/apiv1/region_target_https_proxies_client_example_test.go @@ -128,6 +128,29 @@ func ExampleRegionTargetHttpsProxiesClient_List() { } } +func ExampleRegionTargetHttpsProxiesClient_Patch() { + ctx := context.Background() + c, err := compute.NewRegionTargetHttpsProxiesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRegionTargetHttpsProxyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionTargetHttpsProxyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + func ExampleRegionTargetHttpsProxiesClient_SetSslCertificates() { ctx := context.Background() c, err := compute.NewRegionTargetHttpsProxiesRESTClient(ctx) diff --git a/compute/apiv1/security_policies_client.go b/compute/apiv1/security_policies_client.go index f254f1b7d9b..a63d254f22f 100644 --- a/compute/apiv1/security_policies_client.go +++ b/compute/apiv1/security_policies_client.go @@ -24,6 +24,7 @@ import ( "math" "net/http" "net/url" + "sort" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/googleapi" @@ -43,6 +44,7 @@ var newSecurityPoliciesClientHook clientHook // SecurityPoliciesCallOptions contains the retry settings for each method of SecurityPoliciesClient. type SecurityPoliciesCallOptions struct { AddRule []gax.CallOption + AggregatedList []gax.CallOption Delete []gax.CallOption Get []gax.CallOption GetRule []gax.CallOption @@ -60,6 +62,7 @@ type internalSecurityPoliciesClient interface { setGoogleClientInfo(...string) Connection() *grpc.ClientConn AddRule(context.Context, *computepb.AddRuleSecurityPolicyRequest, ...gax.CallOption) (*Operation, error) + AggregatedList(context.Context, *computepb.AggregatedListSecurityPoliciesRequest, ...gax.CallOption) *SecurityPoliciesScopedListPairIterator Delete(context.Context, *computepb.DeleteSecurityPolicyRequest, ...gax.CallOption) (*Operation, error) Get(context.Context, *computepb.GetSecurityPolicyRequest, ...gax.CallOption) (*computepb.SecurityPolicy, error) GetRule(context.Context, *computepb.GetRuleSecurityPolicyRequest, ...gax.CallOption) (*computepb.SecurityPolicyRule, error) @@ -110,6 +113,11 @@ func (c *SecurityPoliciesClient) AddRule(ctx context.Context, req *computepb.Add return c.internalClient.AddRule(ctx, req, opts...) } +// AggregatedList retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project. +func (c *SecurityPoliciesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListSecurityPoliciesRequest, opts ...gax.CallOption) *SecurityPoliciesScopedListPairIterator { + return c.internalClient.AggregatedList(ctx, req, opts...) +} + // Delete deletes the specified policy. func (c *SecurityPoliciesClient) Delete(ctx context.Context, req *computepb.DeleteSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { return c.internalClient.Delete(ctx, req, opts...) @@ -293,6 +301,106 @@ func (c *securityPoliciesRESTClient) AddRule(ctx context.Context, req *computepb return op, nil } +// AggregatedList retrieves the list of all SecurityPolicy resources, regional and global, available to the specified project. +func (c *securityPoliciesRESTClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListSecurityPoliciesRequest, opts ...gax.CallOption) *SecurityPoliciesScopedListPairIterator { + it := &SecurityPoliciesScopedListPairIterator{} + req = proto.Clone(req).(*computepb.AggregatedListSecurityPoliciesRequest) + unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} + it.InternalFetch = func(pageSize int, pageToken string) ([]SecurityPoliciesScopedListPair, string, error) { + resp := &computepb.SecurityPoliciesAggregatedList{} + if pageToken != "" { + req.PageToken = proto.String(pageToken) + } + if pageSize > math.MaxInt32 { + req.MaxResults = proto.Uint32(math.MaxInt32) + } else if pageSize != 0 { + req.MaxResults = proto.Uint32(uint32(pageSize)) + } + baseUrl, _ := url.Parse(c.endpoint) + baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/aggregated/securityPolicies", req.GetProject()) + + params := url.Values{} + if req != nil && req.Filter != nil { + params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) + } + if req != nil && req.IncludeAllScopes != nil { + params.Add("includeAllScopes", fmt.Sprintf("%v", req.GetIncludeAllScopes())) + } + if req != nil && req.MaxResults != nil { + params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults())) + } + if req != nil && req.OrderBy != nil { + params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) + } + if req != nil && req.PageToken != nil { + params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) + } + if req != nil && req.ReturnPartialSuccess != nil { + params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess())) + } + + baseUrl.RawQuery = params.Encode() + + // Build HTTP headers from client and context metadata. + headers := buildHeaders(ctx, c.xGoogMetadata, metadata.Pairs("Content-Type", "application/json")) + e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) + if err != nil { + return err + } + httpReq.Header = headers + + httpRsp, err := c.httpClient.Do(httpReq) + if err != nil { + return err + } + defer httpRsp.Body.Close() + + if err = googleapi.CheckResponse(httpRsp); err != nil { + return err + } + + buf, err := ioutil.ReadAll(httpRsp.Body) + if err != nil { + return err + } + + if err := unm.Unmarshal(buf, resp); err != nil { + return maybeUnknownEnum(err) + } + + return nil + }, opts...) + if e != nil { + return nil, "", e + } + it.Response = resp + + elems := make([]SecurityPoliciesScopedListPair, 0, len(resp.GetItems())) + for k, v := range resp.GetItems() { + elems = append(elems, SecurityPoliciesScopedListPair{k, v}) + } + sort.Slice(elems, func(i, j int) bool { return elems[i].Key < elems[j].Key }) + + return elems, 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.GetMaxResults()) + it.pageInfo.Token = req.GetPageToken() + + return it +} + // Delete deletes the specified policy. func (c *securityPoliciesRESTClient) Delete(ctx context.Context, req *computepb.DeleteSecurityPolicyRequest, opts ...gax.CallOption) (*Operation, error) { baseUrl, _ := url.Parse(c.endpoint) @@ -852,9 +960,15 @@ func (c *securityPoliciesRESTClient) RemoveRule(ctx context.Context, req *comput return op, nil } -// SecurityPolicyIterator manages a stream of *computepb.SecurityPolicy. -type SecurityPolicyIterator struct { - items []*computepb.SecurityPolicy +// SecurityPoliciesScopedListPair is a holder type for string/*computepb.SecurityPoliciesScopedList map entries +type SecurityPoliciesScopedListPair struct { + Key string + Value *computepb.SecurityPoliciesScopedList +} + +// SecurityPoliciesScopedListPairIterator manages a stream of SecurityPoliciesScopedListPair. +type SecurityPoliciesScopedListPairIterator struct { + items []SecurityPoliciesScopedListPair pageInfo *iterator.PageInfo nextFunc func() error @@ -869,18 +983,18 @@ type SecurityPolicyIterator struct { // 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 []*computepb.SecurityPolicy, nextPageToken string, err error) + InternalFetch func(pageSize int, pageToken string) (results []SecurityPoliciesScopedListPair, nextPageToken string, err error) } // PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *SecurityPolicyIterator) PageInfo() *iterator.PageInfo { +func (it *SecurityPoliciesScopedListPairIterator) 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 *SecurityPolicyIterator) Next() (*computepb.SecurityPolicy, error) { - var item *computepb.SecurityPolicy +func (it *SecurityPoliciesScopedListPairIterator) Next() (SecurityPoliciesScopedListPair, error) { + var item SecurityPoliciesScopedListPair if err := it.nextFunc(); err != nil { return item, err } @@ -889,11 +1003,11 @@ func (it *SecurityPolicyIterator) Next() (*computepb.SecurityPolicy, error) { return item, nil } -func (it *SecurityPolicyIterator) bufLen() int { +func (it *SecurityPoliciesScopedListPairIterator) bufLen() int { return len(it.items) } -func (it *SecurityPolicyIterator) takeBuf() interface{} { +func (it *SecurityPoliciesScopedListPairIterator) takeBuf() interface{} { b := it.items it.items = nil return b diff --git a/compute/apiv1/security_policies_client_example_test.go b/compute/apiv1/security_policies_client_example_test.go index 022901f93f9..a7cbc07e059 100644 --- a/compute/apiv1/security_policies_client_example_test.go +++ b/compute/apiv1/security_policies_client_example_test.go @@ -59,6 +59,32 @@ func ExampleSecurityPoliciesClient_AddRule() { } } +func ExampleSecurityPoliciesClient_AggregatedList() { + ctx := context.Background() + c, err := compute.NewSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AggregatedListSecurityPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AggregatedListSecurityPoliciesRequest. + } + it := c.AggregatedList(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + func ExampleSecurityPoliciesClient_Delete() { ctx := context.Background() c, err := compute.NewSecurityPoliciesRESTClient(ctx) diff --git a/compute/go.mod b/compute/go.mod index c973ad5e2bd..0e31eb3112e 100644 --- a/compute/go.mod +++ b/compute/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/go-cmp v0.5.7 github.com/googleapis/gax-go/v2 v2.2.0 google.golang.org/api v0.74.0 - google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb + google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac google.golang.org/grpc v1.45.0 google.golang.org/protobuf v1.28.0 ) diff --git a/compute/go.sum b/compute/go.sum index 9e4db38227f..b52e04616d8 100644 --- a/compute/go.sum +++ b/compute/go.sum @@ -536,8 +536,9 @@ google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2 google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb h1:0m9wktIpOxGw+SSKmydXWB3Z3GTfcPP6+q75HCQa6HI= google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= 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/go.mod b/go.mod index f591d70f0f0..054e00e8453 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 google.golang.org/api v0.74.0 - google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf + google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac google.golang.org/grpc v1.45.0 google.golang.org/protobuf v1.28.0 ) diff --git a/go.sum b/go.sum index f6ecd9d2c59..6c9f7e75632 100644 --- a/go.sum +++ b/go.sum @@ -558,8 +558,8 @@ google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2 google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf h1:JTjwKJX9erVpsw17w+OIPP7iAgEkN/r8urhWSunEDTs= -google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= 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/bigquery/migration/apiv2/Client/CreateMigrationWorkflow/main.go b/internal/generated/snippets/bigquery/migration/apiv2/Client/CreateMigrationWorkflow/main.go new file mode 100644 index 00000000000..4c611f691cb --- /dev/null +++ b/internal/generated/snippets/bigquery/migration/apiv2/Client/CreateMigrationWorkflow/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START bigquerymigration_v2_generated_MigrationService_CreateMigrationWorkflow_sync] + +package main + +import ( + "context" + + migration "cloud.google.com/go/bigquery/migration/apiv2" + migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2" +) + +func main() { + ctx := context.Background() + c, err := migration.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &migrationpb.CreateMigrationWorkflowRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2#CreateMigrationWorkflowRequest. + } + resp, err := c.CreateMigrationWorkflow(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END bigquerymigration_v2_generated_MigrationService_CreateMigrationWorkflow_sync] diff --git a/internal/generated/snippets/bigquery/migration/apiv2/Client/DeleteMigrationWorkflow/main.go b/internal/generated/snippets/bigquery/migration/apiv2/Client/DeleteMigrationWorkflow/main.go new file mode 100644 index 00000000000..02a06faab39 --- /dev/null +++ b/internal/generated/snippets/bigquery/migration/apiv2/Client/DeleteMigrationWorkflow/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START bigquerymigration_v2_generated_MigrationService_DeleteMigrationWorkflow_sync] + +package main + +import ( + "context" + + migration "cloud.google.com/go/bigquery/migration/apiv2" + migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2" +) + +func main() { + ctx := context.Background() + c, err := migration.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &migrationpb.DeleteMigrationWorkflowRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2#DeleteMigrationWorkflowRequest. + } + err = c.DeleteMigrationWorkflow(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END bigquerymigration_v2_generated_MigrationService_DeleteMigrationWorkflow_sync] diff --git a/internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationSubtask/main.go b/internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationSubtask/main.go new file mode 100644 index 00000000000..4952930c24b --- /dev/null +++ b/internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationSubtask/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START bigquerymigration_v2_generated_MigrationService_GetMigrationSubtask_sync] + +package main + +import ( + "context" + + migration "cloud.google.com/go/bigquery/migration/apiv2" + migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2" +) + +func main() { + ctx := context.Background() + c, err := migration.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &migrationpb.GetMigrationSubtaskRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2#GetMigrationSubtaskRequest. + } + resp, err := c.GetMigrationSubtask(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END bigquerymigration_v2_generated_MigrationService_GetMigrationSubtask_sync] diff --git a/internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationWorkflow/main.go b/internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationWorkflow/main.go new file mode 100644 index 00000000000..e8af902ad23 --- /dev/null +++ b/internal/generated/snippets/bigquery/migration/apiv2/Client/GetMigrationWorkflow/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START bigquerymigration_v2_generated_MigrationService_GetMigrationWorkflow_sync] + +package main + +import ( + "context" + + migration "cloud.google.com/go/bigquery/migration/apiv2" + migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2" +) + +func main() { + ctx := context.Background() + c, err := migration.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &migrationpb.GetMigrationWorkflowRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2#GetMigrationWorkflowRequest. + } + resp, err := c.GetMigrationWorkflow(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END bigquerymigration_v2_generated_MigrationService_GetMigrationWorkflow_sync] diff --git a/internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationSubtasks/main.go b/internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationSubtasks/main.go new file mode 100644 index 00000000000..e9735223166 --- /dev/null +++ b/internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationSubtasks/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START bigquerymigration_v2_generated_MigrationService_ListMigrationSubtasks_sync] + +package main + +import ( + "context" + + migration "cloud.google.com/go/bigquery/migration/apiv2" + "google.golang.org/api/iterator" + migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2" +) + +func main() { + ctx := context.Background() + c, err := migration.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &migrationpb.ListMigrationSubtasksRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2#ListMigrationSubtasksRequest. + } + it := c.ListMigrationSubtasks(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END bigquerymigration_v2_generated_MigrationService_ListMigrationSubtasks_sync] diff --git a/internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationWorkflows/main.go b/internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationWorkflows/main.go new file mode 100644 index 00000000000..f0463c4dc69 --- /dev/null +++ b/internal/generated/snippets/bigquery/migration/apiv2/Client/ListMigrationWorkflows/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START bigquerymigration_v2_generated_MigrationService_ListMigrationWorkflows_sync] + +package main + +import ( + "context" + + migration "cloud.google.com/go/bigquery/migration/apiv2" + "google.golang.org/api/iterator" + migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2" +) + +func main() { + ctx := context.Background() + c, err := migration.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &migrationpb.ListMigrationWorkflowsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2#ListMigrationWorkflowsRequest. + } + it := c.ListMigrationWorkflows(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END bigquerymigration_v2_generated_MigrationService_ListMigrationWorkflows_sync] diff --git a/internal/generated/snippets/bigquery/migration/apiv2/Client/StartMigrationWorkflow/main.go b/internal/generated/snippets/bigquery/migration/apiv2/Client/StartMigrationWorkflow/main.go new file mode 100644 index 00000000000..a6bc23a5f56 --- /dev/null +++ b/internal/generated/snippets/bigquery/migration/apiv2/Client/StartMigrationWorkflow/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START bigquerymigration_v2_generated_MigrationService_StartMigrationWorkflow_sync] + +package main + +import ( + "context" + + migration "cloud.google.com/go/bigquery/migration/apiv2" + migrationpb "google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2" +) + +func main() { + ctx := context.Background() + c, err := migration.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &migrationpb.StartMigrationWorkflowRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/migration/v2#StartMigrationWorkflowRequest. + } + err = c.StartMigrationWorkflow(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END bigquerymigration_v2_generated_MigrationService_StartMigrationWorkflow_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/AggregatedList/main.go b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/AggregatedList/main.go new file mode 100644 index 00000000000..e82168453a4 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/AggregatedList/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkEdgeSecurityServices_AggregatedList_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AggregatedListNetworkEdgeSecurityServicesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AggregatedListNetworkEdgeSecurityServicesRequest. + } + it := c.AggregatedList(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END compute_v1_generated_NetworkEdgeSecurityServices_AggregatedList_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Delete/main.go b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Delete/main.go new file mode 100644 index 00000000000..de0241b6035 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Delete/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkEdgeSecurityServices_Delete_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNetworkEdgeSecurityServiceRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkEdgeSecurityServices_Delete_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Get/main.go b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Get/main.go new file mode 100644 index 00000000000..2dd0c71c695 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Get/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkEdgeSecurityServices_Get_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetNetworkEdgeSecurityServiceRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_NetworkEdgeSecurityServices_Get_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Insert/main.go b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Insert/main.go new file mode 100644 index 00000000000..ed740e12ceb --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Insert/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkEdgeSecurityServices_Insert_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNetworkEdgeSecurityServiceRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkEdgeSecurityServices_Insert_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Patch/main.go b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Patch/main.go new file mode 100644 index 00000000000..ae719c1d518 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkEdgeSecurityServicesClient/Patch/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkEdgeSecurityServices_Patch_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchNetworkEdgeSecurityServiceRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchNetworkEdgeSecurityServiceRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkEdgeSecurityServices_Patch_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddAssociation/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddAssociation/main.go new file mode 100644 index 00000000000..70adf9f2d25 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddAssociation/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_AddAssociation_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddAssociationNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddAssociationNetworkFirewallPolicyRequest. + } + op, err := c.AddAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_AddAssociation_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddRule/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddRule/main.go new file mode 100644 index 00000000000..40534ae5e3c --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/AddRule/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_AddRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddRuleNetworkFirewallPolicyRequest. + } + op, err := c.AddRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_AddRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/CloneRules/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/CloneRules/main.go new file mode 100644 index 00000000000..a09472f9cd4 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/CloneRules/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_CloneRules_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.CloneRulesNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CloneRulesNetworkFirewallPolicyRequest. + } + op, err := c.CloneRules(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_CloneRules_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Delete/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Delete/main.go new file mode 100644 index 00000000000..b65b6fab0f2 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Delete/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_Delete_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNetworkFirewallPolicyRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_Delete_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Get/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Get/main.go new file mode 100644 index 00000000000..5eac50a696a --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Get/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_Get_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetNetworkFirewallPolicyRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_NetworkFirewallPolicies_Get_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetAssociation/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetAssociation/main.go new file mode 100644 index 00000000000..216ca490243 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetAssociation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_GetAssociation_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetAssociationNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetAssociationNetworkFirewallPolicyRequest. + } + resp, err := c.GetAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_NetworkFirewallPolicies_GetAssociation_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetIamPolicy/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetIamPolicy/main.go new file mode 100644 index 00000000000..b7bbc9b4159 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetIamPolicy/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_GetIamPolicy_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetIamPolicyNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetIamPolicyNetworkFirewallPolicyRequest. + } + resp, err := c.GetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_NetworkFirewallPolicies_GetIamPolicy_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetRule/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetRule/main.go new file mode 100644 index 00000000000..8acfad3ccb4 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/GetRule/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_GetRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRuleNetworkFirewallPolicyRequest. + } + resp, err := c.GetRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_NetworkFirewallPolicies_GetRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Insert/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Insert/main.go new file mode 100644 index 00000000000..eea60a81b18 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Insert/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_Insert_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNetworkFirewallPolicyRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_Insert_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/List/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/List/main.go new file mode 100644 index 00000000000..e0468e57060 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/List/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_List_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.ListNetworkFirewallPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListNetworkFirewallPoliciesRequest. + } + it := c.List(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_List_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Patch/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Patch/main.go new file mode 100644 index 00000000000..fbfe0d682ee --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/Patch/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_Patch_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchNetworkFirewallPolicyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_Patch_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/PatchRule/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/PatchRule/main.go new file mode 100644 index 00000000000..b7df05eb9c5 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/PatchRule/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_PatchRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRuleNetworkFirewallPolicyRequest. + } + op, err := c.PatchRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_PatchRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveAssociation/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveAssociation/main.go new file mode 100644 index 00000000000..8a8387fa2e5 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveAssociation/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_RemoveAssociation_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveAssociationNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveAssociationNetworkFirewallPolicyRequest. + } + op, err := c.RemoveAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_RemoveAssociation_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveRule/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveRule/main.go new file mode 100644 index 00000000000..a995bebaf2c --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/RemoveRule/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_RemoveRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveRuleNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveRuleNetworkFirewallPolicyRequest. + } + op, err := c.RemoveRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_NetworkFirewallPolicies_RemoveRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/SetIamPolicy/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/SetIamPolicy/main.go new file mode 100644 index 00000000000..c4fb1cd67a7 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/SetIamPolicy/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_SetIamPolicy_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.SetIamPolicyNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetIamPolicyNetworkFirewallPolicyRequest. + } + resp, err := c.SetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_NetworkFirewallPolicies_SetIamPolicy_sync] diff --git a/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/TestIamPermissions/main.go b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/TestIamPermissions/main.go new file mode 100644 index 00000000000..04a694c5b88 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/NetworkFirewallPoliciesClient/TestIamPermissions/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_NetworkFirewallPolicies_TestIamPermissions_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.TestIamPermissionsNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#TestIamPermissionsNetworkFirewallPolicyRequest. + } + resp, err := c.TestIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_NetworkFirewallPolicies_TestIamPermissions_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddAssociation/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddAssociation/main.go new file mode 100644 index 00000000000..bcf115e27d5 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddAssociation/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_AddAssociation_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddAssociationRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddAssociationRegionNetworkFirewallPolicyRequest. + } + op, err := c.AddAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_AddAssociation_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddRule/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddRule/main.go new file mode 100644 index 00000000000..eec3c70177a --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/AddRule/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_AddRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AddRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddRuleRegionNetworkFirewallPolicyRequest. + } + op, err := c.AddRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_AddRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/CloneRules/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/CloneRules/main.go new file mode 100644 index 00000000000..ac8cb1ec358 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/CloneRules/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_CloneRules_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.CloneRulesRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CloneRulesRegionNetworkFirewallPolicyRequest. + } + op, err := c.CloneRules(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_CloneRules_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Delete/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Delete/main.go new file mode 100644 index 00000000000..2a0737fcbb1 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Delete/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_Delete_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionNetworkFirewallPolicyRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_Delete_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Get/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Get/main.go new file mode 100644 index 00000000000..c081f0aef9c --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Get/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_Get_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRegionNetworkFirewallPolicyRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_Get_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetAssociation/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetAssociation/main.go new file mode 100644 index 00000000000..6cd61260f3d --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetAssociation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_GetAssociation_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetAssociationRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetAssociationRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_GetAssociation_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetEffectiveFirewalls/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetEffectiveFirewalls/main.go new file mode 100644 index 00000000000..b000869573d --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetEffectiveFirewalls/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_GetEffectiveFirewalls_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetEffectiveFirewallsRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetEffectiveFirewalls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_GetEffectiveFirewalls_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetIamPolicy/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetIamPolicy/main.go new file mode 100644 index 00000000000..7047f4a5135 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetIamPolicy/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_GetIamPolicy_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetIamPolicyRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetIamPolicyRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_GetIamPolicy_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetRule/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetRule/main.go new file mode 100644 index 00000000000..ad667d990ce --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/GetRule/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_GetRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRuleRegionNetworkFirewallPolicyRequest. + } + resp, err := c.GetRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_GetRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Insert/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Insert/main.go new file mode 100644 index 00000000000..5d920ae65e2 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Insert/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_Insert_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionNetworkFirewallPolicyRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_Insert_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/List/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/List/main.go new file mode 100644 index 00000000000..f7f3dd9344d --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/List/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_List_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.ListRegionNetworkFirewallPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListRegionNetworkFirewallPoliciesRequest. + } + it := c.List(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_List_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Patch/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Patch/main.go new file mode 100644 index 00000000000..54c7d9f3696 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/Patch/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_Patch_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionNetworkFirewallPolicyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_Patch_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/PatchRule/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/PatchRule/main.go new file mode 100644 index 00000000000..7ac6d0ee827 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/PatchRule/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_PatchRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRuleRegionNetworkFirewallPolicyRequest. + } + op, err := c.PatchRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_PatchRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveAssociation/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveAssociation/main.go new file mode 100644 index 00000000000..7184cfa1f3d --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveAssociation/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_RemoveAssociation_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveAssociationRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveAssociationRegionNetworkFirewallPolicyRequest. + } + op, err := c.RemoveAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_RemoveAssociation_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveRule/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveRule/main.go new file mode 100644 index 00000000000..16cb19ebf43 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/RemoveRule/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_RemoveRule_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.RemoveRuleRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveRuleRegionNetworkFirewallPolicyRequest. + } + op, err := c.RemoveRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_RemoveRule_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/SetIamPolicy/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/SetIamPolicy/main.go new file mode 100644 index 00000000000..bf512177c82 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/SetIamPolicy/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_SetIamPolicy_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.SetIamPolicyRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetIamPolicyRegionNetworkFirewallPolicyRequest. + } + resp, err := c.SetIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_SetIamPolicy_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/TestIamPermissions/main.go b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/TestIamPermissions/main.go new file mode 100644 index 00000000000..1d6df2c9608 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionNetworkFirewallPoliciesClient/TestIamPermissions/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionNetworkFirewallPolicies_TestIamPermissions_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionNetworkFirewallPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.TestIamPermissionsRegionNetworkFirewallPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#TestIamPermissionsRegionNetworkFirewallPolicyRequest. + } + resp, err := c.TestIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionNetworkFirewallPolicies_TestIamPermissions_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Delete/main.go b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Delete/main.go new file mode 100644 index 00000000000..0c68d3d7cd3 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Delete/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionSecurityPolicies_Delete_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.DeleteRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionSecurityPolicyRequest. + } + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionSecurityPolicies_Delete_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Get/main.go b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Get/main.go new file mode 100644 index 00000000000..4b115eed555 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Get/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionSecurityPolicies_Get_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.GetRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#GetRegionSecurityPolicyRequest. + } + resp, err := c.Get(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END compute_v1_generated_RegionSecurityPolicies_Get_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Insert/main.go b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Insert/main.go new file mode 100644 index 00000000000..1e8cc3696b7 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Insert/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionSecurityPolicies_Insert_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.InsertRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionSecurityPolicyRequest. + } + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionSecurityPolicies_Insert_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/List/main.go b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/List/main.go new file mode 100644 index 00000000000..8e6a7b000bf --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/List/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionSecurityPolicies_List_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.ListRegionSecurityPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ListRegionSecurityPoliciesRequest. + } + it := c.List(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END compute_v1_generated_RegionSecurityPolicies_List_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Patch/main.go b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Patch/main.go new file mode 100644 index 00000000000..0bddce3c9ac --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionSecurityPoliciesClient/Patch/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionSecurityPolicies_Patch_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRegionSecurityPolicyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionSecurityPolicyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionSecurityPolicies_Patch_sync] diff --git a/internal/generated/snippets/compute/apiv1/RegionTargetHttpsProxiesClient/Patch/main.go b/internal/generated/snippets/compute/apiv1/RegionTargetHttpsProxiesClient/Patch/main.go new file mode 100644 index 00000000000..b49b06edc14 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/RegionTargetHttpsProxiesClient/Patch/main.go @@ -0,0 +1,51 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_RegionTargetHttpsProxies_Patch_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewRegionTargetHttpsProxiesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.PatchRegionTargetHttpsProxyRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionTargetHttpsProxyRequest. + } + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +// [END compute_v1_generated_RegionTargetHttpsProxies_Patch_sync] diff --git a/internal/generated/snippets/compute/apiv1/SecurityPoliciesClient/AggregatedList/main.go b/internal/generated/snippets/compute/apiv1/SecurityPoliciesClient/AggregatedList/main.go new file mode 100644 index 00000000000..5565164b379 --- /dev/null +++ b/internal/generated/snippets/compute/apiv1/SecurityPoliciesClient/AggregatedList/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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. + +// Code generated by cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START compute_v1_generated_SecurityPolicies_AggregatedList_sync] + +package main + +import ( + "context" + + compute "cloud.google.com/go/compute/apiv1" + "google.golang.org/api/iterator" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +func main() { + ctx := context.Background() + c, err := compute.NewSecurityPoliciesRESTClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &computepb.AggregatedListSecurityPoliciesRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AggregatedListSecurityPoliciesRequest. + } + it := c.AggregatedList(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END compute_v1_generated_SecurityPolicies_AggregatedList_sync] diff --git a/internal/generated/snippets/go.mod b/internal/generated/snippets/go.mod index c8c18bcf46a..81bb1ae7f90 100644 --- a/internal/generated/snippets/go.mod +++ b/internal/generated/snippets/go.mod @@ -114,7 +114,7 @@ require ( cloud.google.com/go/workflows v1.1.0 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect google.golang.org/api v0.74.0 - google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf + google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac ) replace cloud.google.com/go/storagetransfer => ../../../storagetransfer diff --git a/internal/generated/snippets/go.sum b/internal/generated/snippets/go.sum index 0c11493bf5f..8b6bc306563 100644 --- a/internal/generated/snippets/go.sum +++ b/internal/generated/snippets/go.sum @@ -190,8 +190,9 @@ google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2I google.golang.org/genproto v0.0.0-20220328180837-c47567c462d1/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/genproto v0.0.0-20220329135034-5a5e19f58d62/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf h1:JTjwKJX9erVpsw17w+OIPP7iAgEkN/r8urhWSunEDTs= google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= 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/godocfx/go.sum b/internal/godocfx/go.sum index d81a6289f25..9fbfb9ed23b 100644 --- a/internal/godocfx/go.sum +++ b/internal/godocfx/go.sum @@ -226,8 +226,8 @@ google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2 google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf h1:JTjwKJX9erVpsw17w+OIPP7iAgEkN/r8urhWSunEDTs= -google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= 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/storage/go.sum b/storage/go.sum index 7b39d604534..15aeedc7cba 100644 --- a/storage/go.sum +++ b/storage/go.sum @@ -545,7 +545,6 @@ google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2 google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb h1:0m9wktIpOxGw+SSKmydXWB3Z3GTfcPP6+q75HCQa6HI= google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf h1:JTjwKJX9erVpsw17w+OIPP7iAgEkN/r8urhWSunEDTs= google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=