blob: 630395260888fa08482471304c5a8dbb3febf86e [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 newInstanceGroupManagersClientHook clientHook
// InstanceGroupManagersCallOptions contains the retry settings for each method of InstanceGroupManagersClient.
type InstanceGroupManagersCallOptions struct {
AbandonInstances []gax.CallOption
AggregatedList []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
}
// internalInstanceGroupManagersClient is an interface that defines the methods availaible from Google Compute Engine API.
type internalInstanceGroupManagersClient interface {
Close() error
setGoogleClientInfo(...string)
Connection() *grpc.ClientConn
AbandonInstances(context.Context, *computepb.AbandonInstancesInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
AggregatedList(context.Context, *computepb.AggregatedListInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.InstanceGroupManagerAggregatedList, error)
ApplyUpdatesToInstances(context.Context, *computepb.ApplyUpdatesToInstancesInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
CreateInstances(context.Context, *computepb.CreateInstancesInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
Delete(context.Context, *computepb.DeleteInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
DeleteInstances(context.Context, *computepb.DeleteInstancesInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
DeletePerInstanceConfigs(context.Context, *computepb.DeletePerInstanceConfigsInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
Get(context.Context, *computepb.GetInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.InstanceGroupManager, error)
Insert(context.Context, *computepb.InsertInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
List(context.Context, *computepb.ListInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.InstanceGroupManagerList, error)
ListErrors(context.Context, *computepb.ListErrorsInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.InstanceGroupManagersListErrorsResponse, error)
ListManagedInstances(context.Context, *computepb.ListManagedInstancesInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.InstanceGroupManagersListManagedInstancesResponse, error)
ListPerInstanceConfigs(context.Context, *computepb.ListPerInstanceConfigsInstanceGroupManagersRequest, ...gax.CallOption) (*computepb.InstanceGroupManagersListPerInstanceConfigsResp, error)
Patch(context.Context, *computepb.PatchInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
PatchPerInstanceConfigs(context.Context, *computepb.PatchPerInstanceConfigsInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
RecreateInstances(context.Context, *computepb.RecreateInstancesInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
Resize(context.Context, *computepb.ResizeInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
SetInstanceTemplate(context.Context, *computepb.SetInstanceTemplateInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
SetTargetPools(context.Context, *computepb.SetTargetPoolsInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
UpdatePerInstanceConfigs(context.Context, *computepb.UpdatePerInstanceConfigsInstanceGroupManagerRequest, ...gax.CallOption) (*computepb.Operation, error)
}
// InstanceGroupManagersClient 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 InstanceGroupManagers API.
type InstanceGroupManagersClient struct {
// The internal transport-dependent client.
internalClient internalInstanceGroupManagersClient
// The call options for this service.
CallOptions *InstanceGroupManagersCallOptions
}
// 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 *InstanceGroupManagersClient) 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 *InstanceGroupManagersClient) setGoogleClientInfo(keyval ...string) {
c.internalClient.setGoogleClientInfo(keyval...)
}
// Connection returns a connection to the API service.
//
// Deprecated.
func (c *InstanceGroupManagersClient) Connection() *grpc.ClientConn {
return c.internalClient.Connection()
}
// AbandonInstances flags the specified instances to be 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 *InstanceGroupManagersClient) AbandonInstances(ctx context.Context, req *computepb.AbandonInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.AbandonInstances(ctx, req, opts...)
}
// AggregatedList retrieves the list of managed instance groups and groups them by zone.
func (c *InstanceGroupManagersClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagerAggregatedList, error) {
return c.internalClient.AggregatedList(ctx, req, opts...)
}
// ApplyUpdatesToInstances applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions.
func (c *InstanceGroupManagersClient) ApplyUpdatesToInstances(ctx context.Context, req *computepb.ApplyUpdatesToInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.ApplyUpdatesToInstances(ctx, req, opts...)
}
// CreateInstances creates instances with per-instance configs in this 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 *InstanceGroupManagersClient) CreateInstances(ctx context.Context, req *computepb.CreateInstancesInstanceGroupManagerRequest, 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. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information.
func (c *InstanceGroupManagersClient) Delete(ctx context.Context, req *computepb.DeleteInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.Delete(ctx, req, opts...)
}
// DeleteInstances flags the specified instances in the managed instance group for immediate deletion. 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. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. 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 *InstanceGroupManagersClient) DeleteInstances(ctx context.Context, req *computepb.DeleteInstancesInstanceGroupManagerRequest, 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 *InstanceGroupManagersClient) DeletePerInstanceConfigs(ctx context.Context, req *computepb.DeletePerInstanceConfigsInstanceGroupManagerRequest, 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. Gets a list of available managed instance groups by making a list() request.
func (c *InstanceGroupManagersClient) Get(ctx context.Context, req *computepb.GetInstanceGroupManagerRequest, 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 managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit.
func (c *InstanceGroupManagersClient) Insert(ctx context.Context, req *computepb.InsertInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.Insert(ctx, req, opts...)
}
// List retrieves a list of managed instance groups that are contained within the specified project and zone.
func (c *InstanceGroupManagersClient) List(ctx context.Context, req *computepb.ListInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagerList, error) {
return c.internalClient.List(ctx, req, opts...)
}
// ListErrors lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported.
func (c *InstanceGroupManagersClient) ListErrors(ctx context.Context, req *computepb.ListErrorsInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagersListErrorsResponse, error) {
return c.internalClient.ListErrors(ctx, req, opts...)
}
// ListManagedInstances lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported.
func (c *InstanceGroupManagersClient) ListManagedInstances(ctx context.Context, req *computepb.ListManagedInstancesInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagersListManagedInstancesResponse, 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 *InstanceGroupManagersClient) ListPerInstanceConfigs(ctx context.Context, req *computepb.ListPerInstanceConfigsInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagersListPerInstanceConfigsResp, 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 *InstanceGroupManagersClient) Patch(ctx context.Context, req *computepb.PatchInstanceGroupManagerRequest, 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 *InstanceGroupManagersClient) PatchPerInstanceConfigs(ctx context.Context, req *computepb.PatchPerInstanceConfigsInstanceGroupManagerRequest, 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 *InstanceGroupManagersClient) RecreateInstances(ctx context.Context, req *computepb.RecreateInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.RecreateInstances(ctx, req, opts...)
}
// Resize resizes 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 instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method.
//
// When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including:
//
// The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance.
//
// This list is subject to change.
//
// 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 *InstanceGroupManagersClient) Resize(ctx context.Context, req *computepb.ResizeInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.Resize(ctx, req, opts...)
}
// SetInstanceTemplate specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group’s updatePolicy.type to PROACTIVE.
func (c *InstanceGroupManagersClient) SetInstanceTemplate(ctx context.Context, req *computepb.SetInstanceTemplateInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
return c.internalClient.SetInstanceTemplate(ctx, req, opts...)
}
// SetTargetPools modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group.
func (c *InstanceGroupManagersClient) SetTargetPools(ctx context.Context, req *computepb.SetTargetPoolsInstanceGroupManagerRequest, 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 *InstanceGroupManagersClient) UpdatePerInstanceConfigs(ctx context.Context, req *computepb.UpdatePerInstanceConfigsInstanceGroupManagerRequest, 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 instanceGroupManagersRESTClient 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
}
// NewInstanceGroupManagersRESTClient creates a new instance group managers rest client.
//
// The InstanceGroupManagers API.
func NewInstanceGroupManagersRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupManagersClient, error) {
clientOpts := append(defaultInstanceGroupManagersRESTClientOptions(), opts...)
httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
if err != nil {
return nil, err
}
c := &instanceGroupManagersRESTClient{
endpoint: endpoint,
httpClient: httpClient,
}
c.setGoogleClientInfo()
return &InstanceGroupManagersClient{internalClient: c, CallOptions: &InstanceGroupManagersCallOptions{}}, nil
}
func defaultInstanceGroupManagersRESTClientOptions() []option.ClientOption {
return []option.ClientOption{
internaloption.WithDefaultEndpoint("compute.googleapis.com"),
internaloption.WithDefaultMTLSEndpoint("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 *instanceGroupManagersRESTClient) 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 *instanceGroupManagersRESTClient) 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 *instanceGroupManagersRESTClient) Connection() *grpc.ClientConn {
return nil
}
// AbandonInstances flags the specified instances to be 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 *instanceGroupManagersRESTClient) AbandonInstances(ctx context.Context, req *computepb.AbandonInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersAbandonInstancesRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/abandonInstances", req.GetProject(), req.GetZone(), 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)
}
// AggregatedList retrieves the list of managed instance groups and groups them by zone.
func (c *instanceGroupManagersRESTClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagerAggregatedList, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/aggregated/instanceGroupManagers", req.GetProject())
params := url.Values{}
if req != nil && req.Filter != nil {
params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
}
if req != nil && req.IncludeAllScopes != nil {
params.Add("includeAllScopes", fmt.Sprintf("%v", req.GetIncludeAllScopes()))
}
if req != nil && req.MaxResults != nil {
params.Add("maxResults", fmt.Sprintf("%v", req.GetMaxResults()))
}
if req != nil && req.OrderBy != nil {
params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
}
if req != nil && req.PageToken != nil {
params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
}
if req != nil && req.ReturnPartialSuccess != nil {
params.Add("returnPartialSuccess", fmt.Sprintf("%v", req.GetReturnPartialSuccess()))
}
baseUrl.RawQuery = params.Encode()
httpReq, err := http.NewRequest("GET", 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.InstanceGroupManagerAggregatedList{}
return rsp, unm.Unmarshal(buf, rsp)
}
// ApplyUpdatesToInstances applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions.
func (c *instanceGroupManagersRESTClient) ApplyUpdatesToInstances(ctx context.Context, req *computepb.ApplyUpdatesToInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersApplyUpdatesRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/applyUpdatesToInstances", req.GetProject(), req.GetZone(), 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 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 *instanceGroupManagersRESTClient) CreateInstances(ctx context.Context, req *computepb.CreateInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersCreateInstancesRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/createInstances", req.GetProject(), req.GetZone(), 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. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information.
func (c *instanceGroupManagersRESTClient) Delete(ctx context.Context, req *computepb.DeleteInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v", req.GetProject(), req.GetZone(), 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(), 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)
}
// DeleteInstances flags the specified instances in the managed instance group for immediate deletion. 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. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. 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 *instanceGroupManagersRESTClient) DeleteInstances(ctx context.Context, req *computepb.DeleteInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersDeleteInstancesRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/deleteInstances", req.GetProject(), req.GetZone(), 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 *instanceGroupManagersRESTClient) DeletePerInstanceConfigs(ctx context.Context, req *computepb.DeletePerInstanceConfigsInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersDeletePerInstanceConfigsReqResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/deletePerInstanceConfigs", req.GetProject(), req.GetZone(), 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. Gets a list of available managed instance groups by making a list() request.
func (c *instanceGroupManagersRESTClient) Get(ctx context.Context, req *computepb.GetInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManager, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v", req.GetProject(), req.GetZone(), req.GetInstanceGroupManager())
httpReq, err := http.NewRequest("GET", 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.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 managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit.
func (c *instanceGroupManagersRESTClient) Insert(ctx context.Context, req *computepb.InsertInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: 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/zones/%v/instanceGroupManagers", req.GetProject(), req.GetZone())
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 a list of managed instance groups that are contained within the specified project and zone.
func (c *instanceGroupManagersRESTClient) List(ctx context.Context, req *computepb.ListInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagerList, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers", req.GetProject(), req.GetZone())
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(), 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.InstanceGroupManagerList{}
return rsp, unm.Unmarshal(buf, rsp)
}
// ListErrors lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported.
func (c *instanceGroupManagersRESTClient) ListErrors(ctx context.Context, req *computepb.ListErrorsInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagersListErrorsResponse, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/listErrors", req.GetProject(), req.GetZone(), 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(), 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.InstanceGroupManagersListErrorsResponse{}
return rsp, unm.Unmarshal(buf, rsp)
}
// ListManagedInstances lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported.
func (c *instanceGroupManagersRESTClient) ListManagedInstances(ctx context.Context, req *computepb.ListManagedInstancesInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagersListManagedInstancesResponse, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/listManagedInstances", req.GetProject(), req.GetZone(), 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(), 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.InstanceGroupManagersListManagedInstancesResponse{}
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 *instanceGroupManagersRESTClient) ListPerInstanceConfigs(ctx context.Context, req *computepb.ListPerInstanceConfigsInstanceGroupManagersRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagersListPerInstanceConfigsResp, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/listPerInstanceConfigs", req.GetProject(), req.GetZone(), 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(), 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.InstanceGroupManagersListPerInstanceConfigsResp{}
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 *instanceGroupManagersRESTClient) Patch(ctx context.Context, req *computepb.PatchInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: 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/zones/%v/instanceGroupManagers/%v", req.GetProject(), req.GetZone(), 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 *instanceGroupManagersRESTClient) PatchPerInstanceConfigs(ctx context.Context, req *computepb.PatchPerInstanceConfigsInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersPatchPerInstanceConfigsReqResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/patchPerInstanceConfigs", req.GetProject(), req.GetZone(), 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 *instanceGroupManagersRESTClient) RecreateInstances(ctx context.Context, req *computepb.RecreateInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersRecreateInstancesRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/recreateInstances", req.GetProject(), req.GetZone(), 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 resizes 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 instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method.
//
// When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including:
//
// The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance.
//
// This list is subject to change.
//
// 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 *instanceGroupManagersRESTClient) Resize(ctx context.Context, req *computepb.ResizeInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
jsonReq, err := m.Marshal(req)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/resize", req.GetProject(), req.GetZone(), 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(), 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)
}
// SetInstanceTemplate specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group’s updatePolicy.type to PROACTIVE.
func (c *instanceGroupManagersRESTClient) SetInstanceTemplate(ctx context.Context, req *computepb.SetInstanceTemplateInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersSetInstanceTemplateRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/setInstanceTemplate", req.GetProject(), req.GetZone(), 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 instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group.
func (c *instanceGroupManagersRESTClient) SetTargetPools(ctx context.Context, req *computepb.SetTargetPoolsInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersSetTargetPoolsRequestResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/setTargetPools", req.GetProject(), req.GetZone(), 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 *instanceGroupManagersRESTClient) UpdatePerInstanceConfigs(ctx context.Context, req *computepb.UpdatePerInstanceConfigsInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.Operation, error) {
m := protojson.MarshalOptions{AllowPartial: true, EmitUnpopulated: true}
body := req.GetInstanceGroupManagersUpdatePerInstanceConfigsReqResource()
jsonReq, err := m.Marshal(body)
if err != nil {
return nil, err
}
baseUrl, _ := url.Parse(c.endpoint)
baseUrl.Path += fmt.Sprintf("/compute/v1/projects/%v/zones/%v/instanceGroupManagers/%v/updatePerInstanceConfigs", req.GetProject(), req.GetZone(), 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)
}