// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. // Code generated. DO NOT EDIT. // Container Engine for Kubernetes API // // Container Engine for Kubernetes API // package containerengine import ( "context" "fmt" "github.com/oracle/oci-go-sdk/common" "net/http" ) //ContainerEngineClient a client for ContainerEngine type ContainerEngineClient struct { common.BaseClient config *common.ConfigurationProvider } // NewContainerEngineClientWithConfigurationProvider Creates a new default ContainerEngine client with the given configuration provider. // the configuration provider will be used for the default signer as well as reading the region func NewContainerEngineClientWithConfigurationProvider(configProvider common.ConfigurationProvider) (client ContainerEngineClient, err error) { baseClient, err := common.NewClientWithConfig(configProvider) if err != nil { return } client = ContainerEngineClient{BaseClient: baseClient} client.BasePath = "20180222" err = client.setConfigurationProvider(configProvider) return } // SetRegion overrides the region of this client. func (client *ContainerEngineClient) SetRegion(region string) { client.Host = fmt.Sprintf(common.DefaultHostURLTemplate, "containerengine", region) } // SetConfigurationProvider sets the configuration provider including the region, returns an error if is not valid func (client *ContainerEngineClient) setConfigurationProvider(configProvider common.ConfigurationProvider) error { if ok, err := common.IsConfigurationProviderValid(configProvider); !ok { return err } // Error has been checked already region, _ := configProvider.Region() client.SetRegion(region) client.config = &configProvider return nil } // ConfigurationProvider the ConfigurationProvider used in this client, or null if none set func (client *ContainerEngineClient) ConfigurationProvider() *common.ConfigurationProvider { return client.config } // CreateCluster Create a new cluster. func (client ContainerEngineClient) CreateCluster(ctx context.Context, request CreateClusterRequest) (response CreateClusterResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.createCluster, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(CreateClusterResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into CreateClusterResponse") } return } // createCluster implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) createCluster(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodPost, "/clusters") if err != nil { return nil, err } var response CreateClusterResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // CreateKubeconfig Create the Kubeconfig YAML for a cluster. func (client ContainerEngineClient) CreateKubeconfig(ctx context.Context, request CreateKubeconfigRequest) (response CreateKubeconfigResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.createKubeconfig, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(CreateKubeconfigResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into CreateKubeconfigResponse") } return } // createKubeconfig implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) createKubeconfig(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodPost, "/clusters/{clusterId}/kubeconfig/content") if err != nil { return nil, err } var response CreateKubeconfigResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // CreateNodePool Create a new node pool. func (client ContainerEngineClient) CreateNodePool(ctx context.Context, request CreateNodePoolRequest) (response CreateNodePoolResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.createNodePool, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(CreateNodePoolResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into CreateNodePoolResponse") } return } // createNodePool implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) createNodePool(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodPost, "/nodePools") if err != nil { return nil, err } var response CreateNodePoolResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // DeleteCluster Delete a cluster. func (client ContainerEngineClient) DeleteCluster(ctx context.Context, request DeleteClusterRequest) (response DeleteClusterResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.deleteCluster, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(DeleteClusterResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into DeleteClusterResponse") } return } // deleteCluster implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) deleteCluster(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodDelete, "/clusters/{clusterId}") if err != nil { return nil, err } var response DeleteClusterResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // DeleteNodePool Delete a node pool. func (client ContainerEngineClient) DeleteNodePool(ctx context.Context, request DeleteNodePoolRequest) (response DeleteNodePoolResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.deleteNodePool, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(DeleteNodePoolResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into DeleteNodePoolResponse") } return } // deleteNodePool implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) deleteNodePool(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodDelete, "/nodePools/{nodePoolId}") if err != nil { return nil, err } var response DeleteNodePoolResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // DeleteWorkRequest Cancel a work request that has not started. func (client ContainerEngineClient) DeleteWorkRequest(ctx context.Context, request DeleteWorkRequestRequest) (response DeleteWorkRequestResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.deleteWorkRequest, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(DeleteWorkRequestResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into DeleteWorkRequestResponse") } return } // deleteWorkRequest implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) deleteWorkRequest(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodDelete, "/workRequests/{workRequestId}") if err != nil { return nil, err } var response DeleteWorkRequestResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // GetCluster Get the details of a cluster. func (client ContainerEngineClient) GetCluster(ctx context.Context, request GetClusterRequest) (response GetClusterResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.getCluster, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(GetClusterResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into GetClusterResponse") } return } // getCluster implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) getCluster(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/clusters/{clusterId}") if err != nil { return nil, err } var response GetClusterResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // GetClusterOptions Get options available for clusters. func (client ContainerEngineClient) GetClusterOptions(ctx context.Context, request GetClusterOptionsRequest) (response GetClusterOptionsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.getClusterOptions, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(GetClusterOptionsResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into GetClusterOptionsResponse") } return } // getClusterOptions implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) getClusterOptions(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/clusterOptions/{clusterOptionId}") if err != nil { return nil, err } var response GetClusterOptionsResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // GetNodePool Get the details of a node pool. func (client ContainerEngineClient) GetNodePool(ctx context.Context, request GetNodePoolRequest) (response GetNodePoolResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.getNodePool, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(GetNodePoolResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into GetNodePoolResponse") } return } // getNodePool implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) getNodePool(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/nodePools/{nodePoolId}") if err != nil { return nil, err } var response GetNodePoolResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // GetNodePoolOptions Get options available for node pools. func (client ContainerEngineClient) GetNodePoolOptions(ctx context.Context, request GetNodePoolOptionsRequest) (response GetNodePoolOptionsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.getNodePoolOptions, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(GetNodePoolOptionsResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into GetNodePoolOptionsResponse") } return } // getNodePoolOptions implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) getNodePoolOptions(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/nodePoolOptions/{nodePoolOptionId}") if err != nil { return nil, err } var response GetNodePoolOptionsResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // GetWorkRequest Get the details of a work request. func (client ContainerEngineClient) GetWorkRequest(ctx context.Context, request GetWorkRequestRequest) (response GetWorkRequestResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.getWorkRequest, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(GetWorkRequestResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into GetWorkRequestResponse") } return } // getWorkRequest implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) getWorkRequest(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/workRequests/{workRequestId}") if err != nil { return nil, err } var response GetWorkRequestResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // ListClusters List all the cluster objects in a compartment. func (client ContainerEngineClient) ListClusters(ctx context.Context, request ListClustersRequest) (response ListClustersResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.listClusters, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(ListClustersResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into ListClustersResponse") } return } // listClusters implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) listClusters(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/clusters") if err != nil { return nil, err } var response ListClustersResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // ListNodePools List all the node pools in a compartment, and optionally filter by cluster. func (client ContainerEngineClient) ListNodePools(ctx context.Context, request ListNodePoolsRequest) (response ListNodePoolsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.listNodePools, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(ListNodePoolsResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into ListNodePoolsResponse") } return } // listNodePools implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) listNodePools(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/nodePools") if err != nil { return nil, err } var response ListNodePoolsResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // ListWorkRequestErrors Get the errors of a work request. func (client ContainerEngineClient) ListWorkRequestErrors(ctx context.Context, request ListWorkRequestErrorsRequest) (response ListWorkRequestErrorsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.listWorkRequestErrors, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(ListWorkRequestErrorsResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into ListWorkRequestErrorsResponse") } return } // listWorkRequestErrors implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) listWorkRequestErrors(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/workRequests/{workRequestId}/errors") if err != nil { return nil, err } var response ListWorkRequestErrorsResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // ListWorkRequestLogs Get the logs of a work request. func (client ContainerEngineClient) ListWorkRequestLogs(ctx context.Context, request ListWorkRequestLogsRequest) (response ListWorkRequestLogsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.listWorkRequestLogs, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(ListWorkRequestLogsResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into ListWorkRequestLogsResponse") } return } // listWorkRequestLogs implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) listWorkRequestLogs(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/workRequests/{workRequestId}/logs") if err != nil { return nil, err } var response ListWorkRequestLogsResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // ListWorkRequests List all work requests in a compartment. func (client ContainerEngineClient) ListWorkRequests(ctx context.Context, request ListWorkRequestsRequest) (response ListWorkRequestsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.listWorkRequests, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(ListWorkRequestsResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into ListWorkRequestsResponse") } return } // listWorkRequests implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) listWorkRequests(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodGet, "/workRequests") if err != nil { return nil, err } var response ListWorkRequestsResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // UpdateCluster Update the details of a cluster. func (client ContainerEngineClient) UpdateCluster(ctx context.Context, request UpdateClusterRequest) (response UpdateClusterResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.updateCluster, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(UpdateClusterResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into UpdateClusterResponse") } return } // updateCluster implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) updateCluster(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodPut, "/clusters/{clusterId}") if err != nil { return nil, err } var response UpdateClusterResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err } // UpdateNodePool Update the details of a node pool. func (client ContainerEngineClient) UpdateNodePool(ctx context.Context, request UpdateNodePoolRequest) (response UpdateNodePoolResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() if request.RetryPolicy() != nil { policy = *request.RetryPolicy() } ociResponse, err = common.Retry(ctx, request, client.updateNodePool, policy) if err != nil { return } if convertedResponse, ok := ociResponse.(UpdateNodePoolResponse); ok { response = convertedResponse } else { err = fmt.Errorf("failed to convert OCIResponse into UpdateNodePoolResponse") } return } // updateNodePool implements the OCIOperation interface (enables retrying operations) func (client ContainerEngineClient) updateNodePool(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { httpRequest, err := request.HTTPRequest(http.MethodPut, "/nodePools/{nodePoolId}") if err != nil { return nil, err } var response UpdateNodePoolResponse var httpResponse *http.Response httpResponse, err = client.Call(ctx, &httpRequest) defer common.CloseBodyIfValid(httpResponse) response.RawResponse = httpResponse if err != nil { return response, err } err = common.UnmarshalResponse(httpResponse, &response) return response, err }