1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17package compute
18
19import (
20	"bytes"
21	"context"
22	"fmt"
23	"io/ioutil"
24	"math"
25	"net/http"
26	"net/url"
27
28	gax "github.com/googleapis/gax-go/v2"
29	"google.golang.org/api/googleapi"
30	"google.golang.org/api/iterator"
31	"google.golang.org/api/option"
32	"google.golang.org/api/option/internaloption"
33	httptransport "google.golang.org/api/transport/http"
34	computepb "google.golang.org/genproto/googleapis/cloud/compute/v1"
35	"google.golang.org/grpc"
36	"google.golang.org/grpc/metadata"
37	"google.golang.org/protobuf/encoding/protojson"
38	"google.golang.org/protobuf/proto"
39)
40
41var newFirewallPoliciesClientHook clientHook
42
43// FirewallPoliciesCallOptions contains the retry settings for each method of FirewallPoliciesClient.
44type FirewallPoliciesCallOptions struct {
45	AddAssociation     []gax.CallOption
46	AddRule            []gax.CallOption
47	CloneRules         []gax.CallOption
48	Delete             []gax.CallOption
49	Get                []gax.CallOption
50	GetAssociation     []gax.CallOption
51	GetIamPolicy       []gax.CallOption
52	GetRule            []gax.CallOption
53	Insert             []gax.CallOption
54	List               []gax.CallOption
55	ListAssociations   []gax.CallOption
56	Move               []gax.CallOption
57	Patch              []gax.CallOption
58	PatchRule          []gax.CallOption
59	RemoveAssociation  []gax.CallOption
60	RemoveRule         []gax.CallOption
61	SetIamPolicy       []gax.CallOption
62	TestIamPermissions []gax.CallOption
63}
64
65// internalFirewallPoliciesClient is an interface that defines the methods availaible from Google Compute Engine API.
66type internalFirewallPoliciesClient interface {
67	Close() error
68	setGoogleClientInfo(...string)
69	Connection() *grpc.ClientConn
70	AddAssociation(context.Context, *computepb.AddAssociationFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
71	AddRule(context.Context, *computepb.AddRuleFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
72	CloneRules(context.Context, *computepb.CloneRulesFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
73	Delete(context.Context, *computepb.DeleteFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
74	Get(context.Context, *computepb.GetFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicy, error)
75	GetAssociation(context.Context, *computepb.GetAssociationFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error)
76	GetIamPolicy(context.Context, *computepb.GetIamPolicyFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error)
77	GetRule(context.Context, *computepb.GetRuleFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPolicyRule, error)
78	Insert(context.Context, *computepb.InsertFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
79	List(context.Context, *computepb.ListFirewallPoliciesRequest, ...gax.CallOption) *FirewallPolicyIterator
80	ListAssociations(context.Context, *computepb.ListAssociationsFirewallPolicyRequest, ...gax.CallOption) (*computepb.FirewallPoliciesListAssociationsResponse, error)
81	Move(context.Context, *computepb.MoveFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
82	Patch(context.Context, *computepb.PatchFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
83	PatchRule(context.Context, *computepb.PatchRuleFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
84	RemoveAssociation(context.Context, *computepb.RemoveAssociationFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
85	RemoveRule(context.Context, *computepb.RemoveRuleFirewallPolicyRequest, ...gax.CallOption) (*Operation, error)
86	SetIamPolicy(context.Context, *computepb.SetIamPolicyFirewallPolicyRequest, ...gax.CallOption) (*computepb.Policy, error)
87	TestIamPermissions(context.Context, *computepb.TestIamPermissionsFirewallPolicyRequest, ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
88}
89
90// FirewallPoliciesClient is a client for interacting with Google Compute Engine API.
91// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
92//
93// The FirewallPolicies API.
94type FirewallPoliciesClient struct {
95	// The internal transport-dependent client.
96	internalClient internalFirewallPoliciesClient
97
98	// The call options for this service.
99	CallOptions *FirewallPoliciesCallOptions
100}
101
102// Wrapper methods routed to the internal client.
103
104// Close closes the connection to the API service. The user should invoke this when
105// the client is no longer required.
106func (c *FirewallPoliciesClient) Close() error {
107	return c.internalClient.Close()
108}
109
110// setGoogleClientInfo sets the name and version of the application in
111// the `x-goog-api-client` header passed on each request. Intended for
112// use by Google-written clients.
113func (c *FirewallPoliciesClient) setGoogleClientInfo(keyval ...string) {
114	c.internalClient.setGoogleClientInfo(keyval...)
115}
116
117// Connection returns a connection to the API service.
118//
119// Deprecated.
120func (c *FirewallPoliciesClient) Connection() *grpc.ClientConn {
121	return c.internalClient.Connection()
122}
123
124// AddAssociation inserts an association for the specified firewall policy.
125func (c *FirewallPoliciesClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
126	return c.internalClient.AddAssociation(ctx, req, opts...)
127}
128
129// AddRule inserts a rule into a firewall policy.
130func (c *FirewallPoliciesClient) AddRule(ctx context.Context, req *computepb.AddRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
131	return c.internalClient.AddRule(ctx, req, opts...)
132}
133
134// CloneRules copies rules to the specified firewall policy.
135func (c *FirewallPoliciesClient) CloneRules(ctx context.Context, req *computepb.CloneRulesFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
136	return c.internalClient.CloneRules(ctx, req, opts...)
137}
138
139// Delete deletes the specified policy.
140func (c *FirewallPoliciesClient) Delete(ctx context.Context, req *computepb.DeleteFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
141	return c.internalClient.Delete(ctx, req, opts...)
142}
143
144// Get returns the specified firewall policy.
145func (c *FirewallPoliciesClient) Get(ctx context.Context, req *computepb.GetFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error) {
146	return c.internalClient.Get(ctx, req, opts...)
147}
148
149// GetAssociation gets an association with the specified name.
150func (c *FirewallPoliciesClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) {
151	return c.internalClient.GetAssociation(ctx, req, opts...)
152}
153
154// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
155func (c *FirewallPoliciesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
156	return c.internalClient.GetIamPolicy(ctx, req, opts...)
157}
158
159// GetRule gets a rule of the specified priority.
160func (c *FirewallPoliciesClient) GetRule(ctx context.Context, req *computepb.GetRuleFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) {
161	return c.internalClient.GetRule(ctx, req, opts...)
162}
163
164// Insert creates a new policy in the specified project using the data included in the request.
165func (c *FirewallPoliciesClient) Insert(ctx context.Context, req *computepb.InsertFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
166	return c.internalClient.Insert(ctx, req, opts...)
167}
168
169// List lists all the policies that have been configured for the specified project.
170func (c *FirewallPoliciesClient) List(ctx context.Context, req *computepb.ListFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator {
171	return c.internalClient.List(ctx, req, opts...)
172}
173
174// ListAssociations lists associations of a specified target, i.e., organization or folder.
175func (c *FirewallPoliciesClient) ListAssociations(ctx context.Context, req *computepb.ListAssociationsFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPoliciesListAssociationsResponse, error) {
176	return c.internalClient.ListAssociations(ctx, req, opts...)
177}
178
179// Move moves the specified firewall policy.
180func (c *FirewallPoliciesClient) Move(ctx context.Context, req *computepb.MoveFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
181	return c.internalClient.Move(ctx, req, opts...)
182}
183
184// Patch patches the specified policy with the data included in the request.
185func (c *FirewallPoliciesClient) Patch(ctx context.Context, req *computepb.PatchFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
186	return c.internalClient.Patch(ctx, req, opts...)
187}
188
189// PatchRule patches a rule of the specified priority.
190func (c *FirewallPoliciesClient) PatchRule(ctx context.Context, req *computepb.PatchRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
191	return c.internalClient.PatchRule(ctx, req, opts...)
192}
193
194// RemoveAssociation removes an association for the specified firewall policy.
195func (c *FirewallPoliciesClient) RemoveAssociation(ctx context.Context, req *computepb.RemoveAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
196	return c.internalClient.RemoveAssociation(ctx, req, opts...)
197}
198
199// RemoveRule deletes a rule of the specified priority.
200func (c *FirewallPoliciesClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
201	return c.internalClient.RemoveRule(ctx, req, opts...)
202}
203
204// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
205func (c *FirewallPoliciesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
206	return c.internalClient.SetIamPolicy(ctx, req, opts...)
207}
208
209// TestIamPermissions returns permissions that a caller has on the specified resource.
210func (c *FirewallPoliciesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
211	return c.internalClient.TestIamPermissions(ctx, req, opts...)
212}
213
214// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
215type firewallPoliciesRESTClient struct {
216	// The http endpoint to connect to.
217	endpoint string
218
219	// The http client.
220	httpClient *http.Client
221
222	// The x-goog-* metadata to be sent with each request.
223	xGoogMetadata metadata.MD
224}
225
226// NewFirewallPoliciesRESTClient creates a new firewall policies rest client.
227//
228// The FirewallPolicies API.
229func NewFirewallPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*FirewallPoliciesClient, error) {
230	clientOpts := append(defaultFirewallPoliciesRESTClientOptions(), opts...)
231	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
232	if err != nil {
233		return nil, err
234	}
235
236	c := &firewallPoliciesRESTClient{
237		endpoint:   endpoint,
238		httpClient: httpClient,
239	}
240	c.setGoogleClientInfo()
241
242	return &FirewallPoliciesClient{internalClient: c, CallOptions: &FirewallPoliciesCallOptions{}}, nil
243}
244
245func defaultFirewallPoliciesRESTClientOptions() []option.ClientOption {
246	return []option.ClientOption{
247		internaloption.WithDefaultEndpoint("https://compute.googleapis.com"),
248		internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"),
249		internaloption.WithDefaultAudience("https://compute.googleapis.com/"),
250		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
251	}
252}
253
254// setGoogleClientInfo sets the name and version of the application in
255// the `x-goog-api-client` header passed on each request. Intended for
256// use by Google-written clients.
257func (c *firewallPoliciesRESTClient) setGoogleClientInfo(keyval ...string) {
258	kv := append([]string{"gl-go", versionGo()}, keyval...)
259	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "rest", "UNKNOWN")
260	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
261}
262
263// Close closes the connection to the API service. The user should invoke this when
264// the client is no longer required.
265func (c *firewallPoliciesRESTClient) Close() error {
266	// Replace httpClient with nil to force cleanup.
267	c.httpClient = nil
268	return nil
269}
270
271// Connection returns a connection to the API service.
272//
273// Deprecated.
274func (c *firewallPoliciesRESTClient) Connection() *grpc.ClientConn {
275	return nil
276}
277
278// AddAssociation inserts an association for the specified firewall policy.
279func (c *firewallPoliciesRESTClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
280	m := protojson.MarshalOptions{AllowPartial: true}
281	body := req.GetFirewallPolicyAssociationResource()
282	jsonReq, err := m.Marshal(body)
283	if err != nil {
284		return nil, err
285	}
286
287	baseUrl, _ := url.Parse(c.endpoint)
288	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/addAssociation", req.GetFirewallPolicy())
289
290	params := url.Values{}
291	if req != nil && req.ReplaceExistingAssociation != nil {
292		params.Add("replaceExistingAssociation", fmt.Sprintf("%v", req.GetReplaceExistingAssociation()))
293	}
294	if req != nil && req.RequestId != nil {
295		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
296	}
297
298	baseUrl.RawQuery = params.Encode()
299
300	httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
301	if err != nil {
302		return nil, err
303	}
304	httpReq = httpReq.WithContext(ctx)
305	// Set the headers
306	for k, v := range c.xGoogMetadata {
307		httpReq.Header[k] = v
308	}
309	httpReq.Header["Content-Type"] = []string{"application/json"}
310
311	httpRsp, err := c.httpClient.Do(httpReq)
312	if err != nil {
313		return nil, err
314	}
315	defer httpRsp.Body.Close()
316
317	if err = googleapi.CheckResponse(httpRsp); err != nil {
318		return nil, err
319	}
320
321	buf, err := ioutil.ReadAll(httpRsp.Body)
322	if err != nil {
323		return nil, err
324	}
325
326	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
327	rsp := &computepb.Operation{}
328
329	if err := unm.Unmarshal(buf, rsp); err != nil {
330		return nil, maybeUnknownEnum(err)
331	}
332	op := &Operation{proto: rsp}
333	return op, err
334}
335
336// AddRule inserts a rule into a firewall policy.
337func (c *firewallPoliciesRESTClient) AddRule(ctx context.Context, req *computepb.AddRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
338	m := protojson.MarshalOptions{AllowPartial: true}
339	body := req.GetFirewallPolicyRuleResource()
340	jsonReq, err := m.Marshal(body)
341	if err != nil {
342		return nil, err
343	}
344
345	baseUrl, _ := url.Parse(c.endpoint)
346	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/addRule", req.GetFirewallPolicy())
347
348	params := url.Values{}
349	if req != nil && req.RequestId != nil {
350		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
351	}
352
353	baseUrl.RawQuery = params.Encode()
354
355	httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
356	if err != nil {
357		return nil, err
358	}
359	httpReq = httpReq.WithContext(ctx)
360	// Set the headers
361	for k, v := range c.xGoogMetadata {
362		httpReq.Header[k] = v
363	}
364	httpReq.Header["Content-Type"] = []string{"application/json"}
365
366	httpRsp, err := c.httpClient.Do(httpReq)
367	if err != nil {
368		return nil, err
369	}
370	defer httpRsp.Body.Close()
371
372	if err = googleapi.CheckResponse(httpRsp); err != nil {
373		return nil, err
374	}
375
376	buf, err := ioutil.ReadAll(httpRsp.Body)
377	if err != nil {
378		return nil, err
379	}
380
381	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
382	rsp := &computepb.Operation{}
383
384	if err := unm.Unmarshal(buf, rsp); err != nil {
385		return nil, maybeUnknownEnum(err)
386	}
387	op := &Operation{proto: rsp}
388	return op, err
389}
390
391// CloneRules copies rules to the specified firewall policy.
392func (c *firewallPoliciesRESTClient) CloneRules(ctx context.Context, req *computepb.CloneRulesFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
393	baseUrl, _ := url.Parse(c.endpoint)
394	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/cloneRules", req.GetFirewallPolicy())
395
396	params := url.Values{}
397	if req != nil && req.RequestId != nil {
398		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
399	}
400	if req != nil && req.SourceFirewallPolicy != nil {
401		params.Add("sourceFirewallPolicy", fmt.Sprintf("%v", req.GetSourceFirewallPolicy()))
402	}
403
404	baseUrl.RawQuery = params.Encode()
405
406	httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
407	if err != nil {
408		return nil, err
409	}
410	httpReq = httpReq.WithContext(ctx)
411	// Set the headers
412	for k, v := range c.xGoogMetadata {
413		httpReq.Header[k] = v
414	}
415	httpReq.Header["Content-Type"] = []string{"application/json"}
416
417	httpRsp, err := c.httpClient.Do(httpReq)
418	if err != nil {
419		return nil, err
420	}
421	defer httpRsp.Body.Close()
422
423	if err = googleapi.CheckResponse(httpRsp); err != nil {
424		return nil, err
425	}
426
427	buf, err := ioutil.ReadAll(httpRsp.Body)
428	if err != nil {
429		return nil, err
430	}
431
432	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
433	rsp := &computepb.Operation{}
434
435	if err := unm.Unmarshal(buf, rsp); err != nil {
436		return nil, maybeUnknownEnum(err)
437	}
438	op := &Operation{proto: rsp}
439	return op, err
440}
441
442// Delete deletes the specified policy.
443func (c *firewallPoliciesRESTClient) Delete(ctx context.Context, req *computepb.DeleteFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
444	baseUrl, _ := url.Parse(c.endpoint)
445	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v", req.GetFirewallPolicy())
446
447	params := url.Values{}
448	if req != nil && req.RequestId != nil {
449		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
450	}
451
452	baseUrl.RawQuery = params.Encode()
453
454	httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
455	if err != nil {
456		return nil, err
457	}
458	httpReq = httpReq.WithContext(ctx)
459	// Set the headers
460	for k, v := range c.xGoogMetadata {
461		httpReq.Header[k] = v
462	}
463	httpReq.Header["Content-Type"] = []string{"application/json"}
464
465	httpRsp, err := c.httpClient.Do(httpReq)
466	if err != nil {
467		return nil, err
468	}
469	defer httpRsp.Body.Close()
470
471	if err = googleapi.CheckResponse(httpRsp); err != nil {
472		return nil, err
473	}
474
475	buf, err := ioutil.ReadAll(httpRsp.Body)
476	if err != nil {
477		return nil, err
478	}
479
480	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
481	rsp := &computepb.Operation{}
482
483	if err := unm.Unmarshal(buf, rsp); err != nil {
484		return nil, maybeUnknownEnum(err)
485	}
486	op := &Operation{proto: rsp}
487	return op, err
488}
489
490// Get returns the specified firewall policy.
491func (c *firewallPoliciesRESTClient) Get(ctx context.Context, req *computepb.GetFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error) {
492	baseUrl, _ := url.Parse(c.endpoint)
493	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v", req.GetFirewallPolicy())
494
495	httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
496	if err != nil {
497		return nil, err
498	}
499	httpReq = httpReq.WithContext(ctx)
500	// Set the headers
501	for k, v := range c.xGoogMetadata {
502		httpReq.Header[k] = v
503	}
504	httpReq.Header["Content-Type"] = []string{"application/json"}
505
506	httpRsp, err := c.httpClient.Do(httpReq)
507	if err != nil {
508		return nil, err
509	}
510	defer httpRsp.Body.Close()
511
512	if err = googleapi.CheckResponse(httpRsp); err != nil {
513		return nil, err
514	}
515
516	buf, err := ioutil.ReadAll(httpRsp.Body)
517	if err != nil {
518		return nil, err
519	}
520
521	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
522	rsp := &computepb.FirewallPolicy{}
523
524	if err := unm.Unmarshal(buf, rsp); err != nil {
525		return nil, maybeUnknownEnum(err)
526	}
527	return rsp, nil
528}
529
530// GetAssociation gets an association with the specified name.
531func (c *firewallPoliciesRESTClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error) {
532	baseUrl, _ := url.Parse(c.endpoint)
533	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/getAssociation", req.GetFirewallPolicy())
534
535	params := url.Values{}
536	if req != nil && req.Name != nil {
537		params.Add("name", fmt.Sprintf("%v", req.GetName()))
538	}
539
540	baseUrl.RawQuery = params.Encode()
541
542	httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
543	if err != nil {
544		return nil, err
545	}
546	httpReq = httpReq.WithContext(ctx)
547	// Set the headers
548	for k, v := range c.xGoogMetadata {
549		httpReq.Header[k] = v
550	}
551	httpReq.Header["Content-Type"] = []string{"application/json"}
552
553	httpRsp, err := c.httpClient.Do(httpReq)
554	if err != nil {
555		return nil, err
556	}
557	defer httpRsp.Body.Close()
558
559	if err = googleapi.CheckResponse(httpRsp); err != nil {
560		return nil, err
561	}
562
563	buf, err := ioutil.ReadAll(httpRsp.Body)
564	if err != nil {
565		return nil, err
566	}
567
568	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
569	rsp := &computepb.FirewallPolicyAssociation{}
570
571	if err := unm.Unmarshal(buf, rsp); err != nil {
572		return nil, maybeUnknownEnum(err)
573	}
574	return rsp, nil
575}
576
577// GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
578func (c *firewallPoliciesRESTClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
579	baseUrl, _ := url.Parse(c.endpoint)
580	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/getIamPolicy", req.GetResource())
581
582	params := url.Values{}
583	if req != nil && req.OptionsRequestedPolicyVersion != nil {
584		params.Add("optionsRequestedPolicyVersion", fmt.Sprintf("%v", req.GetOptionsRequestedPolicyVersion()))
585	}
586
587	baseUrl.RawQuery = params.Encode()
588
589	httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
590	if err != nil {
591		return nil, err
592	}
593	httpReq = httpReq.WithContext(ctx)
594	// Set the headers
595	for k, v := range c.xGoogMetadata {
596		httpReq.Header[k] = v
597	}
598	httpReq.Header["Content-Type"] = []string{"application/json"}
599
600	httpRsp, err := c.httpClient.Do(httpReq)
601	if err != nil {
602		return nil, err
603	}
604	defer httpRsp.Body.Close()
605
606	if err = googleapi.CheckResponse(httpRsp); err != nil {
607		return nil, err
608	}
609
610	buf, err := ioutil.ReadAll(httpRsp.Body)
611	if err != nil {
612		return nil, err
613	}
614
615	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
616	rsp := &computepb.Policy{}
617
618	if err := unm.Unmarshal(buf, rsp); err != nil {
619		return nil, maybeUnknownEnum(err)
620	}
621	return rsp, nil
622}
623
624// GetRule gets a rule of the specified priority.
625func (c *firewallPoliciesRESTClient) GetRule(ctx context.Context, req *computepb.GetRuleFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error) {
626	baseUrl, _ := url.Parse(c.endpoint)
627	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/getRule", req.GetFirewallPolicy())
628
629	params := url.Values{}
630	if req != nil && req.Priority != nil {
631		params.Add("priority", fmt.Sprintf("%v", req.GetPriority()))
632	}
633
634	baseUrl.RawQuery = params.Encode()
635
636	httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
637	if err != nil {
638		return nil, err
639	}
640	httpReq = httpReq.WithContext(ctx)
641	// Set the headers
642	for k, v := range c.xGoogMetadata {
643		httpReq.Header[k] = v
644	}
645	httpReq.Header["Content-Type"] = []string{"application/json"}
646
647	httpRsp, err := c.httpClient.Do(httpReq)
648	if err != nil {
649		return nil, err
650	}
651	defer httpRsp.Body.Close()
652
653	if err = googleapi.CheckResponse(httpRsp); err != nil {
654		return nil, err
655	}
656
657	buf, err := ioutil.ReadAll(httpRsp.Body)
658	if err != nil {
659		return nil, err
660	}
661
662	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
663	rsp := &computepb.FirewallPolicyRule{}
664
665	if err := unm.Unmarshal(buf, rsp); err != nil {
666		return nil, maybeUnknownEnum(err)
667	}
668	return rsp, nil
669}
670
671// Insert creates a new policy in the specified project using the data included in the request.
672func (c *firewallPoliciesRESTClient) Insert(ctx context.Context, req *computepb.InsertFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
673	m := protojson.MarshalOptions{AllowPartial: true}
674	body := req.GetFirewallPolicyResource()
675	jsonReq, err := m.Marshal(body)
676	if err != nil {
677		return nil, err
678	}
679
680	baseUrl, _ := url.Parse(c.endpoint)
681	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies")
682
683	params := url.Values{}
684	if req != nil && req.ParentId != nil {
685		params.Add("parentId", fmt.Sprintf("%v", req.GetParentId()))
686	}
687	if req != nil && req.RequestId != nil {
688		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
689	}
690
691	baseUrl.RawQuery = params.Encode()
692
693	httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
694	if err != nil {
695		return nil, err
696	}
697	httpReq = httpReq.WithContext(ctx)
698	// Set the headers
699	for k, v := range c.xGoogMetadata {
700		httpReq.Header[k] = v
701	}
702	httpReq.Header["Content-Type"] = []string{"application/json"}
703
704	httpRsp, err := c.httpClient.Do(httpReq)
705	if err != nil {
706		return nil, err
707	}
708	defer httpRsp.Body.Close()
709
710	if err = googleapi.CheckResponse(httpRsp); err != nil {
711		return nil, err
712	}
713
714	buf, err := ioutil.ReadAll(httpRsp.Body)
715	if err != nil {
716		return nil, err
717	}
718
719	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
720	rsp := &computepb.Operation{}
721
722	if err := unm.Unmarshal(buf, rsp); err != nil {
723		return nil, maybeUnknownEnum(err)
724	}
725	op := &Operation{proto: rsp}
726	return op, err
727}
728
729// List lists all the policies that have been configured for the specified project.
730func (c *firewallPoliciesRESTClient) List(ctx context.Context, req *computepb.ListFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator {
731	it := &FirewallPolicyIterator{}
732	req = proto.Clone(req).(*computepb.ListFirewallPoliciesRequest)
733	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
734	it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.FirewallPolicy, string, error) {
735		resp := &computepb.FirewallPolicyList{}
736		if pageToken != "" {
737			req.PageToken = proto.String(pageToken)
738		}
739		if pageSize > math.MaxInt32 {
740			req.MaxResults = proto.Uint32(math.MaxInt32)
741		} else if pageSize != 0 {
742			req.MaxResults = proto.Uint32(uint32(pageSize))
743		}
744		baseUrl, _ := url.Parse(c.endpoint)
745		baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies")
746
747		params := url.Values{}
748		if req != nil && req.Filter != nil {
749			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
750		}
751		if req != nil && req.MaxResults != nil {
752			params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults()))
753		}
754		if req != nil && req.OrderBy != nil {
755			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
756		}
757		if req != nil && req.PageToken != nil {
758			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
759		}
760		if req != nil && req.ParentId != nil {
761			params.Add("parentId", fmt.Sprintf("%v", req.GetParentId()))
762		}
763		if req != nil && req.ReturnPartialSuccess != nil {
764			params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess()))
765		}
766
767		baseUrl.RawQuery = params.Encode()
768
769		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
770		if err != nil {
771			return nil, "", err
772		}
773
774		// Set the headers
775		for k, v := range c.xGoogMetadata {
776			httpReq.Header[k] = v
777		}
778
779		httpReq.Header["Content-Type"] = []string{"application/json"}
780		httpRsp, err := c.httpClient.Do(httpReq)
781		if err != nil {
782			return nil, "", err
783		}
784		defer httpRsp.Body.Close()
785
786		if err = googleapi.CheckResponse(httpRsp); err != nil {
787			return nil, "", err
788		}
789
790		buf, err := ioutil.ReadAll(httpRsp.Body)
791		if err != nil {
792			return nil, "", err
793		}
794
795		unm.Unmarshal(buf, resp)
796		it.Response = resp
797		return resp.GetItems(), resp.GetNextPageToken(), nil
798	}
799
800	fetch := func(pageSize int, pageToken string) (string, error) {
801		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
802		if err != nil {
803			return "", err
804		}
805		it.items = append(it.items, items...)
806		return nextPageToken, nil
807	}
808
809	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
810	it.pageInfo.MaxSize = int(req.GetMaxResults())
811	it.pageInfo.Token = req.GetPageToken()
812
813	return it
814}
815
816// ListAssociations lists associations of a specified target, i.e., organization or folder.
817func (c *firewallPoliciesRESTClient) ListAssociations(ctx context.Context, req *computepb.ListAssociationsFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPoliciesListAssociationsResponse, error) {
818	baseUrl, _ := url.Parse(c.endpoint)
819	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/listAssociations")
820
821	params := url.Values{}
822	if req != nil && req.TargetResource != nil {
823		params.Add("targetResource", fmt.Sprintf("%v", req.GetTargetResource()))
824	}
825
826	baseUrl.RawQuery = params.Encode()
827
828	httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
829	if err != nil {
830		return nil, err
831	}
832	httpReq = httpReq.WithContext(ctx)
833	// Set the headers
834	for k, v := range c.xGoogMetadata {
835		httpReq.Header[k] = v
836	}
837	httpReq.Header["Content-Type"] = []string{"application/json"}
838
839	httpRsp, err := c.httpClient.Do(httpReq)
840	if err != nil {
841		return nil, err
842	}
843	defer httpRsp.Body.Close()
844
845	if err = googleapi.CheckResponse(httpRsp); err != nil {
846		return nil, err
847	}
848
849	buf, err := ioutil.ReadAll(httpRsp.Body)
850	if err != nil {
851		return nil, err
852	}
853
854	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
855	rsp := &computepb.FirewallPoliciesListAssociationsResponse{}
856
857	if err := unm.Unmarshal(buf, rsp); err != nil {
858		return nil, maybeUnknownEnum(err)
859	}
860	return rsp, nil
861}
862
863// Move moves the specified firewall policy.
864func (c *firewallPoliciesRESTClient) Move(ctx context.Context, req *computepb.MoveFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
865	baseUrl, _ := url.Parse(c.endpoint)
866	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/move", req.GetFirewallPolicy())
867
868	params := url.Values{}
869	if req != nil && req.ParentId != nil {
870		params.Add("parentId", fmt.Sprintf("%v", req.GetParentId()))
871	}
872	if req != nil && req.RequestId != nil {
873		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
874	}
875
876	baseUrl.RawQuery = params.Encode()
877
878	httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
879	if err != nil {
880		return nil, err
881	}
882	httpReq = httpReq.WithContext(ctx)
883	// Set the headers
884	for k, v := range c.xGoogMetadata {
885		httpReq.Header[k] = v
886	}
887	httpReq.Header["Content-Type"] = []string{"application/json"}
888
889	httpRsp, err := c.httpClient.Do(httpReq)
890	if err != nil {
891		return nil, err
892	}
893	defer httpRsp.Body.Close()
894
895	if err = googleapi.CheckResponse(httpRsp); err != nil {
896		return nil, err
897	}
898
899	buf, err := ioutil.ReadAll(httpRsp.Body)
900	if err != nil {
901		return nil, err
902	}
903
904	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
905	rsp := &computepb.Operation{}
906
907	if err := unm.Unmarshal(buf, rsp); err != nil {
908		return nil, maybeUnknownEnum(err)
909	}
910	op := &Operation{proto: rsp}
911	return op, err
912}
913
914// Patch patches the specified policy with the data included in the request.
915func (c *firewallPoliciesRESTClient) Patch(ctx context.Context, req *computepb.PatchFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
916	m := protojson.MarshalOptions{AllowPartial: true}
917	body := req.GetFirewallPolicyResource()
918	jsonReq, err := m.Marshal(body)
919	if err != nil {
920		return nil, err
921	}
922
923	baseUrl, _ := url.Parse(c.endpoint)
924	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v", req.GetFirewallPolicy())
925
926	params := url.Values{}
927	if req != nil && req.RequestId != nil {
928		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
929	}
930
931	baseUrl.RawQuery = params.Encode()
932
933	httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
934	if err != nil {
935		return nil, err
936	}
937	httpReq = httpReq.WithContext(ctx)
938	// Set the headers
939	for k, v := range c.xGoogMetadata {
940		httpReq.Header[k] = v
941	}
942	httpReq.Header["Content-Type"] = []string{"application/json"}
943
944	httpRsp, err := c.httpClient.Do(httpReq)
945	if err != nil {
946		return nil, err
947	}
948	defer httpRsp.Body.Close()
949
950	if err = googleapi.CheckResponse(httpRsp); err != nil {
951		return nil, err
952	}
953
954	buf, err := ioutil.ReadAll(httpRsp.Body)
955	if err != nil {
956		return nil, err
957	}
958
959	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
960	rsp := &computepb.Operation{}
961
962	if err := unm.Unmarshal(buf, rsp); err != nil {
963		return nil, maybeUnknownEnum(err)
964	}
965	op := &Operation{proto: rsp}
966	return op, err
967}
968
969// PatchRule patches a rule of the specified priority.
970func (c *firewallPoliciesRESTClient) PatchRule(ctx context.Context, req *computepb.PatchRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
971	m := protojson.MarshalOptions{AllowPartial: true}
972	body := req.GetFirewallPolicyRuleResource()
973	jsonReq, err := m.Marshal(body)
974	if err != nil {
975		return nil, err
976	}
977
978	baseUrl, _ := url.Parse(c.endpoint)
979	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/patchRule", req.GetFirewallPolicy())
980
981	params := url.Values{}
982	if req != nil && req.Priority != nil {
983		params.Add("priority", fmt.Sprintf("%v", req.GetPriority()))
984	}
985	if req != nil && req.RequestId != nil {
986		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
987	}
988
989	baseUrl.RawQuery = params.Encode()
990
991	httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
992	if err != nil {
993		return nil, err
994	}
995	httpReq = httpReq.WithContext(ctx)
996	// Set the headers
997	for k, v := range c.xGoogMetadata {
998		httpReq.Header[k] = v
999	}
1000	httpReq.Header["Content-Type"] = []string{"application/json"}
1001
1002	httpRsp, err := c.httpClient.Do(httpReq)
1003	if err != nil {
1004		return nil, err
1005	}
1006	defer httpRsp.Body.Close()
1007
1008	if err = googleapi.CheckResponse(httpRsp); err != nil {
1009		return nil, err
1010	}
1011
1012	buf, err := ioutil.ReadAll(httpRsp.Body)
1013	if err != nil {
1014		return nil, err
1015	}
1016
1017	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1018	rsp := &computepb.Operation{}
1019
1020	if err := unm.Unmarshal(buf, rsp); err != nil {
1021		return nil, maybeUnknownEnum(err)
1022	}
1023	op := &Operation{proto: rsp}
1024	return op, err
1025}
1026
1027// RemoveAssociation removes an association for the specified firewall policy.
1028func (c *firewallPoliciesRESTClient) RemoveAssociation(ctx context.Context, req *computepb.RemoveAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
1029	baseUrl, _ := url.Parse(c.endpoint)
1030	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/removeAssociation", req.GetFirewallPolicy())
1031
1032	params := url.Values{}
1033	if req != nil && req.Name != nil {
1034		params.Add("name", fmt.Sprintf("%v", req.GetName()))
1035	}
1036	if req != nil && req.RequestId != nil {
1037		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1038	}
1039
1040	baseUrl.RawQuery = params.Encode()
1041
1042	httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
1043	if err != nil {
1044		return nil, err
1045	}
1046	httpReq = httpReq.WithContext(ctx)
1047	// Set the headers
1048	for k, v := range c.xGoogMetadata {
1049		httpReq.Header[k] = v
1050	}
1051	httpReq.Header["Content-Type"] = []string{"application/json"}
1052
1053	httpRsp, err := c.httpClient.Do(httpReq)
1054	if err != nil {
1055		return nil, err
1056	}
1057	defer httpRsp.Body.Close()
1058
1059	if err = googleapi.CheckResponse(httpRsp); err != nil {
1060		return nil, err
1061	}
1062
1063	buf, err := ioutil.ReadAll(httpRsp.Body)
1064	if err != nil {
1065		return nil, err
1066	}
1067
1068	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1069	rsp := &computepb.Operation{}
1070
1071	if err := unm.Unmarshal(buf, rsp); err != nil {
1072		return nil, maybeUnknownEnum(err)
1073	}
1074	op := &Operation{proto: rsp}
1075	return op, err
1076}
1077
1078// RemoveRule deletes a rule of the specified priority.
1079func (c *firewallPoliciesRESTClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error) {
1080	baseUrl, _ := url.Parse(c.endpoint)
1081	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/removeRule", req.GetFirewallPolicy())
1082
1083	params := url.Values{}
1084	if req != nil && req.Priority != nil {
1085		params.Add("priority", fmt.Sprintf("%v", req.GetPriority()))
1086	}
1087	if req != nil && req.RequestId != nil {
1088		params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
1089	}
1090
1091	baseUrl.RawQuery = params.Encode()
1092
1093	httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
1094	if err != nil {
1095		return nil, err
1096	}
1097	httpReq = httpReq.WithContext(ctx)
1098	// Set the headers
1099	for k, v := range c.xGoogMetadata {
1100		httpReq.Header[k] = v
1101	}
1102	httpReq.Header["Content-Type"] = []string{"application/json"}
1103
1104	httpRsp, err := c.httpClient.Do(httpReq)
1105	if err != nil {
1106		return nil, err
1107	}
1108	defer httpRsp.Body.Close()
1109
1110	if err = googleapi.CheckResponse(httpRsp); err != nil {
1111		return nil, err
1112	}
1113
1114	buf, err := ioutil.ReadAll(httpRsp.Body)
1115	if err != nil {
1116		return nil, err
1117	}
1118
1119	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1120	rsp := &computepb.Operation{}
1121
1122	if err := unm.Unmarshal(buf, rsp); err != nil {
1123		return nil, maybeUnknownEnum(err)
1124	}
1125	op := &Operation{proto: rsp}
1126	return op, err
1127}
1128
1129// SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
1130func (c *firewallPoliciesRESTClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error) {
1131	m := protojson.MarshalOptions{AllowPartial: true}
1132	body := req.GetGlobalOrganizationSetPolicyRequestResource()
1133	jsonReq, err := m.Marshal(body)
1134	if err != nil {
1135		return nil, err
1136	}
1137
1138	baseUrl, _ := url.Parse(c.endpoint)
1139	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/setIamPolicy", req.GetResource())
1140
1141	httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1142	if err != nil {
1143		return nil, err
1144	}
1145	httpReq = httpReq.WithContext(ctx)
1146	// Set the headers
1147	for k, v := range c.xGoogMetadata {
1148		httpReq.Header[k] = v
1149	}
1150	httpReq.Header["Content-Type"] = []string{"application/json"}
1151
1152	httpRsp, err := c.httpClient.Do(httpReq)
1153	if err != nil {
1154		return nil, err
1155	}
1156	defer httpRsp.Body.Close()
1157
1158	if err = googleapi.CheckResponse(httpRsp); err != nil {
1159		return nil, err
1160	}
1161
1162	buf, err := ioutil.ReadAll(httpRsp.Body)
1163	if err != nil {
1164		return nil, err
1165	}
1166
1167	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1168	rsp := &computepb.Policy{}
1169
1170	if err := unm.Unmarshal(buf, rsp); err != nil {
1171		return nil, maybeUnknownEnum(err)
1172	}
1173	return rsp, nil
1174}
1175
1176// TestIamPermissions returns permissions that a caller has on the specified resource.
1177func (c *firewallPoliciesRESTClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error) {
1178	m := protojson.MarshalOptions{AllowPartial: true}
1179	body := req.GetTestPermissionsRequestResource()
1180	jsonReq, err := m.Marshal(body)
1181	if err != nil {
1182		return nil, err
1183	}
1184
1185	baseUrl, _ := url.Parse(c.endpoint)
1186	baseUrl.Path += fmt.Sprintf("/compute/v1/locations/global/firewallPolicies/%v/testIamPermissions", req.GetResource())
1187
1188	httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1189	if err != nil {
1190		return nil, err
1191	}
1192	httpReq = httpReq.WithContext(ctx)
1193	// Set the headers
1194	for k, v := range c.xGoogMetadata {
1195		httpReq.Header[k] = v
1196	}
1197	httpReq.Header["Content-Type"] = []string{"application/json"}
1198
1199	httpRsp, err := c.httpClient.Do(httpReq)
1200	if err != nil {
1201		return nil, err
1202	}
1203	defer httpRsp.Body.Close()
1204
1205	if err = googleapi.CheckResponse(httpRsp); err != nil {
1206		return nil, err
1207	}
1208
1209	buf, err := ioutil.ReadAll(httpRsp.Body)
1210	if err != nil {
1211		return nil, err
1212	}
1213
1214	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1215	rsp := &computepb.TestPermissionsResponse{}
1216
1217	if err := unm.Unmarshal(buf, rsp); err != nil {
1218		return nil, maybeUnknownEnum(err)
1219	}
1220	return rsp, nil
1221}
1222
1223// FirewallPolicyIterator manages a stream of *computepb.FirewallPolicy.
1224type FirewallPolicyIterator struct {
1225	items    []*computepb.FirewallPolicy
1226	pageInfo *iterator.PageInfo
1227	nextFunc func() error
1228
1229	// Response is the raw response for the current page.
1230	// It must be cast to the RPC response type.
1231	// Calling Next() or InternalFetch() updates this value.
1232	Response interface{}
1233
1234	// InternalFetch is for use by the Google Cloud Libraries only.
1235	// It is not part of the stable interface of this package.
1236	//
1237	// InternalFetch returns results from a single call to the underlying RPC.
1238	// The number of results is no greater than pageSize.
1239	// If there are no more results, nextPageToken is empty and err is nil.
1240	InternalFetch func(pageSize int, pageToken string) (results []*computepb.FirewallPolicy, nextPageToken string, err error)
1241}
1242
1243// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1244func (it *FirewallPolicyIterator) PageInfo() *iterator.PageInfo {
1245	return it.pageInfo
1246}
1247
1248// Next returns the next result. Its second return value is iterator.Done if there are no more
1249// results. Once Next returns Done, all subsequent calls will return Done.
1250func (it *FirewallPolicyIterator) Next() (*computepb.FirewallPolicy, error) {
1251	var item *computepb.FirewallPolicy
1252	if err := it.nextFunc(); err != nil {
1253		return item, err
1254	}
1255	item = it.items[0]
1256	it.items = it.items[1:]
1257	return item, nil
1258}
1259
1260func (it *FirewallPolicyIterator) bufLen() int {
1261	return len(it.items)
1262}
1263
1264func (it *FirewallPolicyIterator) takeBuf() interface{} {
1265	b := it.items
1266	it.items = nil
1267	return b
1268}
1269