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 "sort" 28 29 gax "github.com/googleapis/gax-go/v2" 30 "google.golang.org/api/googleapi" 31 "google.golang.org/api/iterator" 32 "google.golang.org/api/option" 33 "google.golang.org/api/option/internaloption" 34 httptransport "google.golang.org/api/transport/http" 35 computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" 36 "google.golang.org/grpc" 37 "google.golang.org/grpc/metadata" 38 "google.golang.org/protobuf/encoding/protojson" 39 "google.golang.org/protobuf/proto" 40) 41 42var newTargetHttpsProxiesClientHook clientHook 43 44// TargetHttpsProxiesCallOptions contains the retry settings for each method of TargetHttpsProxiesClient. 45type TargetHttpsProxiesCallOptions struct { 46 AggregatedList []gax.CallOption 47 Delete []gax.CallOption 48 Get []gax.CallOption 49 Insert []gax.CallOption 50 List []gax.CallOption 51 Patch []gax.CallOption 52 SetQuicOverride []gax.CallOption 53 SetSslCertificates []gax.CallOption 54 SetSslPolicy []gax.CallOption 55 SetUrlMap []gax.CallOption 56} 57 58// internalTargetHttpsProxiesClient is an interface that defines the methods availaible from Google Compute Engine API. 59type internalTargetHttpsProxiesClient interface { 60 Close() error 61 setGoogleClientInfo(...string) 62 Connection() *grpc.ClientConn 63 AggregatedList(context.Context, *computepb.AggregatedListTargetHttpsProxiesRequest, ...gax.CallOption) *TargetHttpsProxiesScopedListPairIterator 64 Delete(context.Context, *computepb.DeleteTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) 65 Get(context.Context, *computepb.GetTargetHttpsProxyRequest, ...gax.CallOption) (*computepb.TargetHttpsProxy, error) 66 Insert(context.Context, *computepb.InsertTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) 67 List(context.Context, *computepb.ListTargetHttpsProxiesRequest, ...gax.CallOption) *TargetHttpsProxyIterator 68 Patch(context.Context, *computepb.PatchTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) 69 SetQuicOverride(context.Context, *computepb.SetQuicOverrideTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) 70 SetSslCertificates(context.Context, *computepb.SetSslCertificatesTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) 71 SetSslPolicy(context.Context, *computepb.SetSslPolicyTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) 72 SetUrlMap(context.Context, *computepb.SetUrlMapTargetHttpsProxyRequest, ...gax.CallOption) (*Operation, error) 73} 74 75// TargetHttpsProxiesClient is a client for interacting with Google Compute Engine API. 76// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 77// 78// The TargetHttpsProxies API. 79type TargetHttpsProxiesClient struct { 80 // The internal transport-dependent client. 81 internalClient internalTargetHttpsProxiesClient 82 83 // The call options for this service. 84 CallOptions *TargetHttpsProxiesCallOptions 85} 86 87// Wrapper methods routed to the internal client. 88 89// Close closes the connection to the API service. The user should invoke this when 90// the client is no longer required. 91func (c *TargetHttpsProxiesClient) Close() error { 92 return c.internalClient.Close() 93} 94 95// setGoogleClientInfo sets the name and version of the application in 96// the `x-goog-api-client` header passed on each request. Intended for 97// use by Google-written clients. 98func (c *TargetHttpsProxiesClient) setGoogleClientInfo(keyval ...string) { 99 c.internalClient.setGoogleClientInfo(keyval...) 100} 101 102// Connection returns a connection to the API service. 103// 104// Deprecated. 105func (c *TargetHttpsProxiesClient) Connection() *grpc.ClientConn { 106 return c.internalClient.Connection() 107} 108 109// AggregatedList retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project. 110func (c *TargetHttpsProxiesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListTargetHttpsProxiesRequest, opts ...gax.CallOption) *TargetHttpsProxiesScopedListPairIterator { 111 return c.internalClient.AggregatedList(ctx, req, opts...) 112} 113 114// Delete deletes the specified TargetHttpsProxy resource. 115func (c *TargetHttpsProxiesClient) Delete(ctx context.Context, req *computepb.DeleteTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 116 return c.internalClient.Delete(ctx, req, opts...) 117} 118 119// Get returns the specified TargetHttpsProxy resource. Gets a list of available target HTTPS proxies by making a list() request. 120func (c *TargetHttpsProxiesClient) Get(ctx context.Context, req *computepb.GetTargetHttpsProxyRequest, opts ...gax.CallOption) (*computepb.TargetHttpsProxy, error) { 121 return c.internalClient.Get(ctx, req, opts...) 122} 123 124// Insert creates a TargetHttpsProxy resource in the specified project using the data included in the request. 125func (c *TargetHttpsProxiesClient) Insert(ctx context.Context, req *computepb.InsertTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 126 return c.internalClient.Insert(ctx, req, opts...) 127} 128 129// List retrieves the list of TargetHttpsProxy resources available to the specified project. 130func (c *TargetHttpsProxiesClient) List(ctx context.Context, req *computepb.ListTargetHttpsProxiesRequest, opts ...gax.CallOption) *TargetHttpsProxyIterator { 131 return c.internalClient.List(ctx, req, opts...) 132} 133 134// Patch patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. (== suppress_warning http-rest-shadowed ==) 135func (c *TargetHttpsProxiesClient) Patch(ctx context.Context, req *computepb.PatchTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 136 return c.internalClient.Patch(ctx, req, opts...) 137} 138 139// SetQuicOverride sets the QUIC override policy for TargetHttpsProxy. 140func (c *TargetHttpsProxiesClient) SetQuicOverride(ctx context.Context, req *computepb.SetQuicOverrideTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 141 return c.internalClient.SetQuicOverride(ctx, req, opts...) 142} 143 144// SetSslCertificates replaces SslCertificates for TargetHttpsProxy. 145func (c *TargetHttpsProxiesClient) SetSslCertificates(ctx context.Context, req *computepb.SetSslCertificatesTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 146 return c.internalClient.SetSslCertificates(ctx, req, opts...) 147} 148 149// SetSslPolicy sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends. 150func (c *TargetHttpsProxiesClient) SetSslPolicy(ctx context.Context, req *computepb.SetSslPolicyTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 151 return c.internalClient.SetSslPolicy(ctx, req, opts...) 152} 153 154// SetUrlMap changes the URL map for TargetHttpsProxy. 155func (c *TargetHttpsProxiesClient) SetUrlMap(ctx context.Context, req *computepb.SetUrlMapTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 156 return c.internalClient.SetUrlMap(ctx, req, opts...) 157} 158 159// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 160type targetHttpsProxiesRESTClient struct { 161 // The http endpoint to connect to. 162 endpoint string 163 164 // The http client. 165 httpClient *http.Client 166 167 // The x-goog-* metadata to be sent with each request. 168 xGoogMetadata metadata.MD 169} 170 171// NewTargetHttpsProxiesRESTClient creates a new target https proxies rest client. 172// 173// The TargetHttpsProxies API. 174func NewTargetHttpsProxiesRESTClient(ctx context.Context, opts ...option.ClientOption) (*TargetHttpsProxiesClient, error) { 175 clientOpts := append(defaultTargetHttpsProxiesRESTClientOptions(), opts...) 176 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) 177 if err != nil { 178 return nil, err 179 } 180 181 c := &targetHttpsProxiesRESTClient{ 182 endpoint: endpoint, 183 httpClient: httpClient, 184 } 185 c.setGoogleClientInfo() 186 187 return &TargetHttpsProxiesClient{internalClient: c, CallOptions: &TargetHttpsProxiesCallOptions{}}, nil 188} 189 190func defaultTargetHttpsProxiesRESTClientOptions() []option.ClientOption { 191 return []option.ClientOption{ 192 internaloption.WithDefaultEndpoint("https://compute.googleapis.com"), 193 internaloption.WithDefaultMTLSEndpoint("https://compute.mtls.googleapis.com"), 194 internaloption.WithDefaultAudience("https://compute.googleapis.com/"), 195 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 196 } 197} 198 199// setGoogleClientInfo sets the name and version of the application in 200// the `x-goog-api-client` header passed on each request. Intended for 201// use by Google-written clients. 202func (c *targetHttpsProxiesRESTClient) setGoogleClientInfo(keyval ...string) { 203 kv := append([]string{"gl-go", versionGo()}, keyval...) 204 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "rest", "UNKNOWN") 205 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 206} 207 208// Close closes the connection to the API service. The user should invoke this when 209// the client is no longer required. 210func (c *targetHttpsProxiesRESTClient) Close() error { 211 // Replace httpClient with nil to force cleanup. 212 c.httpClient = nil 213 return nil 214} 215 216// Connection returns a connection to the API service. 217// 218// Deprecated. 219func (c *targetHttpsProxiesRESTClient) Connection() *grpc.ClientConn { 220 return nil 221} 222 223// AggregatedList retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project. 224func (c *targetHttpsProxiesRESTClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListTargetHttpsProxiesRequest, opts ...gax.CallOption) *TargetHttpsProxiesScopedListPairIterator { 225 it := &TargetHttpsProxiesScopedListPairIterator{} 226 req = proto.Clone(req).(*computepb.AggregatedListTargetHttpsProxiesRequest) 227 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 228 it.InternalFetch = func(pageSize int, pageToken string) ([]TargetHttpsProxiesScopedListPair, string, error) { 229 resp := &computepb.TargetHttpsProxyAggregatedList{} 230 if pageToken != "" { 231 req.PageToken = proto.String(pageToken) 232 } 233 if pageSize > math.MaxInt32 { 234 req.MaxResults = proto.Uint32(math.MaxInt32) 235 } else if pageSize != 0 { 236 req.MaxResults = proto.Uint32(uint32(pageSize)) 237 } 238 baseUrl, _ := url.Parse(c.endpoint) 239 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/aggregated/targetHttpsProxies", req.GetProject()) 240 241 params := url.Values{} 242 if req != nil && req.Filter != nil { 243 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 244 } 245 if req != nil && req.IncludeAllScopes != nil { 246 params.Add("includeAllScopes", fmt.Sprintf("%v", req.GetIncludeAllScopes())) 247 } 248 if req != nil && req.MaxResults != nil { 249 params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults())) 250 } 251 if req != nil && req.OrderBy != nil { 252 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) 253 } 254 if req != nil && req.PageToken != nil { 255 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 256 } 257 if req != nil && req.ReturnPartialSuccess != nil { 258 params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess())) 259 } 260 261 baseUrl.RawQuery = params.Encode() 262 263 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 264 if err != nil { 265 return nil, "", err 266 } 267 268 // Set the headers 269 for k, v := range c.xGoogMetadata { 270 httpReq.Header[k] = v 271 } 272 273 httpReq.Header["Content-Type"] = []string{"application/json"} 274 httpRsp, err := c.httpClient.Do(httpReq) 275 if err != nil { 276 return nil, "", err 277 } 278 defer httpRsp.Body.Close() 279 280 if err = googleapi.CheckResponse(httpRsp); err != nil { 281 return nil, "", err 282 } 283 284 buf, err := ioutil.ReadAll(httpRsp.Body) 285 if err != nil { 286 return nil, "", err 287 } 288 289 unm.Unmarshal(buf, resp) 290 it.Response = resp 291 292 elems := make([]TargetHttpsProxiesScopedListPair, 0, len(resp.GetItems())) 293 for k, v := range resp.GetItems() { 294 elems = append(elems, TargetHttpsProxiesScopedListPair{k, v}) 295 } 296 sort.Slice(elems, func(i, j int) bool { return elems[i].Key < elems[j].Key }) 297 298 return elems, resp.GetNextPageToken(), nil 299 } 300 301 fetch := func(pageSize int, pageToken string) (string, error) { 302 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 303 if err != nil { 304 return "", err 305 } 306 it.items = append(it.items, items...) 307 return nextPageToken, nil 308 } 309 310 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 311 it.pageInfo.MaxSize = int(req.GetMaxResults()) 312 it.pageInfo.Token = req.GetPageToken() 313 314 return it 315} 316 317// Delete deletes the specified TargetHttpsProxy resource. 318func (c *targetHttpsProxiesRESTClient) Delete(ctx context.Context, req *computepb.DeleteTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 319 baseUrl, _ := url.Parse(c.endpoint) 320 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/targetHttpsProxies/%v", req.GetProject(), req.GetTargetHttpsProxy()) 321 322 params := url.Values{} 323 if req != nil && req.RequestId != nil { 324 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) 325 } 326 327 baseUrl.RawQuery = params.Encode() 328 329 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 330 if err != nil { 331 return nil, err 332 } 333 httpReq = httpReq.WithContext(ctx) 334 // Set the headers 335 for k, v := range c.xGoogMetadata { 336 httpReq.Header[k] = v 337 } 338 httpReq.Header["Content-Type"] = []string{"application/json"} 339 340 httpRsp, err := c.httpClient.Do(httpReq) 341 if err != nil { 342 return nil, err 343 } 344 defer httpRsp.Body.Close() 345 346 if err = googleapi.CheckResponse(httpRsp); err != nil { 347 return nil, err 348 } 349 350 buf, err := ioutil.ReadAll(httpRsp.Body) 351 if err != nil { 352 return nil, err 353 } 354 355 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 356 rsp := &computepb.Operation{} 357 358 if err := unm.Unmarshal(buf, rsp); err != nil { 359 return nil, maybeUnknownEnum(err) 360 } 361 op := &Operation{proto: rsp} 362 return op, err 363} 364 365// Get returns the specified TargetHttpsProxy resource. Gets a list of available target HTTPS proxies by making a list() request. 366func (c *targetHttpsProxiesRESTClient) Get(ctx context.Context, req *computepb.GetTargetHttpsProxyRequest, opts ...gax.CallOption) (*computepb.TargetHttpsProxy, error) { 367 baseUrl, _ := url.Parse(c.endpoint) 368 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/targetHttpsProxies/%v", req.GetProject(), req.GetTargetHttpsProxy()) 369 370 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 371 if err != nil { 372 return nil, err 373 } 374 httpReq = httpReq.WithContext(ctx) 375 // Set the headers 376 for k, v := range c.xGoogMetadata { 377 httpReq.Header[k] = v 378 } 379 httpReq.Header["Content-Type"] = []string{"application/json"} 380 381 httpRsp, err := c.httpClient.Do(httpReq) 382 if err != nil { 383 return nil, err 384 } 385 defer httpRsp.Body.Close() 386 387 if err = googleapi.CheckResponse(httpRsp); err != nil { 388 return nil, err 389 } 390 391 buf, err := ioutil.ReadAll(httpRsp.Body) 392 if err != nil { 393 return nil, err 394 } 395 396 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 397 rsp := &computepb.TargetHttpsProxy{} 398 399 if err := unm.Unmarshal(buf, rsp); err != nil { 400 return nil, maybeUnknownEnum(err) 401 } 402 return rsp, nil 403} 404 405// Insert creates a TargetHttpsProxy resource in the specified project using the data included in the request. 406func (c *targetHttpsProxiesRESTClient) Insert(ctx context.Context, req *computepb.InsertTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 407 m := protojson.MarshalOptions{AllowPartial: true} 408 body := req.GetTargetHttpsProxyResource() 409 jsonReq, err := m.Marshal(body) 410 if err != nil { 411 return nil, err 412 } 413 414 baseUrl, _ := url.Parse(c.endpoint) 415 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/targetHttpsProxies", req.GetProject()) 416 417 params := url.Values{} 418 if req != nil && req.RequestId != nil { 419 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) 420 } 421 422 baseUrl.RawQuery = params.Encode() 423 424 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 425 if err != nil { 426 return nil, err 427 } 428 httpReq = httpReq.WithContext(ctx) 429 // Set the headers 430 for k, v := range c.xGoogMetadata { 431 httpReq.Header[k] = v 432 } 433 httpReq.Header["Content-Type"] = []string{"application/json"} 434 435 httpRsp, err := c.httpClient.Do(httpReq) 436 if err != nil { 437 return nil, err 438 } 439 defer httpRsp.Body.Close() 440 441 if err = googleapi.CheckResponse(httpRsp); err != nil { 442 return nil, err 443 } 444 445 buf, err := ioutil.ReadAll(httpRsp.Body) 446 if err != nil { 447 return nil, err 448 } 449 450 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 451 rsp := &computepb.Operation{} 452 453 if err := unm.Unmarshal(buf, rsp); err != nil { 454 return nil, maybeUnknownEnum(err) 455 } 456 op := &Operation{proto: rsp} 457 return op, err 458} 459 460// List retrieves the list of TargetHttpsProxy resources available to the specified project. 461func (c *targetHttpsProxiesRESTClient) List(ctx context.Context, req *computepb.ListTargetHttpsProxiesRequest, opts ...gax.CallOption) *TargetHttpsProxyIterator { 462 it := &TargetHttpsProxyIterator{} 463 req = proto.Clone(req).(*computepb.ListTargetHttpsProxiesRequest) 464 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 465 it.InternalFetch = func(pageSize int, pageToken string) ([]*computepb.TargetHttpsProxy, string, error) { 466 resp := &computepb.TargetHttpsProxyList{} 467 if pageToken != "" { 468 req.PageToken = proto.String(pageToken) 469 } 470 if pageSize > math.MaxInt32 { 471 req.MaxResults = proto.Uint32(math.MaxInt32) 472 } else if pageSize != 0 { 473 req.MaxResults = proto.Uint32(uint32(pageSize)) 474 } 475 baseUrl, _ := url.Parse(c.endpoint) 476 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/targetHttpsProxies", req.GetProject()) 477 478 params := url.Values{} 479 if req != nil && req.Filter != nil { 480 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 481 } 482 if req != nil && req.MaxResults != nil { 483 params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults())) 484 } 485 if req != nil && req.OrderBy != nil { 486 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) 487 } 488 if req != nil && req.PageToken != nil { 489 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 490 } 491 if req != nil && req.ReturnPartialSuccess != nil { 492 params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess())) 493 } 494 495 baseUrl.RawQuery = params.Encode() 496 497 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 498 if err != nil { 499 return nil, "", err 500 } 501 502 // Set the headers 503 for k, v := range c.xGoogMetadata { 504 httpReq.Header[k] = v 505 } 506 507 httpReq.Header["Content-Type"] = []string{"application/json"} 508 httpRsp, err := c.httpClient.Do(httpReq) 509 if err != nil { 510 return nil, "", err 511 } 512 defer httpRsp.Body.Close() 513 514 if err = googleapi.CheckResponse(httpRsp); err != nil { 515 return nil, "", err 516 } 517 518 buf, err := ioutil.ReadAll(httpRsp.Body) 519 if err != nil { 520 return nil, "", err 521 } 522 523 unm.Unmarshal(buf, resp) 524 it.Response = resp 525 return resp.GetItems(), resp.GetNextPageToken(), nil 526 } 527 528 fetch := func(pageSize int, pageToken string) (string, error) { 529 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 530 if err != nil { 531 return "", err 532 } 533 it.items = append(it.items, items...) 534 return nextPageToken, nil 535 } 536 537 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 538 it.pageInfo.MaxSize = int(req.GetMaxResults()) 539 it.pageInfo.Token = req.GetPageToken() 540 541 return it 542} 543 544// Patch patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules. (== suppress_warning http-rest-shadowed ==) 545func (c *targetHttpsProxiesRESTClient) Patch(ctx context.Context, req *computepb.PatchTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 546 m := protojson.MarshalOptions{AllowPartial: true} 547 body := req.GetTargetHttpsProxyResource() 548 jsonReq, err := m.Marshal(body) 549 if err != nil { 550 return nil, err 551 } 552 553 baseUrl, _ := url.Parse(c.endpoint) 554 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/targetHttpsProxies/%v", req.GetProject(), req.GetTargetHttpsProxy()) 555 556 params := url.Values{} 557 if req != nil && req.RequestId != nil { 558 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) 559 } 560 561 baseUrl.RawQuery = params.Encode() 562 563 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) 564 if err != nil { 565 return nil, err 566 } 567 httpReq = httpReq.WithContext(ctx) 568 // Set the headers 569 for k, v := range c.xGoogMetadata { 570 httpReq.Header[k] = v 571 } 572 httpReq.Header["Content-Type"] = []string{"application/json"} 573 574 httpRsp, err := c.httpClient.Do(httpReq) 575 if err != nil { 576 return nil, err 577 } 578 defer httpRsp.Body.Close() 579 580 if err = googleapi.CheckResponse(httpRsp); err != nil { 581 return nil, err 582 } 583 584 buf, err := ioutil.ReadAll(httpRsp.Body) 585 if err != nil { 586 return nil, err 587 } 588 589 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 590 rsp := &computepb.Operation{} 591 592 if err := unm.Unmarshal(buf, rsp); err != nil { 593 return nil, maybeUnknownEnum(err) 594 } 595 op := &Operation{proto: rsp} 596 return op, err 597} 598 599// SetQuicOverride sets the QUIC override policy for TargetHttpsProxy. 600func (c *targetHttpsProxiesRESTClient) SetQuicOverride(ctx context.Context, req *computepb.SetQuicOverrideTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 601 m := protojson.MarshalOptions{AllowPartial: true} 602 body := req.GetTargetHttpsProxiesSetQuicOverrideRequestResource() 603 jsonReq, err := m.Marshal(body) 604 if err != nil { 605 return nil, err 606 } 607 608 baseUrl, _ := url.Parse(c.endpoint) 609 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/targetHttpsProxies/%v/setQuicOverride", req.GetProject(), req.GetTargetHttpsProxy()) 610 611 params := url.Values{} 612 if req != nil && req.RequestId != nil { 613 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) 614 } 615 616 baseUrl.RawQuery = params.Encode() 617 618 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 619 if err != nil { 620 return nil, err 621 } 622 httpReq = httpReq.WithContext(ctx) 623 // Set the headers 624 for k, v := range c.xGoogMetadata { 625 httpReq.Header[k] = v 626 } 627 httpReq.Header["Content-Type"] = []string{"application/json"} 628 629 httpRsp, err := c.httpClient.Do(httpReq) 630 if err != nil { 631 return nil, err 632 } 633 defer httpRsp.Body.Close() 634 635 if err = googleapi.CheckResponse(httpRsp); err != nil { 636 return nil, err 637 } 638 639 buf, err := ioutil.ReadAll(httpRsp.Body) 640 if err != nil { 641 return nil, err 642 } 643 644 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 645 rsp := &computepb.Operation{} 646 647 if err := unm.Unmarshal(buf, rsp); err != nil { 648 return nil, maybeUnknownEnum(err) 649 } 650 op := &Operation{proto: rsp} 651 return op, err 652} 653 654// SetSslCertificates replaces SslCertificates for TargetHttpsProxy. 655func (c *targetHttpsProxiesRESTClient) SetSslCertificates(ctx context.Context, req *computepb.SetSslCertificatesTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 656 m := protojson.MarshalOptions{AllowPartial: true} 657 body := req.GetTargetHttpsProxiesSetSslCertificatesRequestResource() 658 jsonReq, err := m.Marshal(body) 659 if err != nil { 660 return nil, err 661 } 662 663 baseUrl, _ := url.Parse(c.endpoint) 664 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/targetHttpsProxies/%v/setSslCertificates", req.GetProject(), req.GetTargetHttpsProxy()) 665 666 params := url.Values{} 667 if req != nil && req.RequestId != nil { 668 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) 669 } 670 671 baseUrl.RawQuery = params.Encode() 672 673 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 674 if err != nil { 675 return nil, err 676 } 677 httpReq = httpReq.WithContext(ctx) 678 // Set the headers 679 for k, v := range c.xGoogMetadata { 680 httpReq.Header[k] = v 681 } 682 httpReq.Header["Content-Type"] = []string{"application/json"} 683 684 httpRsp, err := c.httpClient.Do(httpReq) 685 if err != nil { 686 return nil, err 687 } 688 defer httpRsp.Body.Close() 689 690 if err = googleapi.CheckResponse(httpRsp); err != nil { 691 return nil, err 692 } 693 694 buf, err := ioutil.ReadAll(httpRsp.Body) 695 if err != nil { 696 return nil, err 697 } 698 699 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 700 rsp := &computepb.Operation{} 701 702 if err := unm.Unmarshal(buf, rsp); err != nil { 703 return nil, maybeUnknownEnum(err) 704 } 705 op := &Operation{proto: rsp} 706 return op, err 707} 708 709// SetSslPolicy sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends. 710func (c *targetHttpsProxiesRESTClient) SetSslPolicy(ctx context.Context, req *computepb.SetSslPolicyTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 711 m := protojson.MarshalOptions{AllowPartial: true} 712 body := req.GetSslPolicyReferenceResource() 713 jsonReq, err := m.Marshal(body) 714 if err != nil { 715 return nil, err 716 } 717 718 baseUrl, _ := url.Parse(c.endpoint) 719 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/global/targetHttpsProxies/%v/setSslPolicy", req.GetProject(), req.GetTargetHttpsProxy()) 720 721 params := url.Values{} 722 if req != nil && req.RequestId != nil { 723 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) 724 } 725 726 baseUrl.RawQuery = params.Encode() 727 728 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 729 if err != nil { 730 return nil, err 731 } 732 httpReq = httpReq.WithContext(ctx) 733 // Set the headers 734 for k, v := range c.xGoogMetadata { 735 httpReq.Header[k] = v 736 } 737 httpReq.Header["Content-Type"] = []string{"application/json"} 738 739 httpRsp, err := c.httpClient.Do(httpReq) 740 if err != nil { 741 return nil, err 742 } 743 defer httpRsp.Body.Close() 744 745 if err = googleapi.CheckResponse(httpRsp); err != nil { 746 return nil, err 747 } 748 749 buf, err := ioutil.ReadAll(httpRsp.Body) 750 if err != nil { 751 return nil, err 752 } 753 754 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 755 rsp := &computepb.Operation{} 756 757 if err := unm.Unmarshal(buf, rsp); err != nil { 758 return nil, maybeUnknownEnum(err) 759 } 760 op := &Operation{proto: rsp} 761 return op, err 762} 763 764// SetUrlMap changes the URL map for TargetHttpsProxy. 765func (c *targetHttpsProxiesRESTClient) SetUrlMap(ctx context.Context, req *computepb.SetUrlMapTargetHttpsProxyRequest, opts ...gax.CallOption) (*Operation, error) { 766 m := protojson.MarshalOptions{AllowPartial: true} 767 body := req.GetUrlMapReferenceResource() 768 jsonReq, err := m.Marshal(body) 769 if err != nil { 770 return nil, err 771 } 772 773 baseUrl, _ := url.Parse(c.endpoint) 774 baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/targetHttpsProxies/%v/setUrlMap", req.GetProject(), req.GetTargetHttpsProxy()) 775 776 params := url.Values{} 777 if req != nil && req.RequestId != nil { 778 params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId())) 779 } 780 781 baseUrl.RawQuery = params.Encode() 782 783 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 784 if err != nil { 785 return nil, err 786 } 787 httpReq = httpReq.WithContext(ctx) 788 // Set the headers 789 for k, v := range c.xGoogMetadata { 790 httpReq.Header[k] = v 791 } 792 httpReq.Header["Content-Type"] = []string{"application/json"} 793 794 httpRsp, err := c.httpClient.Do(httpReq) 795 if err != nil { 796 return nil, err 797 } 798 defer httpRsp.Body.Close() 799 800 if err = googleapi.CheckResponse(httpRsp); err != nil { 801 return nil, err 802 } 803 804 buf, err := ioutil.ReadAll(httpRsp.Body) 805 if err != nil { 806 return nil, err 807 } 808 809 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 810 rsp := &computepb.Operation{} 811 812 if err := unm.Unmarshal(buf, rsp); err != nil { 813 return nil, maybeUnknownEnum(err) 814 } 815 op := &Operation{proto: rsp} 816 return op, err 817} 818 819// TargetHttpsProxiesScopedListPair is a holder type for string/*computepb.TargetHttpsProxiesScopedList map entries 820type TargetHttpsProxiesScopedListPair struct { 821 Key string 822 Value *computepb.TargetHttpsProxiesScopedList 823} 824 825// TargetHttpsProxiesScopedListPairIterator manages a stream of TargetHttpsProxiesScopedListPair. 826type TargetHttpsProxiesScopedListPairIterator struct { 827 items []TargetHttpsProxiesScopedListPair 828 pageInfo *iterator.PageInfo 829 nextFunc func() error 830 831 // Response is the raw response for the current page. 832 // It must be cast to the RPC response type. 833 // Calling Next() or InternalFetch() updates this value. 834 Response interface{} 835 836 // InternalFetch is for use by the Google Cloud Libraries only. 837 // It is not part of the stable interface of this package. 838 // 839 // InternalFetch returns results from a single call to the underlying RPC. 840 // The number of results is no greater than pageSize. 841 // If there are no more results, nextPageToken is empty and err is nil. 842 InternalFetch func(pageSize int, pageToken string) (results []TargetHttpsProxiesScopedListPair, nextPageToken string, err error) 843} 844 845// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 846func (it *TargetHttpsProxiesScopedListPairIterator) PageInfo() *iterator.PageInfo { 847 return it.pageInfo 848} 849 850// Next returns the next result. Its second return value is iterator.Done if there are no more 851// results. Once Next returns Done, all subsequent calls will return Done. 852func (it *TargetHttpsProxiesScopedListPairIterator) Next() (TargetHttpsProxiesScopedListPair, error) { 853 var item TargetHttpsProxiesScopedListPair 854 if err := it.nextFunc(); err != nil { 855 return item, err 856 } 857 item = it.items[0] 858 it.items = it.items[1:] 859 return item, nil 860} 861 862func (it *TargetHttpsProxiesScopedListPairIterator) bufLen() int { 863 return len(it.items) 864} 865 866func (it *TargetHttpsProxiesScopedListPairIterator) takeBuf() interface{} { 867 b := it.items 868 it.items = nil 869 return b 870} 871