blob: 6d8c91533997489b6d307c55d4ef6c5b4a24da76 [file] [log] [blame]
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 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"
"net/http"
"net/url"
gax "github.com/googleapis/gax-go/v2"
"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"
)
var newRegionInstanceGroupManagersClientHook clientHook
// RegionInstanceGroupManagersCallOptions contains the retry settings for each method of RegionInstanceGroupManagersClient.
type RegionInstanceGroupManagersCallOptions struct {
AbandonInstances []gax.CallOption
ApplyUpdatesToInstances []gax.CallOption
CreateInstances []gax.CallOption
Delete []gax.CallOption
DeleteInstances []gax.CallOption
DeletePerInstanceConfigs []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListErrors []gax.CallOption
ListManagedInstances []gax.CallOption
ListPerInstanceConfigs []gax.CallOption
Patch []gax.CallOption
PatchPerInstanceConfigs []gax.CallOption
RecreateInstances []gax.CallOption
Resize []gax.CallOption
SetInstanceTemplate []gax.CallOption
SetTargetPools []gax.CallOption
UpdatePerInstanceConfigs []gax.CallOption
}
// internalRegionInstanceGroupManagersClient is an interface that defines the methods availaible from Google Compute Engine API.
type internalRegionInstanceGroupManagersClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
AbandonInstances(context.Context, *computepb.AbandonInstancesRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
ApplyUpdatesToInstances(context.Context, *computepb.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
CreateInstances(context.Context, *computepb.CreateInstancesRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
Delete(context.Context, *computepb.DeleteRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
DeleteInstances(context.Context, *computepb.DeleteInstancesRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
DeletePerInstanceConfigs(context.Context, *computepb.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
Get(context.Context, *computepb.GetRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.InstanceGroupManager, error)
Insert(context.Context, *computepb.InsertRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
List(context.Context, *computepb.ListRegionInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.RegionInstanceGroupManagerList, error)
ListErrors(context.Context, *computepb.ListErrorsRegionInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListErrorsResponse, error)
ListManagedInstances(context.Context, *computepb.ListManagedInstancesRegionInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListInstancesResponse, error)
ListPerInstanceConfigs(context.Context, *computepb.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListInstanceConfigsResp, error)
Patch(context.Context, *computepb.PatchRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
PatchPerInstanceConfigs(context.Context, *computepb.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
RecreateInstances(context.Context, *computepb.RecreateInstancesRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
Resize(context.Context, *computepb.ResizeRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
SetInstanceTemplate(context.Context, *computepb.SetInstanceTemplateRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
SetTargetPools(context.Context, *computepb.SetTargetPoolsRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
UpdatePerInstanceConfigs(context.Context, *computepb.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
}
// RegionInstanceGroupManagersClient 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 RegionInstanceGroupManagers API.
type RegionInstanceGroupManagersClient struct {
// The internal transport-dependent client.
internalClient internalRegionInstanceGroupManagersClient
// The call options for this service.
CallOptions *RegionInstanceGroupManagersCallOptions
}
// 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 *RegionInstanceGroupManagersClient) 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 *RegionInstanceGroupManagersClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated.
func (c *RegionInstanceGroupManagersClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// AbandonInstances flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
//
// You can specify a maximum of 1000 instances with this method per request.
func (c *RegionInstanceGroupManagersClient) AbandonInstances(ctx context.Context, req *computepb.AbandonInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.AbandonInstances(ctx, req, opts...)
}
// ApplyUpdatesToInstances apply updates to selected instances the managed instance group.
func (c *RegionInstanceGroupManagersClient) ApplyUpdatesToInstances(ctx context.Context, req *computepb.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.ApplyUpdatesToInstances(ctx, req, opts...)
}
// CreateInstances creates instances with per-instance configs in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.
func (c *RegionInstanceGroupManagersClient) CreateInstances(ctx context.Context, req *computepb.CreateInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.CreateInstances(ctx, req, opts...)
}
// Delete deletes the specified managed instance group and all of the instances in that group.
func (c *RegionInstanceGroupManagersClient) Delete(ctx context.Context, req *computepb.DeleteRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.Delete(ctx, req, opts...)
}
// DeleteInstances flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
//
// You can specify a maximum of 1000 instances with this method per request.
func (c *RegionInstanceGroupManagersClient) DeleteInstances(ctx context.Context, req *computepb.DeleteInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.DeleteInstances(ctx, req, opts...)
}
// DeletePerInstanceConfigs deletes selected per-instance configs for the managed instance group.
func (c *RegionInstanceGroupManagersClient) DeletePerInstanceConfigs(ctx context.Context, req *computepb.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.DeletePerInstanceConfigs(ctx, req, opts...)
}
// Get returns all of the details about the specified managed instance group.
func (c *RegionInstanceGroupManagersClient) Get(ctx context.Context, req *computepb.GetRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManager, error) {
return c.internalClient.Get(ctx, req, opts...)
}
// Insert creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method.
//
// A regional managed instance group can contain up to 2000 instances.
func (c *RegionInstanceGroupManagersClient) Insert(ctx context.Context, req *computepb.InsertRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.Insert(ctx, req, opts...)
}
// List retrieves the list of managed instance groups that are contained within the specified region.
func (c *RegionInstanceGroupManagersClient) List(ctx context.Context, req *computepb.ListRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagerList, error) {
return c.internalClient.List(ctx, req, opts...)
}
// ListErrors lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported.
func (c *RegionInstanceGroupManagersClient) ListErrors(ctx context.Context, req *computepb.ListErrorsRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListErrorsResponse, error) {
return c.internalClient.ListErrors(ctx, req, opts...)
}
// ListManagedInstances lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported.
func (c *RegionInstanceGroupManagersClient) ListManagedInstances(ctx context.Context, req *computepb.ListManagedInstancesRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListInstancesResponse, error) {
return c.internalClient.ListManagedInstances(ctx, req, opts...)
}
// ListPerInstanceConfigs lists all of the per-instance configs defined for the managed instance group. The orderBy query parameter is not supported.
func (c *RegionInstanceGroupManagersClient) ListPerInstanceConfigs(ctx context.Context, req *computepb.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListInstanceConfigsResp, error) {
return c.internalClient.ListPerInstanceConfigs(ctx, req, opts...)
}
// Patch updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
func (c *RegionInstanceGroupManagersClient) Patch(ctx context.Context, req *computepb.PatchRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.Patch(ctx, req, opts...)
}
// PatchPerInstanceConfigs inserts or patches per-instance configs for the managed instance group. perInstanceConfig.name (at http://perInstanceConfig.name) serves as a key used to distinguish whether to perform insert or patch.
func (c *RegionInstanceGroupManagersClient) PatchPerInstanceConfigs(ctx context.Context, req *computepb.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.PatchPerInstanceConfigs(ctx, req, opts...)
}
// RecreateInstances flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group’s current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
//
// You can specify a maximum of 1000 instances with this method per request.
func (c *RegionInstanceGroupManagersClient) RecreateInstances(ctx context.Context, req *computepb.RecreateInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.RecreateInstances(ctx, req, opts...)
}
// Resize changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances.
//
// The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
func (c *RegionInstanceGroupManagersClient) Resize(ctx context.Context, req *computepb.ResizeRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.Resize(ctx, req, opts...)
}
// SetInstanceTemplate sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected.
func (c *RegionInstanceGroupManagersClient) SetInstanceTemplate(ctx context.Context, req *computepb.SetInstanceTemplateRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.SetInstanceTemplate(ctx, req, opts...)
}
// SetTargetPools modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected.
func (c *RegionInstanceGroupManagersClient) SetTargetPools(ctx context.Context, req *computepb.SetTargetPoolsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.SetTargetPools(ctx, req, opts...)
}
// UpdatePerInstanceConfigs inserts or updates per-instance configs for the managed instance group. perInstanceConfig.name (at http://perInstanceConfig.name) serves as a key used to distinguish whether to perform insert or patch.
func (c *RegionInstanceGroupManagersClient) UpdatePerInstanceConfigs(ctx context.Context, req *computepb.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.UpdatePerInstanceConfigs(ctx, req, opts...)
}
// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
type regionInstanceGroupManagersRESTClient struct {
// The http endpoint to connect to.
endpoint string
// The http client.
httpClient *http.Client
// The x-goog-* metadata to be sent with each request.
xGoogMetadata metadata.MD
}
// NewRegionInstanceGroupManagersRESTClient creates a new region instance group managers rest client.
//
// The RegionInstanceGroupManagers API.
func NewRegionInstanceGroupManagersRESTClient(ctx context.Context, opts ...option.ClientOption) (*RegionInstanceGroupManagersClient, error) {
clientOpts := append(defaultRegionInstanceGroupManagersRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
c := &regionInstanceGroupManagersRESTClient{
endpoint: endpoint,
httpClient: httpClient,
}
c.setGoogleClientInfo()
return &RegionInstanceGroupManagersClient{internalClient: c, CallOptions: &RegionInstanceGroupManagersCallOptions{}}, nil
}
func defaultRegionInstanceGroupManagersRESTClientOptions() []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 *regionInstanceGroupManagersRESTClient) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", versionGo()}, keyval...)
kv = append(kv, "gapic", versionClient, "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 *regionInstanceGroupManagersRESTClient) Close() error {
// Replace httpClient with nil to force cleanup.
c.httpClient = nil
return nil
}
// Connection returns a connection to the API service.
//
// Deprecated.
func (c *regionInstanceGroupManagersRESTClient) Connection() *grpc.ClientConn {
return nil
}
// AbandonInstances flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
//
// You can specify a maximum of 1000 instances with this method per request.
func (c *regionInstanceGroupManagersRESTClient) AbandonInstances(ctx context.Context, req *computepb.AbandonInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagersAbandonInstancesRequestResource()
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/instanceGroupManagers/%v/abandonInstances", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// ApplyUpdatesToInstances apply updates to selected instances the managed instance group.
func (c *regionInstanceGroupManagersRESTClient) ApplyUpdatesToInstances(ctx context.Context, req *computepb.ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagersApplyUpdatesRequestResource()
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/instanceGroupManagers/%v/applyUpdatesToInstances", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// CreateInstances creates instances with per-instance configs in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.
func (c *regionInstanceGroupManagersRESTClient) CreateInstances(ctx context.Context, req *computepb.CreateInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagersCreateInstancesRequestResource()
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/instanceGroupManagers/%v/createInstances", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// Delete deletes the specified managed instance group and all of the instances in that group.
func (c *regionInstanceGroupManagersRESTClient) Delete(ctx context.Context, req *computepb.DeleteRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/instanceGroupManagers/%v", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// DeleteInstances flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
//
// You can specify a maximum of 1000 instances with this method per request.
func (c *regionInstanceGroupManagersRESTClient) DeleteInstances(ctx context.Context, req *computepb.DeleteInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagersDeleteInstancesRequestResource()
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/instanceGroupManagers/%v/deleteInstances", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// DeletePerInstanceConfigs deletes selected per-instance configs for the managed instance group.
func (c *regionInstanceGroupManagersRESTClient) DeletePerInstanceConfigs(ctx context.Context, req *computepb.DeletePerInstanceConfigsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagerDeleteInstanceConfigReqResource()
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/instanceGroupManagers/%v/deletePerInstanceConfigs", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// Get returns all of the details about the specified managed instance group.
func (c *regionInstanceGroupManagersRESTClient) Get(ctx context.Context, req *computepb.GetRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManager, error) {
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/instanceGroupManagers/%v", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.InstanceGroupManager{}
return rsp, unm.Unmarshal(buf, rsp)
}
// Insert creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method.
//
// A regional managed instance group can contain up to 2000 instances.
func (c *regionInstanceGroupManagersRESTClient) Insert(ctx context.Context, req *computepb.InsertRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInstanceGroupManagerResource()
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/instanceGroupManagers", 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()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// List retrieves the list of managed instance groups that are contained within the specified region.
func (c *regionInstanceGroupManagersRESTClient) List(ctx context.Context, req *computepb.ListRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagerList, error) {
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/instanceGroupManagers", 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()
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.RegionInstanceGroupManagerList{}
return rsp, unm.Unmarshal(buf, rsp)
}
// ListErrors lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported.
func (c *regionInstanceGroupManagersRESTClient) ListErrors(ctx context.Context, req *computepb.ListErrorsRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListErrorsResponse, error) {
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/instanceGroupManagers/%v/listErrors", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
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()
httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.RegionInstanceGroupManagersListErrorsResponse{}
return rsp, unm.Unmarshal(buf, rsp)
}
// ListManagedInstances lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported.
func (c *regionInstanceGroupManagersRESTClient) ListManagedInstances(ctx context.Context, req *computepb.ListManagedInstancesRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListInstancesResponse, error) {
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/instanceGroupManagers/%v/listManagedInstances", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
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()
httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.RegionInstanceGroupManagersListInstancesResponse{}
return rsp, unm.Unmarshal(buf, rsp)
}
// ListPerInstanceConfigs lists all of the per-instance configs defined for the managed instance group. The orderBy query parameter is not supported.
func (c *regionInstanceGroupManagersRESTClient) ListPerInstanceConfigs(ctx context.Context, req *computepb.ListPerInstanceConfigsRegionInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.RegionInstanceGroupManagersListInstanceConfigsResp, error) {
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/instanceGroupManagers/%v/listPerInstanceConfigs", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
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()
httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.RegionInstanceGroupManagersListInstanceConfigsResp{}
return rsp, unm.Unmarshal(buf, rsp)
}
// Patch updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
func (c *regionInstanceGroupManagersRESTClient) Patch(ctx context.Context, req *computepb.PatchRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetInstanceGroupManagerResource()
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/instanceGroupManagers/%v", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// PatchPerInstanceConfigs inserts or patches per-instance configs for the managed instance group. perInstanceConfig.name (at http://perInstanceConfig.name) serves as a key used to distinguish whether to perform insert or patch.
func (c *regionInstanceGroupManagersRESTClient) PatchPerInstanceConfigs(ctx context.Context, req *computepb.PatchPerInstanceConfigsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagerPatchInstanceConfigReqResource()
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/instanceGroupManagers/%v/patchPerInstanceConfigs", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// RecreateInstances flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group’s current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
//
// You can specify a maximum of 1000 instances with this method per request.
func (c *regionInstanceGroupManagersRESTClient) RecreateInstances(ctx context.Context, req *computepb.RecreateInstancesRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagersRecreateRequestResource()
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/instanceGroupManagers/%v/recreateInstances", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// Resize changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances.
//
// The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method.
//
// If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
func (c *regionInstanceGroupManagersRESTClient) Resize(ctx context.Context, req *computepb.ResizeRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/regions/%v/instanceGroupManagers/%v/resize", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
if req.GetSize() != 0 {
params.Add("size", fmt.Sprintf("%v", req.GetSize()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// SetInstanceTemplate sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected.
func (c *regionInstanceGroupManagersRESTClient) SetInstanceTemplate(ctx context.Context, req *computepb.SetInstanceTemplateRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagersSetTemplateRequestResource()
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/instanceGroupManagers/%v/setInstanceTemplate", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// SetTargetPools modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected.
func (c *regionInstanceGroupManagersRESTClient) SetTargetPools(ctx context.Context, req *computepb.SetTargetPoolsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagersSetTargetPoolsRequestResource()
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/instanceGroupManagers/%v/setTargetPools", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}
// UpdatePerInstanceConfigs inserts or updates per-instance configs for the managed instance group. perInstanceConfig.name (at http://perInstanceConfig.name) serves as a key used to distinguish whether to perform insert or patch.
func (c *regionInstanceGroupManagersRESTClient) UpdatePerInstanceConfigs(ctx context.Context, req *computepb.UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true}
body := req.GetRegionInstanceGroupManagerUpdateInstanceConfigReqResource()
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/instanceGroupManagers/%v/updatePerInstanceConfigs", req.GetProject(), req.GetRegion(), req.GetInstanceGroupManager())
params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
if err != nil {
return nil, err
}
httpReq = httpReq.WithContext(ctx)
// Set the headers
for k, v := range c.xGoogMetadata {
httpReq.Header[k] = v
}
httpReq.Header["Content-Type"] = []string{"application/json"}
httpRsp, err := c.httpClient.Do(httpReq)
if err != nil {
return nil, err
}
defer httpRsp.Body.Close()
if httpRsp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(httpRsp.Status)
}
buf, err := ioutil.ReadAll(httpRsp.Body)
if err != nil {
return nil, err
}
unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
rsp := &computepb.Operation{}
return rsp, unm.Unmarshal(buf, rsp)
}