github.com/openshift-online/ocm-sdk-go@v0.1.473/clustersmgmt/v1/cluster_client.go (about)

     1  /*
     2  Copyright (c) 2020 Red Hat, Inc.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8    http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
    18  // your changes will be lost when the file is generated again.
    19  
    20  package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1
    21  
    22  import (
    23  	"bufio"
    24  	"bytes"
    25  	"context"
    26  	"io"
    27  	"net/http"
    28  	"net/url"
    29  	"path"
    30  	"time"
    31  
    32  	"github.com/openshift-online/ocm-sdk-go/errors"
    33  	"github.com/openshift-online/ocm-sdk-go/helpers"
    34  )
    35  
    36  // ClusterClient is the client of the 'cluster' resource.
    37  //
    38  // Manages a specific cluster.
    39  type ClusterClient struct {
    40  	transport http.RoundTripper
    41  	path      string
    42  }
    43  
    44  // NewClusterClient creates a new client for the 'cluster'
    45  // resource using the given transport to send the requests and receive the
    46  // responses.
    47  func NewClusterClient(transport http.RoundTripper, path string) *ClusterClient {
    48  	return &ClusterClient{
    49  		transport: transport,
    50  		path:      path,
    51  	}
    52  }
    53  
    54  // Delete creates a request for the 'delete' method.
    55  //
    56  // Deletes the cluster.
    57  func (c *ClusterClient) Delete() *ClusterDeleteRequest {
    58  	return &ClusterDeleteRequest{
    59  		transport: c.transport,
    60  		path:      c.path,
    61  	}
    62  }
    63  
    64  // Get creates a request for the 'get' method.
    65  //
    66  // Retrieves the details of the cluster.
    67  func (c *ClusterClient) Get() *ClusterGetRequest {
    68  	return &ClusterGetRequest{
    69  		transport: c.transport,
    70  		path:      c.path,
    71  	}
    72  }
    73  
    74  // Hibernate creates a request for the 'hibernate' method.
    75  //
    76  // Initiates cluster hibernation. While hibernating a cluster will not consume any cloud provider infrastructure
    77  // but will be counted for quota.
    78  func (c *ClusterClient) Hibernate() *ClusterHibernateRequest {
    79  	return &ClusterHibernateRequest{
    80  		transport: c.transport,
    81  		path:      path.Join(c.path, "hibernate"),
    82  	}
    83  }
    84  
    85  // Resume creates a request for the 'resume' method.
    86  //
    87  // Resumes from Hibernation.
    88  func (c *ClusterClient) Resume() *ClusterResumeRequest {
    89  	return &ClusterResumeRequest{
    90  		transport: c.transport,
    91  		path:      path.Join(c.path, "resume"),
    92  	}
    93  }
    94  
    95  // Update creates a request for the 'update' method.
    96  //
    97  // Updates the cluster.
    98  func (c *ClusterClient) Update() *ClusterUpdateRequest {
    99  	return &ClusterUpdateRequest{
   100  		transport: c.transport,
   101  		path:      c.path,
   102  	}
   103  }
   104  
   105  // AWS returns the target 'AWS' resource.
   106  func (c *ClusterClient) AWS() *AWSClient {
   107  	return NewAWSClient(
   108  		c.transport,
   109  		path.Join(c.path, "aws"),
   110  	)
   111  }
   112  
   113  // AWSInfrastructureAccessRoleGrants returns the target 'AWS_infrastructure_access_role_grants' resource.
   114  //
   115  // Reference to the resource that manages the collection of AWS infrastructure
   116  // access role grants on this cluster.
   117  func (c *ClusterClient) AWSInfrastructureAccessRoleGrants() *AWSInfrastructureAccessRoleGrantsClient {
   118  	return NewAWSInfrastructureAccessRoleGrantsClient(
   119  		c.transport,
   120  		path.Join(c.path, "aws_infrastructure_access_role_grants"),
   121  	)
   122  }
   123  
   124  // STSOperatorRoles returns the target 'operator_IAM_roles' resource.
   125  func (c *ClusterClient) STSOperatorRoles() *OperatorIAMRolesClient {
   126  	return NewOperatorIAMRolesClient(
   127  		c.transport,
   128  		path.Join(c.path, "sts_operator_roles"),
   129  	)
   130  }
   131  
   132  // AddonInquiries returns the target 'addon_inquiries' resource.
   133  //
   134  // Reference to the resource that manages the collection of the add-on inquiries on this cluster.
   135  func (c *ClusterClient) AddonInquiries() *AddonInquiriesClient {
   136  	return NewAddonInquiriesClient(
   137  		c.transport,
   138  		path.Join(c.path, "addon_inquiries"),
   139  	)
   140  }
   141  
   142  // AddonUpgradePolicies returns the target 'addon_upgrade_policies' resource.
   143  //
   144  // Reference to the resource that manages the collection of addon upgrade policies defined for this cluster.
   145  func (c *ClusterClient) AddonUpgradePolicies() *AddonUpgradePoliciesClient {
   146  	return NewAddonUpgradePoliciesClient(
   147  		c.transport,
   148  		path.Join(c.path, "addon_upgrade_policies"),
   149  	)
   150  }
   151  
   152  // Addons returns the target 'add_on_installations' resource.
   153  //
   154  // Reference to the resource that manages the collection of add-ons installed on this cluster.
   155  func (c *ClusterClient) Addons() *AddOnInstallationsClient {
   156  	return NewAddOnInstallationsClient(
   157  		c.transport,
   158  		path.Join(c.path, "addons"),
   159  	)
   160  }
   161  
   162  // Autoscaler returns the target 'autoscaler' resource.
   163  //
   164  // Reference to the resource that manages the cluster autoscaler.
   165  func (c *ClusterClient) Autoscaler() *AutoscalerClient {
   166  	return NewAutoscalerClient(
   167  		c.transport,
   168  		path.Join(c.path, "autoscaler"),
   169  	)
   170  }
   171  
   172  // BreakGlassCredentials returns the target 'break_glass_credentials' resource.
   173  //
   174  // Reference to the resource that manages the break glass credentials.
   175  func (c *ClusterClient) BreakGlassCredentials() *BreakGlassCredentialsClient {
   176  	return NewBreakGlassCredentialsClient(
   177  		c.transport,
   178  		path.Join(c.path, "break_glass_credentials"),
   179  	)
   180  }
   181  
   182  // Clusterdeployment returns the target 'clusterdeployment' resource.
   183  //
   184  // Reference to the resource that manages the cluster deployment.
   185  func (c *ClusterClient) Clusterdeployment() *ClusterdeploymentClient {
   186  	return NewClusterdeploymentClient(
   187  		c.transport,
   188  		path.Join(c.path, "clusterdeployment"),
   189  	)
   190  }
   191  
   192  // ControlPlane returns the target 'control_plane' resource.
   193  //
   194  // Reference to the resource that manages the collection of upgrade policies defined for control plane for this cluster.
   195  func (c *ClusterClient) ControlPlane() *ControlPlaneClient {
   196  	return NewControlPlaneClient(
   197  		c.transport,
   198  		path.Join(c.path, "control_plane"),
   199  	)
   200  }
   201  
   202  // Credentials returns the target 'credentials' resource.
   203  //
   204  // Reference to the resource that manages the credentials of the cluster.
   205  func (c *ClusterClient) Credentials() *CredentialsClient {
   206  	return NewCredentialsClient(
   207  		c.transport,
   208  		path.Join(c.path, "credentials"),
   209  	)
   210  }
   211  
   212  // DeleteProtection returns the target 'delete_protection' resource.
   213  func (c *ClusterClient) DeleteProtection() *DeleteProtectionClient {
   214  	return NewDeleteProtectionClient(
   215  		c.transport,
   216  		path.Join(c.path, "delete_protection"),
   217  	)
   218  }
   219  
   220  // ExternalAuthConfig returns the target 'external_auth_config' resource.
   221  //
   222  // Reference to the resource that manages the external authentication configuration.
   223  func (c *ClusterClient) ExternalAuthConfig() *ExternalAuthConfigClient {
   224  	return NewExternalAuthConfigClient(
   225  		c.transport,
   226  		path.Join(c.path, "external_auth_config"),
   227  	)
   228  }
   229  
   230  // ExternalConfiguration returns the target 'external_configuration' resource.
   231  //
   232  // Reference to the resource that manages the external configuration.
   233  func (c *ClusterClient) ExternalConfiguration() *ExternalConfigurationClient {
   234  	return NewExternalConfigurationClient(
   235  		c.transport,
   236  		path.Join(c.path, "external_configuration"),
   237  	)
   238  }
   239  
   240  // GateAgreements returns the target 'version_gate_agreements' resource.
   241  //
   242  // Reference to cluster's agreed version gate.
   243  func (c *ClusterClient) GateAgreements() *VersionGateAgreementsClient {
   244  	return NewVersionGateAgreementsClient(
   245  		c.transport,
   246  		path.Join(c.path, "gate_agreements"),
   247  	)
   248  }
   249  
   250  // Groups returns the target 'groups' resource.
   251  //
   252  // Reference to the resource that manages the collection of groups.
   253  func (c *ClusterClient) Groups() *GroupsClient {
   254  	return NewGroupsClient(
   255  		c.transport,
   256  		path.Join(c.path, "groups"),
   257  	)
   258  }
   259  
   260  // Hypershift returns the target 'hypershift' resource.
   261  func (c *ClusterClient) Hypershift() *HypershiftClient {
   262  	return NewHypershiftClient(
   263  		c.transport,
   264  		path.Join(c.path, "hypershift"),
   265  	)
   266  }
   267  
   268  // IdentityProviders returns the target 'identity_providers' resource.
   269  //
   270  // Reference to the resource that manages the collection of identity providers.
   271  func (c *ClusterClient) IdentityProviders() *IdentityProvidersClient {
   272  	return NewIdentityProvidersClient(
   273  		c.transport,
   274  		path.Join(c.path, "identity_providers"),
   275  	)
   276  }
   277  
   278  // InflightChecks returns the target 'inflight_checks' resource.
   279  //
   280  // Reference to the resource that manages the collection of inflight checks.
   281  func (c *ClusterClient) InflightChecks() *InflightChecksClient {
   282  	return NewInflightChecksClient(
   283  		c.transport,
   284  		path.Join(c.path, "inflight_checks"),
   285  	)
   286  }
   287  
   288  // Ingresses returns the target 'ingresses' resource.
   289  //
   290  // Reference to the resource that manages the collection of ingress resources.
   291  func (c *ClusterClient) Ingresses() *IngressesClient {
   292  	return NewIngressesClient(
   293  		c.transport,
   294  		path.Join(c.path, "ingresses"),
   295  	)
   296  }
   297  
   298  // KubeletConfig returns the target 'kubelet_config' resource.
   299  func (c *ClusterClient) KubeletConfig() *KubeletConfigClient {
   300  	return NewKubeletConfigClient(
   301  		c.transport,
   302  		path.Join(c.path, "kubelet_config"),
   303  	)
   304  }
   305  
   306  // KubeletConfigs returns the target 'kubelet_configs' resource.
   307  func (c *ClusterClient) KubeletConfigs() *KubeletConfigsClient {
   308  	return NewKubeletConfigsClient(
   309  		c.transport,
   310  		path.Join(c.path, "kubelet_configs"),
   311  	)
   312  }
   313  
   314  // LimitedSupportReasons returns the target 'limited_support_reasons' resource.
   315  //
   316  // Reference to cluster limited support reasons.
   317  func (c *ClusterClient) LimitedSupportReasons() *LimitedSupportReasonsClient {
   318  	return NewLimitedSupportReasonsClient(
   319  		c.transport,
   320  		path.Join(c.path, "limited_support_reasons"),
   321  	)
   322  }
   323  
   324  // Logs returns the target 'logs' resource.
   325  //
   326  // Reference to the resource that manages the collection of logs of the cluster.
   327  func (c *ClusterClient) Logs() *LogsClient {
   328  	return NewLogsClient(
   329  		c.transport,
   330  		path.Join(c.path, "logs"),
   331  	)
   332  }
   333  
   334  // MachinePools returns the target 'machine_pools' resource.
   335  //
   336  // Reference to the resource that manages the collection of machine pool resources.
   337  func (c *ClusterClient) MachinePools() *MachinePoolsClient {
   338  	return NewMachinePoolsClient(
   339  		c.transport,
   340  		path.Join(c.path, "machine_pools"),
   341  	)
   342  }
   343  
   344  // MetricQueries returns the target 'metric_queries' resource.
   345  //
   346  // Reference to the resource that manages metrics queries for the cluster.
   347  func (c *ClusterClient) MetricQueries() *MetricQueriesClient {
   348  	return NewMetricQueriesClient(
   349  		c.transport,
   350  		path.Join(c.path, "metric_queries"),
   351  	)
   352  }
   353  
   354  // Migrations returns the target 'cluster_migrations' resource.
   355  func (c *ClusterClient) Migrations() *ClusterMigrationsClient {
   356  	return NewClusterMigrationsClient(
   357  		c.transport,
   358  		path.Join(c.path, "migrations"),
   359  	)
   360  }
   361  
   362  // NodePools returns the target 'node_pools' resource.
   363  //
   364  // Reference to the resource that manages the collection of node pool resources.
   365  func (c *ClusterClient) NodePools() *NodePoolsClient {
   366  	return NewNodePoolsClient(
   367  		c.transport,
   368  		path.Join(c.path, "node_pools"),
   369  	)
   370  }
   371  
   372  // ProvisionShard returns the target 'provision_shard' resource.
   373  //
   374  // Reference to the resource that manages the cluster's provision shard.
   375  func (c *ClusterClient) ProvisionShard() *ProvisionShardClient {
   376  	return NewProvisionShardClient(
   377  		c.transport,
   378  		path.Join(c.path, "provision_shard"),
   379  	)
   380  }
   381  
   382  // Resources returns the target 'resources' resource.
   383  //
   384  // Reference to cluster resources.
   385  func (c *ClusterClient) Resources() *ResourcesClient {
   386  	return NewResourcesClient(
   387  		c.transport,
   388  		path.Join(c.path, "resources"),
   389  	)
   390  }
   391  
   392  // Status returns the target 'cluster_status' resource.
   393  //
   394  // Reference to the resource that manages the detailed status of the cluster.
   395  func (c *ClusterClient) Status() *ClusterStatusClient {
   396  	return NewClusterStatusClient(
   397  		c.transport,
   398  		path.Join(c.path, "status"),
   399  	)
   400  }
   401  
   402  // StsSupportJumpRole returns the target 'sts_support_jump_role' resource.
   403  func (c *ClusterClient) StsSupportJumpRole() *StsSupportJumpRoleClient {
   404  	return NewStsSupportJumpRoleClient(
   405  		c.transport,
   406  		path.Join(c.path, "sts_support_jump_role"),
   407  	)
   408  }
   409  
   410  // TuningConfigs returns the target 'tuning_configs' resource.
   411  //
   412  // Reference to the resource that manages the collection of tuning configs for this cluster.
   413  func (c *ClusterClient) TuningConfigs() *TuningConfigsClient {
   414  	return NewTuningConfigsClient(
   415  		c.transport,
   416  		path.Join(c.path, "tuning_configs"),
   417  	)
   418  }
   419  
   420  // UpgradePolicies returns the target 'upgrade_policies' resource.
   421  //
   422  // Reference to the resource that manages the collection of upgrade policies defined for this cluster.
   423  func (c *ClusterClient) UpgradePolicies() *UpgradePoliciesClient {
   424  	return NewUpgradePoliciesClient(
   425  		c.transport,
   426  		path.Join(c.path, "upgrade_policies"),
   427  	)
   428  }
   429  
   430  // Vpc returns the target 'vpc' resource.
   431  //
   432  // Reference to the resource that manages the vpc resource.
   433  func (c *ClusterClient) Vpc() *VpcClient {
   434  	return NewVpcClient(
   435  		c.transport,
   436  		path.Join(c.path, "vpc"),
   437  	)
   438  }
   439  
   440  // ClusterPollRequest is the request for the Poll method.
   441  type ClusterPollRequest struct {
   442  	request    *ClusterGetRequest
   443  	interval   time.Duration
   444  	statuses   []int
   445  	predicates []func(interface{}) bool
   446  }
   447  
   448  // Parameter adds a query parameter to all the requests that will be used to retrieve the object.
   449  func (r *ClusterPollRequest) Parameter(name string, value interface{}) *ClusterPollRequest {
   450  	r.request.Parameter(name, value)
   451  	return r
   452  }
   453  
   454  // Header adds a request header to all the requests that will be used to retrieve the object.
   455  func (r *ClusterPollRequest) Header(name string, value interface{}) *ClusterPollRequest {
   456  	r.request.Header(name, value)
   457  	return r
   458  }
   459  
   460  // Interval sets the polling interval. This parameter is mandatory and must be greater than zero.
   461  func (r *ClusterPollRequest) Interval(value time.Duration) *ClusterPollRequest {
   462  	r.interval = value
   463  	return r
   464  }
   465  
   466  // Status set the expected status of the response. Multiple values can be set calling this method
   467  // multiple times. The response will be considered successful if the status is any of those values.
   468  func (r *ClusterPollRequest) Status(value int) *ClusterPollRequest {
   469  	r.statuses = append(r.statuses, value)
   470  	return r
   471  }
   472  
   473  // Predicate adds a predicate that the response should satisfy be considered successful. Multiple
   474  // predicates can be set calling this method multiple times. The response will be considered successful
   475  // if all the predicates are satisfied.
   476  func (r *ClusterPollRequest) Predicate(value func(*ClusterGetResponse) bool) *ClusterPollRequest {
   477  	r.predicates = append(r.predicates, func(response interface{}) bool {
   478  		return value(response.(*ClusterGetResponse))
   479  	})
   480  	return r
   481  }
   482  
   483  // StartContext starts the polling loop. Responses will be considered successful if the status is one of
   484  // the values specified with the Status method and if all the predicates specified with the Predicate
   485  // method return nil.
   486  //
   487  // The context must have a timeout or deadline, otherwise this method will immediately return an error.
   488  func (r *ClusterPollRequest) StartContext(ctx context.Context) (response *ClusterPollResponse, err error) {
   489  	result, err := helpers.PollContext(ctx, r.interval, r.statuses, r.predicates, r.task)
   490  	if result != nil {
   491  		response = &ClusterPollResponse{
   492  			response: result.(*ClusterGetResponse),
   493  		}
   494  	}
   495  	return
   496  }
   497  
   498  // task adapts the types of the request/response types so that they can be used with the generic
   499  // polling function from the helpers package.
   500  func (r *ClusterPollRequest) task(ctx context.Context) (status int, result interface{}, err error) {
   501  	response, err := r.request.SendContext(ctx)
   502  	if response != nil {
   503  		status = response.Status()
   504  		result = response
   505  	}
   506  	return
   507  }
   508  
   509  // ClusterPollResponse is the response for the Poll method.
   510  type ClusterPollResponse struct {
   511  	response *ClusterGetResponse
   512  }
   513  
   514  // Status returns the response status code.
   515  func (r *ClusterPollResponse) Status() int {
   516  	if r == nil {
   517  		return 0
   518  	}
   519  	return r.response.Status()
   520  }
   521  
   522  // Header returns header of the response.
   523  func (r *ClusterPollResponse) Header() http.Header {
   524  	if r == nil {
   525  		return nil
   526  	}
   527  	return r.response.Header()
   528  }
   529  
   530  // Error returns the response error.
   531  func (r *ClusterPollResponse) Error() *errors.Error {
   532  	if r == nil {
   533  		return nil
   534  	}
   535  	return r.response.Error()
   536  }
   537  
   538  // Body returns the value of the 'body' parameter.
   539  func (r *ClusterPollResponse) Body() *Cluster {
   540  	return r.response.Body()
   541  }
   542  
   543  // GetBody returns the value of the 'body' parameter and
   544  // a flag indicating if the parameter has a value.
   545  func (r *ClusterPollResponse) GetBody() (value *Cluster, ok bool) {
   546  	return r.response.GetBody()
   547  }
   548  
   549  // Poll creates a request to repeatedly retrieve the object till the response has one of a given set
   550  // of states and satisfies a set of predicates.
   551  func (c *ClusterClient) Poll() *ClusterPollRequest {
   552  	return &ClusterPollRequest{
   553  		request: c.Get(),
   554  	}
   555  }
   556  
   557  // ClusterDeleteRequest is the request for the 'delete' method.
   558  type ClusterDeleteRequest struct {
   559  	transport   http.RoundTripper
   560  	path        string
   561  	query       url.Values
   562  	header      http.Header
   563  	bestEffort  *bool
   564  	deprovision *bool
   565  	dryRun      *bool
   566  }
   567  
   568  // Parameter adds a query parameter.
   569  func (r *ClusterDeleteRequest) Parameter(name string, value interface{}) *ClusterDeleteRequest {
   570  	helpers.AddValue(&r.query, name, value)
   571  	return r
   572  }
   573  
   574  // Header adds a request header.
   575  func (r *ClusterDeleteRequest) Header(name string, value interface{}) *ClusterDeleteRequest {
   576  	helpers.AddHeader(&r.header, name, value)
   577  	return r
   578  }
   579  
   580  // Impersonate wraps requests on behalf of another user.
   581  // Note: Services that do not support this feature may silently ignore this call.
   582  func (r *ClusterDeleteRequest) Impersonate(user string) *ClusterDeleteRequest {
   583  	helpers.AddImpersonationHeader(&r.header, user)
   584  	return r
   585  }
   586  
   587  // BestEffort sets the value of the 'best_effort' parameter.
   588  //
   589  // BestEffort flag is used to check if the cluster deletion should be best-effort mode or not.
   590  func (r *ClusterDeleteRequest) BestEffort(value bool) *ClusterDeleteRequest {
   591  	r.bestEffort = &value
   592  	return r
   593  }
   594  
   595  // Deprovision sets the value of the 'deprovision' parameter.
   596  //
   597  // If false it will only delete from OCM but not the actual cluster resources.
   598  // false is only allowed for OCP clusters. true by default.
   599  func (r *ClusterDeleteRequest) Deprovision(value bool) *ClusterDeleteRequest {
   600  	r.deprovision = &value
   601  	return r
   602  }
   603  
   604  // DryRun sets the value of the 'dry_run' parameter.
   605  //
   606  // Dry run flag is used to check if the operation can be completed, but won't delete.
   607  func (r *ClusterDeleteRequest) DryRun(value bool) *ClusterDeleteRequest {
   608  	r.dryRun = &value
   609  	return r
   610  }
   611  
   612  // Send sends this request, waits for the response, and returns it.
   613  //
   614  // This is a potentially lengthy operation, as it requires network communication.
   615  // Consider using a context and the SendContext method.
   616  func (r *ClusterDeleteRequest) Send() (result *ClusterDeleteResponse, err error) {
   617  	return r.SendContext(context.Background())
   618  }
   619  
   620  // SendContext sends this request, waits for the response, and returns it.
   621  func (r *ClusterDeleteRequest) SendContext(ctx context.Context) (result *ClusterDeleteResponse, err error) {
   622  	query := helpers.CopyQuery(r.query)
   623  	if r.bestEffort != nil {
   624  		helpers.AddValue(&query, "best_effort", *r.bestEffort)
   625  	}
   626  	if r.deprovision != nil {
   627  		helpers.AddValue(&query, "deprovision", *r.deprovision)
   628  	}
   629  	if r.dryRun != nil {
   630  		helpers.AddValue(&query, "dry_run", *r.dryRun)
   631  	}
   632  	header := helpers.CopyHeader(r.header)
   633  	uri := &url.URL{
   634  		Path:     r.path,
   635  		RawQuery: query.Encode(),
   636  	}
   637  	request := &http.Request{
   638  		Method: "DELETE",
   639  		URL:    uri,
   640  		Header: header,
   641  	}
   642  	if ctx != nil {
   643  		request = request.WithContext(ctx)
   644  	}
   645  	response, err := r.transport.RoundTrip(request)
   646  	if err != nil {
   647  		return
   648  	}
   649  	defer response.Body.Close()
   650  	result = &ClusterDeleteResponse{}
   651  	result.status = response.StatusCode
   652  	result.header = response.Header
   653  	reader := bufio.NewReader(response.Body)
   654  	_, err = reader.Peek(1)
   655  	if err == io.EOF {
   656  		err = nil
   657  		return
   658  	}
   659  	if result.status >= 400 {
   660  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
   661  		if err != nil {
   662  			return
   663  		}
   664  		err = result.err
   665  		return
   666  	}
   667  	return
   668  }
   669  
   670  // ClusterDeleteResponse is the response for the 'delete' method.
   671  type ClusterDeleteResponse struct {
   672  	status int
   673  	header http.Header
   674  	err    *errors.Error
   675  }
   676  
   677  // Status returns the response status code.
   678  func (r *ClusterDeleteResponse) Status() int {
   679  	if r == nil {
   680  		return 0
   681  	}
   682  	return r.status
   683  }
   684  
   685  // Header returns header of the response.
   686  func (r *ClusterDeleteResponse) Header() http.Header {
   687  	if r == nil {
   688  		return nil
   689  	}
   690  	return r.header
   691  }
   692  
   693  // Error returns the response error.
   694  func (r *ClusterDeleteResponse) Error() *errors.Error {
   695  	if r == nil {
   696  		return nil
   697  	}
   698  	return r.err
   699  }
   700  
   701  // ClusterGetRequest is the request for the 'get' method.
   702  type ClusterGetRequest struct {
   703  	transport http.RoundTripper
   704  	path      string
   705  	query     url.Values
   706  	header    http.Header
   707  }
   708  
   709  // Parameter adds a query parameter.
   710  func (r *ClusterGetRequest) Parameter(name string, value interface{}) *ClusterGetRequest {
   711  	helpers.AddValue(&r.query, name, value)
   712  	return r
   713  }
   714  
   715  // Header adds a request header.
   716  func (r *ClusterGetRequest) Header(name string, value interface{}) *ClusterGetRequest {
   717  	helpers.AddHeader(&r.header, name, value)
   718  	return r
   719  }
   720  
   721  // Impersonate wraps requests on behalf of another user.
   722  // Note: Services that do not support this feature may silently ignore this call.
   723  func (r *ClusterGetRequest) Impersonate(user string) *ClusterGetRequest {
   724  	helpers.AddImpersonationHeader(&r.header, user)
   725  	return r
   726  }
   727  
   728  // Send sends this request, waits for the response, and returns it.
   729  //
   730  // This is a potentially lengthy operation, as it requires network communication.
   731  // Consider using a context and the SendContext method.
   732  func (r *ClusterGetRequest) Send() (result *ClusterGetResponse, err error) {
   733  	return r.SendContext(context.Background())
   734  }
   735  
   736  // SendContext sends this request, waits for the response, and returns it.
   737  func (r *ClusterGetRequest) SendContext(ctx context.Context) (result *ClusterGetResponse, err error) {
   738  	query := helpers.CopyQuery(r.query)
   739  	header := helpers.CopyHeader(r.header)
   740  	uri := &url.URL{
   741  		Path:     r.path,
   742  		RawQuery: query.Encode(),
   743  	}
   744  	request := &http.Request{
   745  		Method: "GET",
   746  		URL:    uri,
   747  		Header: header,
   748  	}
   749  	if ctx != nil {
   750  		request = request.WithContext(ctx)
   751  	}
   752  	response, err := r.transport.RoundTrip(request)
   753  	if err != nil {
   754  		return
   755  	}
   756  	defer response.Body.Close()
   757  	result = &ClusterGetResponse{}
   758  	result.status = response.StatusCode
   759  	result.header = response.Header
   760  	reader := bufio.NewReader(response.Body)
   761  	_, err = reader.Peek(1)
   762  	if err == io.EOF {
   763  		err = nil
   764  		return
   765  	}
   766  	if result.status >= 400 {
   767  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
   768  		if err != nil {
   769  			return
   770  		}
   771  		err = result.err
   772  		return
   773  	}
   774  	err = readClusterGetResponse(result, reader)
   775  	if err != nil {
   776  		return
   777  	}
   778  	return
   779  }
   780  
   781  // ClusterGetResponse is the response for the 'get' method.
   782  type ClusterGetResponse struct {
   783  	status int
   784  	header http.Header
   785  	err    *errors.Error
   786  	body   *Cluster
   787  }
   788  
   789  // Status returns the response status code.
   790  func (r *ClusterGetResponse) Status() int {
   791  	if r == nil {
   792  		return 0
   793  	}
   794  	return r.status
   795  }
   796  
   797  // Header returns header of the response.
   798  func (r *ClusterGetResponse) Header() http.Header {
   799  	if r == nil {
   800  		return nil
   801  	}
   802  	return r.header
   803  }
   804  
   805  // Error returns the response error.
   806  func (r *ClusterGetResponse) Error() *errors.Error {
   807  	if r == nil {
   808  		return nil
   809  	}
   810  	return r.err
   811  }
   812  
   813  // Body returns the value of the 'body' parameter.
   814  func (r *ClusterGetResponse) Body() *Cluster {
   815  	if r == nil {
   816  		return nil
   817  	}
   818  	return r.body
   819  }
   820  
   821  // GetBody returns the value of the 'body' parameter and
   822  // a flag indicating if the parameter has a value.
   823  func (r *ClusterGetResponse) GetBody() (value *Cluster, ok bool) {
   824  	ok = r != nil && r.body != nil
   825  	if ok {
   826  		value = r.body
   827  	}
   828  	return
   829  }
   830  
   831  // ClusterHibernateRequest is the request for the 'hibernate' method.
   832  type ClusterHibernateRequest struct {
   833  	transport http.RoundTripper
   834  	path      string
   835  	query     url.Values
   836  	header    http.Header
   837  }
   838  
   839  // Parameter adds a query parameter.
   840  func (r *ClusterHibernateRequest) Parameter(name string, value interface{}) *ClusterHibernateRequest {
   841  	helpers.AddValue(&r.query, name, value)
   842  	return r
   843  }
   844  
   845  // Header adds a request header.
   846  func (r *ClusterHibernateRequest) Header(name string, value interface{}) *ClusterHibernateRequest {
   847  	helpers.AddHeader(&r.header, name, value)
   848  	return r
   849  }
   850  
   851  // Impersonate wraps requests on behalf of another user.
   852  // Note: Services that do not support this feature may silently ignore this call.
   853  func (r *ClusterHibernateRequest) Impersonate(user string) *ClusterHibernateRequest {
   854  	helpers.AddImpersonationHeader(&r.header, user)
   855  	return r
   856  }
   857  
   858  // Send sends this request, waits for the response, and returns it.
   859  //
   860  // This is a potentially lengthy operation, as it requires network communication.
   861  // Consider using a context and the SendContext method.
   862  func (r *ClusterHibernateRequest) Send() (result *ClusterHibernateResponse, err error) {
   863  	return r.SendContext(context.Background())
   864  }
   865  
   866  // SendContext sends this request, waits for the response, and returns it.
   867  func (r *ClusterHibernateRequest) SendContext(ctx context.Context) (result *ClusterHibernateResponse, err error) {
   868  	query := helpers.CopyQuery(r.query)
   869  	header := helpers.CopyHeader(r.header)
   870  	uri := &url.URL{
   871  		Path:     r.path,
   872  		RawQuery: query.Encode(),
   873  	}
   874  	request := &http.Request{
   875  		Method: "POST",
   876  		URL:    uri,
   877  		Header: header,
   878  	}
   879  	if ctx != nil {
   880  		request = request.WithContext(ctx)
   881  	}
   882  	response, err := r.transport.RoundTrip(request)
   883  	if err != nil {
   884  		return
   885  	}
   886  	defer response.Body.Close()
   887  	result = &ClusterHibernateResponse{}
   888  	result.status = response.StatusCode
   889  	result.header = response.Header
   890  	reader := bufio.NewReader(response.Body)
   891  	_, err = reader.Peek(1)
   892  	if err == io.EOF {
   893  		err = nil
   894  		return
   895  	}
   896  	if result.status >= 400 {
   897  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
   898  		if err != nil {
   899  			return
   900  		}
   901  		err = result.err
   902  		return
   903  	}
   904  	return
   905  }
   906  
   907  // ClusterHibernateResponse is the response for the 'hibernate' method.
   908  type ClusterHibernateResponse struct {
   909  	status int
   910  	header http.Header
   911  	err    *errors.Error
   912  }
   913  
   914  // Status returns the response status code.
   915  func (r *ClusterHibernateResponse) Status() int {
   916  	if r == nil {
   917  		return 0
   918  	}
   919  	return r.status
   920  }
   921  
   922  // Header returns header of the response.
   923  func (r *ClusterHibernateResponse) Header() http.Header {
   924  	if r == nil {
   925  		return nil
   926  	}
   927  	return r.header
   928  }
   929  
   930  // Error returns the response error.
   931  func (r *ClusterHibernateResponse) Error() *errors.Error {
   932  	if r == nil {
   933  		return nil
   934  	}
   935  	return r.err
   936  }
   937  
   938  // ClusterResumeRequest is the request for the 'resume' method.
   939  type ClusterResumeRequest struct {
   940  	transport http.RoundTripper
   941  	path      string
   942  	query     url.Values
   943  	header    http.Header
   944  }
   945  
   946  // Parameter adds a query parameter.
   947  func (r *ClusterResumeRequest) Parameter(name string, value interface{}) *ClusterResumeRequest {
   948  	helpers.AddValue(&r.query, name, value)
   949  	return r
   950  }
   951  
   952  // Header adds a request header.
   953  func (r *ClusterResumeRequest) Header(name string, value interface{}) *ClusterResumeRequest {
   954  	helpers.AddHeader(&r.header, name, value)
   955  	return r
   956  }
   957  
   958  // Impersonate wraps requests on behalf of another user.
   959  // Note: Services that do not support this feature may silently ignore this call.
   960  func (r *ClusterResumeRequest) Impersonate(user string) *ClusterResumeRequest {
   961  	helpers.AddImpersonationHeader(&r.header, user)
   962  	return r
   963  }
   964  
   965  // Send sends this request, waits for the response, and returns it.
   966  //
   967  // This is a potentially lengthy operation, as it requires network communication.
   968  // Consider using a context and the SendContext method.
   969  func (r *ClusterResumeRequest) Send() (result *ClusterResumeResponse, err error) {
   970  	return r.SendContext(context.Background())
   971  }
   972  
   973  // SendContext sends this request, waits for the response, and returns it.
   974  func (r *ClusterResumeRequest) SendContext(ctx context.Context) (result *ClusterResumeResponse, err error) {
   975  	query := helpers.CopyQuery(r.query)
   976  	header := helpers.CopyHeader(r.header)
   977  	uri := &url.URL{
   978  		Path:     r.path,
   979  		RawQuery: query.Encode(),
   980  	}
   981  	request := &http.Request{
   982  		Method: "POST",
   983  		URL:    uri,
   984  		Header: header,
   985  	}
   986  	if ctx != nil {
   987  		request = request.WithContext(ctx)
   988  	}
   989  	response, err := r.transport.RoundTrip(request)
   990  	if err != nil {
   991  		return
   992  	}
   993  	defer response.Body.Close()
   994  	result = &ClusterResumeResponse{}
   995  	result.status = response.StatusCode
   996  	result.header = response.Header
   997  	reader := bufio.NewReader(response.Body)
   998  	_, err = reader.Peek(1)
   999  	if err == io.EOF {
  1000  		err = nil
  1001  		return
  1002  	}
  1003  	if result.status >= 400 {
  1004  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
  1005  		if err != nil {
  1006  			return
  1007  		}
  1008  		err = result.err
  1009  		return
  1010  	}
  1011  	return
  1012  }
  1013  
  1014  // ClusterResumeResponse is the response for the 'resume' method.
  1015  type ClusterResumeResponse struct {
  1016  	status int
  1017  	header http.Header
  1018  	err    *errors.Error
  1019  }
  1020  
  1021  // Status returns the response status code.
  1022  func (r *ClusterResumeResponse) Status() int {
  1023  	if r == nil {
  1024  		return 0
  1025  	}
  1026  	return r.status
  1027  }
  1028  
  1029  // Header returns header of the response.
  1030  func (r *ClusterResumeResponse) Header() http.Header {
  1031  	if r == nil {
  1032  		return nil
  1033  	}
  1034  	return r.header
  1035  }
  1036  
  1037  // Error returns the response error.
  1038  func (r *ClusterResumeResponse) Error() *errors.Error {
  1039  	if r == nil {
  1040  		return nil
  1041  	}
  1042  	return r.err
  1043  }
  1044  
  1045  // ClusterUpdateRequest is the request for the 'update' method.
  1046  type ClusterUpdateRequest struct {
  1047  	transport http.RoundTripper
  1048  	path      string
  1049  	query     url.Values
  1050  	header    http.Header
  1051  	body      *Cluster
  1052  }
  1053  
  1054  // Parameter adds a query parameter.
  1055  func (r *ClusterUpdateRequest) Parameter(name string, value interface{}) *ClusterUpdateRequest {
  1056  	helpers.AddValue(&r.query, name, value)
  1057  	return r
  1058  }
  1059  
  1060  // Header adds a request header.
  1061  func (r *ClusterUpdateRequest) Header(name string, value interface{}) *ClusterUpdateRequest {
  1062  	helpers.AddHeader(&r.header, name, value)
  1063  	return r
  1064  }
  1065  
  1066  // Impersonate wraps requests on behalf of another user.
  1067  // Note: Services that do not support this feature may silently ignore this call.
  1068  func (r *ClusterUpdateRequest) Impersonate(user string) *ClusterUpdateRequest {
  1069  	helpers.AddImpersonationHeader(&r.header, user)
  1070  	return r
  1071  }
  1072  
  1073  // Body sets the value of the 'body' parameter.
  1074  func (r *ClusterUpdateRequest) Body(value *Cluster) *ClusterUpdateRequest {
  1075  	r.body = value
  1076  	return r
  1077  }
  1078  
  1079  // Send sends this request, waits for the response, and returns it.
  1080  //
  1081  // This is a potentially lengthy operation, as it requires network communication.
  1082  // Consider using a context and the SendContext method.
  1083  func (r *ClusterUpdateRequest) Send() (result *ClusterUpdateResponse, err error) {
  1084  	return r.SendContext(context.Background())
  1085  }
  1086  
  1087  // SendContext sends this request, waits for the response, and returns it.
  1088  func (r *ClusterUpdateRequest) SendContext(ctx context.Context) (result *ClusterUpdateResponse, err error) {
  1089  	query := helpers.CopyQuery(r.query)
  1090  	header := helpers.CopyHeader(r.header)
  1091  	buffer := &bytes.Buffer{}
  1092  	err = writeClusterUpdateRequest(r, buffer)
  1093  	if err != nil {
  1094  		return
  1095  	}
  1096  	uri := &url.URL{
  1097  		Path:     r.path,
  1098  		RawQuery: query.Encode(),
  1099  	}
  1100  	request := &http.Request{
  1101  		Method: "PATCH",
  1102  		URL:    uri,
  1103  		Header: header,
  1104  		Body:   io.NopCloser(buffer),
  1105  	}
  1106  	if ctx != nil {
  1107  		request = request.WithContext(ctx)
  1108  	}
  1109  	response, err := r.transport.RoundTrip(request)
  1110  	if err != nil {
  1111  		return
  1112  	}
  1113  	defer response.Body.Close()
  1114  	result = &ClusterUpdateResponse{}
  1115  	result.status = response.StatusCode
  1116  	result.header = response.Header
  1117  	reader := bufio.NewReader(response.Body)
  1118  	_, err = reader.Peek(1)
  1119  	if err == io.EOF {
  1120  		err = nil
  1121  		return
  1122  	}
  1123  	if result.status >= 400 {
  1124  		result.err, err = errors.UnmarshalErrorStatus(reader, result.status)
  1125  		if err != nil {
  1126  			return
  1127  		}
  1128  		err = result.err
  1129  		return
  1130  	}
  1131  	err = readClusterUpdateResponse(result, reader)
  1132  	if err != nil {
  1133  		return
  1134  	}
  1135  	return
  1136  }
  1137  
  1138  // ClusterUpdateResponse is the response for the 'update' method.
  1139  type ClusterUpdateResponse struct {
  1140  	status int
  1141  	header http.Header
  1142  	err    *errors.Error
  1143  	body   *Cluster
  1144  }
  1145  
  1146  // Status returns the response status code.
  1147  func (r *ClusterUpdateResponse) Status() int {
  1148  	if r == nil {
  1149  		return 0
  1150  	}
  1151  	return r.status
  1152  }
  1153  
  1154  // Header returns header of the response.
  1155  func (r *ClusterUpdateResponse) Header() http.Header {
  1156  	if r == nil {
  1157  		return nil
  1158  	}
  1159  	return r.header
  1160  }
  1161  
  1162  // Error returns the response error.
  1163  func (r *ClusterUpdateResponse) Error() *errors.Error {
  1164  	if r == nil {
  1165  		return nil
  1166  	}
  1167  	return r.err
  1168  }
  1169  
  1170  // Body returns the value of the 'body' parameter.
  1171  func (r *ClusterUpdateResponse) Body() *Cluster {
  1172  	if r == nil {
  1173  		return nil
  1174  	}
  1175  	return r.body
  1176  }
  1177  
  1178  // GetBody returns the value of the 'body' parameter and
  1179  // a flag indicating if the parameter has a value.
  1180  func (r *ClusterUpdateResponse) GetBody() (value *Cluster, ok bool) {
  1181  	ok = r != nil && r.body != nil
  1182  	if ok {
  1183  		value = r.body
  1184  	}
  1185  	return
  1186  }