diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/CHANGELOG.md b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/_meta.json b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/_meta.json new file mode 100644 index 000000000000..160fbd07c2a6 --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "20b3d0478638e6b9382d49574084a8d6ad165129", + "readme": "/_/azure-rest-api-specs/specification/redhatopenshift/resource-manager/readme.md", + "tag": "package-2021-09-01-preview", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2021-09-01-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/redhatopenshift/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/client.go b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/client.go new file mode 100644 index 000000000000..fddac0cc4cee --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/client.go @@ -0,0 +1,41 @@ +// Package redhatopenshift implements the Azure ARM Redhatopenshift service API version 2021-09-01-preview. +// +// Rest API for Azure Red Hat OpenShift 4 +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Redhatopenshift + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Redhatopenshift. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/enums.go b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/enums.go new file mode 100644 index 000000000000..65df7fb44d95 --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/enums.go @@ -0,0 +1,151 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// EncryptionAtHost enumerates the values for encryption at host. +type EncryptionAtHost string + +const ( + // Disabled ... + Disabled EncryptionAtHost = "Disabled" + // Enabled ... + Enabled EncryptionAtHost = "Enabled" +) + +// PossibleEncryptionAtHostValues returns an array of possible values for the EncryptionAtHost const type. +func PossibleEncryptionAtHostValues() []EncryptionAtHost { + return []EncryptionAtHost{Disabled, Enabled} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // AdminUpdating ... + AdminUpdating ProvisioningState = "AdminUpdating" + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{AdminUpdating, Creating, Deleting, Failed, Succeeded, Updating} +} + +// SoftwareDefinedNetwork enumerates the values for software defined network. +type SoftwareDefinedNetwork string + +const ( + // OpenShiftSDN ... + OpenShiftSDN SoftwareDefinedNetwork = "OpenShiftSDN" + // OVNKubernetes ... + OVNKubernetes SoftwareDefinedNetwork = "OVNKubernetes" +) + +// PossibleSoftwareDefinedNetworkValues returns an array of possible values for the SoftwareDefinedNetwork const type. +func PossibleSoftwareDefinedNetworkValues() []SoftwareDefinedNetwork { + return []SoftwareDefinedNetwork{OpenShiftSDN, OVNKubernetes} +} + +// Visibility enumerates the values for visibility. +type Visibility string + +const ( + // Private ... + Private Visibility = "Private" + // Public ... + Public Visibility = "Public" +) + +// PossibleVisibilityValues returns an array of possible values for the Visibility const type. +func PossibleVisibilityValues() []Visibility { + return []Visibility{Private, Public} +} + +// VMSize enumerates the values for vm size. +type VMSize string + +const ( + // StandardD16asV4 ... + StandardD16asV4 VMSize = "Standard_D16as_v4" + // StandardD16sV3 ... + StandardD16sV3 VMSize = "Standard_D16s_v3" + // StandardD2sV3 ... + StandardD2sV3 VMSize = "Standard_D2s_v3" + // StandardD32asV4 ... + StandardD32asV4 VMSize = "Standard_D32as_v4" + // StandardD32sV3 ... + StandardD32sV3 VMSize = "Standard_D32s_v3" + // StandardD4asV4 ... + StandardD4asV4 VMSize = "Standard_D4as_v4" + // StandardD4sV3 ... + StandardD4sV3 VMSize = "Standard_D4s_v3" + // StandardD8asV4 ... + StandardD8asV4 VMSize = "Standard_D8as_v4" + // StandardD8sV3 ... + StandardD8sV3 VMSize = "Standard_D8s_v3" + // StandardE16sV3 ... + StandardE16sV3 VMSize = "Standard_E16s_v3" + // StandardE32sV3 ... + StandardE32sV3 VMSize = "Standard_E32s_v3" + // StandardE4sV3 ... + StandardE4sV3 VMSize = "Standard_E4s_v3" + // StandardE64isV3 ... + StandardE64isV3 VMSize = "Standard_E64is_v3" + // StandardE64iV3 ... + StandardE64iV3 VMSize = "Standard_E64i_v3" + // StandardE8sV3 ... + StandardE8sV3 VMSize = "Standard_E8s_v3" + // StandardF16sV2 ... + StandardF16sV2 VMSize = "Standard_F16s_v2" + // StandardF32sV2 ... + StandardF32sV2 VMSize = "Standard_F32s_v2" + // StandardF4sV2 ... + StandardF4sV2 VMSize = "Standard_F4s_v2" + // StandardF72sV2 ... + StandardF72sV2 VMSize = "Standard_F72s_v2" + // StandardF8sV2 ... + StandardF8sV2 VMSize = "Standard_F8s_v2" + // StandardG5 ... + StandardG5 VMSize = "Standard_G5" + // StandardGS5 ... + StandardGS5 VMSize = "Standard_GS5" + // StandardM128ms ... + StandardM128ms VMSize = "Standard_M128ms" +) + +// PossibleVMSizeValues returns an array of possible values for the VMSize const type. +func PossibleVMSizeValues() []VMSize { + return []VMSize{StandardD16asV4, StandardD16sV3, StandardD2sV3, StandardD32asV4, StandardD32sV3, StandardD4asV4, StandardD4sV3, StandardD8asV4, StandardD8sV3, StandardE16sV3, StandardE32sV3, StandardE4sV3, StandardE64isV3, StandardE64iV3, StandardE8sV3, StandardF16sV2, StandardF32sV2, StandardF4sV2, StandardF72sV2, StandardF8sV2, StandardG5, StandardGS5, StandardM128ms} +} diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/models.go b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/models.go new file mode 100644 index 000000000000..c7e3be994b4c --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/models.go @@ -0,0 +1,897 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/mgmt/2021-09-01-preview/redhatopenshift" + +// APIServerProfile aPIServerProfile represents an API server profile. +type APIServerProfile struct { + // Visibility - API server visibility. Possible values include: 'Private', 'Public' + Visibility Visibility `json:"visibility,omitempty"` + // URL - The URL to access the cluster API server. + URL *string `json:"url,omitempty"` + // IP - The IP of the cluster API server. + IP *string `json:"ip,omitempty"` +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CloudError cloudError represents a cloud error. +type CloudError struct { + // Error - An error response from the service. + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody cloudErrorBody represents the body of a cloud error. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` + // Details - A list of additional details about the error. + Details *[]CloudErrorBody `json:"details,omitempty"` +} + +// ClusterProfile clusterProfile represents a cluster profile. +type ClusterProfile struct { + // PullSecret - The pull secret for the cluster. + PullSecret *string `json:"pullSecret,omitempty"` + // Domain - The domain for the cluster. + Domain *string `json:"domain,omitempty"` + // Version - The version of the cluster. + Version *string `json:"version,omitempty"` + // ResourceGroupID - The ID of the cluster resource group. + ResourceGroupID *string `json:"resourceGroupId,omitempty"` +} + +// ConsoleProfile consoleProfile represents a console profile. +type ConsoleProfile struct { + // URL - The URL to access the cluster console. + URL *string `json:"url,omitempty"` +} + +// Display display represents the display details of an operation. +type Display struct { + // Provider - Friendly name of the resource provider. + Provider *string `json:"provider,omitempty"` + // Resource - Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: read, write, delete, listKeys/action, etc. + Operation *string `json:"operation,omitempty"` + // Description - Friendly name of the operation. + Description *string `json:"description,omitempty"` +} + +// IngressProfile ingressProfile represents an ingress profile. +type IngressProfile struct { + // Name - The ingress profile name. + Name *string `json:"name,omitempty"` + // Visibility - Ingress visibility. Possible values include: 'Private', 'Public' + Visibility Visibility `json:"visibility,omitempty"` + // IP - The IP of the ingress. + IP *string `json:"ip,omitempty"` +} + +// MasterProfile masterProfile represents a master profile. +type MasterProfile struct { + // VMSize - The size of the master VMs. Possible values include: 'StandardD16asV4', 'StandardD16sV3', 'StandardD2sV3', 'StandardD32asV4', 'StandardD32sV3', 'StandardD4asV4', 'StandardD4sV3', 'StandardD8asV4', 'StandardD8sV3', 'StandardE16sV3', 'StandardE32sV3', 'StandardE4sV3', 'StandardE64iV3', 'StandardE64isV3', 'StandardE8sV3', 'StandardF16sV2', 'StandardF32sV2', 'StandardF4sV2', 'StandardF72sV2', 'StandardF8sV2', 'StandardG5', 'StandardGS5', 'StandardM128ms' + VMSize VMSize `json:"vmSize,omitempty"` + // SubnetID - The Azure resource ID of the master subnet. + SubnetID *string `json:"subnetId,omitempty"` + // EncryptionAtHost - Whether master virtual machines are encrypted at host. Possible values include: 'Disabled', 'Enabled' + EncryptionAtHost EncryptionAtHost `json:"encryptionAtHost,omitempty"` + // DiskEncryptionSetID - The resource ID of an associated DiskEncryptionSet, if applicable. + DiskEncryptionSetID *string `json:"diskEncryptionSetId,omitempty"` +} + +// NetworkProfile networkProfile represents a network profile. +type NetworkProfile struct { + // SoftwareDefinedNetwork - The software defined network (SDN) to use when installing the cluster. Possible values include: 'OVNKubernetes', 'OpenShiftSDN' + SoftwareDefinedNetwork SoftwareDefinedNetwork `json:"softwareDefinedNetwork,omitempty"` + // PodCidr - The CIDR used for OpenShift/Kubernetes Pods. + PodCidr *string `json:"podCidr,omitempty"` + // ServiceCidr - The CIDR used for OpenShift/Kubernetes Services. + ServiceCidr *string `json:"serviceCidr,omitempty"` +} + +// OpenShiftCluster openShiftCluster represents an Azure Red Hat OpenShift cluster. +type OpenShiftCluster struct { + autorest.Response `json:"-"` + // OpenShiftClusterProperties - The cluster properties. + *OpenShiftClusterProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OpenShiftCluster. +func (osc OpenShiftCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if osc.OpenShiftClusterProperties != nil { + objectMap["properties"] = osc.OpenShiftClusterProperties + } + if osc.Tags != nil { + objectMap["tags"] = osc.Tags + } + if osc.Location != nil { + objectMap["location"] = osc.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OpenShiftCluster struct. +func (osc *OpenShiftCluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var openShiftClusterProperties OpenShiftClusterProperties + err = json.Unmarshal(*v, &openShiftClusterProperties) + if err != nil { + return err + } + osc.OpenShiftClusterProperties = &openShiftClusterProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + osc.SystemData = &systemData + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + osc.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + osc.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + osc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + osc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + osc.Type = &typeVar + } + } + } + + return nil +} + +// OpenShiftClusterAdminKubeconfig openShiftClusterAdminKubeconfig represents an OpenShift cluster's admin +// kubeconfig. +type OpenShiftClusterAdminKubeconfig struct { + autorest.Response `json:"-"` + // Kubeconfig - The base64-encoded kubeconfig file. + Kubeconfig *string `json:"kubeconfig,omitempty"` +} + +// OpenShiftClusterCredentials openShiftClusterCredentials represents an OpenShift cluster's credentials. +type OpenShiftClusterCredentials struct { + autorest.Response `json:"-"` + // KubeadminUsername - The username for the kubeadmin user. + KubeadminUsername *string `json:"kubeadminUsername,omitempty"` + // KubeadminPassword - The password for the kubeadmin user. + KubeadminPassword *string `json:"kubeadminPassword,omitempty"` +} + +// OpenShiftClusterList openShiftClusterList represents a list of OpenShift clusters. +type OpenShiftClusterList struct { + autorest.Response `json:"-"` + // Value - The list of OpenShift clusters. + Value *[]OpenShiftCluster `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// OpenShiftClusterListIterator provides access to a complete listing of OpenShiftCluster values. +type OpenShiftClusterListIterator struct { + i int + page OpenShiftClusterListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OpenShiftClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClusterListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OpenShiftClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OpenShiftClusterListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OpenShiftClusterListIterator) Response() OpenShiftClusterList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OpenShiftClusterListIterator) Value() OpenShiftCluster { + if !iter.page.NotDone() { + return OpenShiftCluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OpenShiftClusterListIterator type. +func NewOpenShiftClusterListIterator(page OpenShiftClusterListPage) OpenShiftClusterListIterator { + return OpenShiftClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oscl OpenShiftClusterList) IsEmpty() bool { + return oscl.Value == nil || len(*oscl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (oscl OpenShiftClusterList) hasNextLink() bool { + return oscl.NextLink != nil && len(*oscl.NextLink) != 0 +} + +// openShiftClusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oscl OpenShiftClusterList) openShiftClusterListPreparer(ctx context.Context) (*http.Request, error) { + if !oscl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oscl.NextLink))) +} + +// OpenShiftClusterListPage contains a page of OpenShiftCluster values. +type OpenShiftClusterListPage struct { + fn func(context.Context, OpenShiftClusterList) (OpenShiftClusterList, error) + oscl OpenShiftClusterList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OpenShiftClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClusterListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.oscl) + if err != nil { + return err + } + page.oscl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OpenShiftClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OpenShiftClusterListPage) NotDone() bool { + return !page.oscl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OpenShiftClusterListPage) Response() OpenShiftClusterList { + return page.oscl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OpenShiftClusterListPage) Values() []OpenShiftCluster { + if page.oscl.IsEmpty() { + return nil + } + return *page.oscl.Value +} + +// Creates a new instance of the OpenShiftClusterListPage type. +func NewOpenShiftClusterListPage(cur OpenShiftClusterList, getNextPage func(context.Context, OpenShiftClusterList) (OpenShiftClusterList, error)) OpenShiftClusterListPage { + return OpenShiftClusterListPage{ + fn: getNextPage, + oscl: cur, + } +} + +// OpenShiftClusterProperties openShiftClusterProperties represents an OpenShift cluster's properties. +type OpenShiftClusterProperties struct { + // ProvisioningState - The cluster provisioning state. Possible values include: 'AdminUpdating', 'Creating', 'Deleting', 'Failed', 'Succeeded', 'Updating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ClusterProfile - The cluster profile. + ClusterProfile *ClusterProfile `json:"clusterProfile,omitempty"` + // ConsoleProfile - The console profile. + ConsoleProfile *ConsoleProfile `json:"consoleProfile,omitempty"` + // ServicePrincipalProfile - The cluster service principal profile. + ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"` + // NetworkProfile - The cluster network profile. + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + // MasterProfile - The cluster master profile. + MasterProfile *MasterProfile `json:"masterProfile,omitempty"` + // WorkerProfiles - The cluster worker profiles. + WorkerProfiles *[]WorkerProfile `json:"workerProfiles,omitempty"` + // ApiserverProfile - The cluster API server profile. + ApiserverProfile *APIServerProfile `json:"apiserverProfile,omitempty"` + // IngressProfiles - The cluster ingress profiles. + IngressProfiles *[]IngressProfile `json:"ingressProfiles,omitempty"` +} + +// OpenShiftClustersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type OpenShiftClustersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OpenShiftClustersClient) (OpenShiftCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OpenShiftClustersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OpenShiftClustersCreateOrUpdateFuture.Result. +func (future *OpenShiftClustersCreateOrUpdateFuture) result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + osc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { + osc, err = client.CreateOrUpdateResponder(osc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateOrUpdateFuture", "Result", osc.Response.Response, "Failure responding to request") + } + } + return +} + +// OpenShiftClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OpenShiftClustersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OpenShiftClustersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OpenShiftClustersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OpenShiftClustersDeleteFuture.Result. +func (future *OpenShiftClustersDeleteFuture) result(client OpenShiftClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// OpenShiftClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OpenShiftClustersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OpenShiftClustersClient) (OpenShiftCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OpenShiftClustersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OpenShiftClustersUpdateFuture.Result. +func (future *OpenShiftClustersUpdateFuture) result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + osc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { + osc, err = client.UpdateResponder(osc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", osc.Response.Response, "Failure responding to request") + } + } + return +} + +// OpenShiftClusterUpdate openShiftCluster represents an Azure Red Hat OpenShift cluster. +type OpenShiftClusterUpdate struct { + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // OpenShiftClusterProperties - The cluster properties. + *OpenShiftClusterProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for OpenShiftClusterUpdate. +func (oscu OpenShiftClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oscu.Tags != nil { + objectMap["tags"] = oscu.Tags + } + if oscu.OpenShiftClusterProperties != nil { + objectMap["properties"] = oscu.OpenShiftClusterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OpenShiftClusterUpdate struct. +func (oscu *OpenShiftClusterUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + oscu.Tags = tags + } + case "properties": + if v != nil { + var openShiftClusterProperties OpenShiftClusterProperties + err = json.Unmarshal(*v, &openShiftClusterProperties) + if err != nil { + return err + } + oscu.OpenShiftClusterProperties = &openShiftClusterProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + oscu.SystemData = &systemData + } + } + } + + return nil +} + +// Operation operation represents an RP operation. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The object that describes the operation. + Display *Display `json:"display,omitempty"` + // Origin - Sources of requests to this operation. Comma separated list with valid values user or system, e.g. "user,system". + Origin *string `json:"origin,omitempty"` +} + +// OperationList operationList represents an RP operation list. +type OperationList struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListIterator) Response() OperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServicePrincipalProfile servicePrincipalProfile represents a service principal profile. +type ServicePrincipalProfile struct { + // ClientID - The client ID used for the cluster. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - The client secret used for the cluster. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// WorkerProfile workerProfile represents a worker profile. +type WorkerProfile struct { + // Name - The worker profile name. + Name *string `json:"name,omitempty"` + // VMSize - The size of the worker VMs. Possible values include: 'StandardD16asV4', 'StandardD16sV3', 'StandardD2sV3', 'StandardD32asV4', 'StandardD32sV3', 'StandardD4asV4', 'StandardD4sV3', 'StandardD8asV4', 'StandardD8sV3', 'StandardE16sV3', 'StandardE32sV3', 'StandardE4sV3', 'StandardE64iV3', 'StandardE64isV3', 'StandardE8sV3', 'StandardF16sV2', 'StandardF32sV2', 'StandardF4sV2', 'StandardF72sV2', 'StandardF8sV2', 'StandardG5', 'StandardGS5', 'StandardM128ms' + VMSize VMSize `json:"vmSize,omitempty"` + // DiskSizeGB - The disk size of the worker VMs. + DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` + // SubnetID - The Azure resource ID of the worker subnet. + SubnetID *string `json:"subnetId,omitempty"` + // Count - The number of worker VMs. + Count *int32 `json:"count,omitempty"` + // EncryptionAtHost - Whether master virtual machines are encrypted at host. Possible values include: 'Disabled', 'Enabled' + EncryptionAtHost EncryptionAtHost `json:"encryptionAtHost,omitempty"` + // DiskEncryptionSetID - The resource ID of an associated DiskEncryptionSet, if applicable. + DiskEncryptionSetID *string `json:"diskEncryptionSetId,omitempty"` +} diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/openshiftclusters.go b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/openshiftclusters.go new file mode 100644 index 000000000000..726466deeccf --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/openshiftclusters.go @@ -0,0 +1,803 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OpenShiftClustersClient is the rest API for Azure Red Hat OpenShift 4 +type OpenShiftClustersClient struct { + BaseClient +} + +// NewOpenShiftClustersClient creates an instance of the OpenShiftClustersClient client. +func NewOpenShiftClustersClient(subscriptionID string) OpenShiftClustersClient { + return NewOpenShiftClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOpenShiftClustersClientWithBaseURI creates an instance of the OpenShiftClustersClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewOpenShiftClustersClientWithBaseURI(baseURI string, subscriptionID string) OpenShiftClustersClient { + return OpenShiftClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +// parameters - the OpenShift cluster resource. +func (client OpenShiftClustersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (result OpenShiftClustersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client OpenShiftClustersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) CreateOrUpdateSender(req *http.Request) (future OpenShiftClustersCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) CreateOrUpdateResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation returns nothing. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OpenShiftClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) DeleteSender(req *http.Request) (future OpenShiftClustersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get the operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftCluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OpenShiftClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) GetResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List the operation returns properties of each OpenShift cluster. +func (client OpenShiftClustersClient) List(ctx context.Context) (result OpenShiftClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.List") + defer func() { + sc := -1 + if result.oscl.Response.Response != nil { + sc = result.oscl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.oscl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure sending request") + return + } + + result.oscl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure responding to request") + return + } + if result.oscl.hasNextLink() && result.oscl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OpenShiftClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListResponder(resp *http.Response) (result OpenShiftClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OpenShiftClustersClient) listNextResults(ctx context.Context, lastResults OpenShiftClusterList) (result OpenShiftClusterList, err error) { + req, err := lastResults.openShiftClusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OpenShiftClustersClient) ListComplete(ctx context.Context) (result OpenShiftClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListAdminCredentials the operation returns the admin kubeconfig. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) ListAdminCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClusterAdminKubeconfig, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListAdminCredentials") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", err.Error()) + } + + req, err := client.ListAdminCredentialsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListAdminCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListAdminCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", resp, "Failure responding to request") + return + } + + return +} + +// ListAdminCredentialsPreparer prepares the ListAdminCredentials request. +func (client OpenShiftClustersClient) ListAdminCredentialsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAdminCredentialsSender sends the ListAdminCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListAdminCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListAdminCredentialsResponder handles the response to the ListAdminCredentials request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListAdminCredentialsResponder(resp *http.Response) (result OpenShiftClusterAdminKubeconfig, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup the operation returns properties of each OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client OpenShiftClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result OpenShiftClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.oscl.Response.Response != nil { + sc = result.oscl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.oscl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.oscl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.oscl.hasNextLink() && result.oscl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client OpenShiftClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListByResourceGroupResponder(resp *http.Response) (result OpenShiftClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client OpenShiftClustersClient) listByResourceGroupNextResults(ctx context.Context, lastResults OpenShiftClusterList) (result OpenShiftClusterList, err error) { + req, err := lastResults.openShiftClusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client OpenShiftClustersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result OpenShiftClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListCredentials the operation returns the credentials. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) ListCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClusterCredentials, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListCredentials") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListCredentials", err.Error()) + } + + req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListCredentials", resp, "Failure responding to request") + return + } + + return +} + +// ListCredentialsPreparer prepares the ListCredentials request. +func (client OpenShiftClustersClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCredentialsSender sends the ListCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCredentialsResponder handles the response to the ListCredentials request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListCredentialsResponder(resp *http.Response) (result OpenShiftClusterCredentials, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +// parameters - the OpenShift cluster resource. +func (client OpenShiftClustersClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftClusterUpdate) (result OpenShiftClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client OpenShiftClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) UpdateSender(req *http.Request) (future OpenShiftClustersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) UpdateResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/operations.go b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/operations.go new file mode 100644 index 000000000000..0f64981148f3 --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/operations.go @@ -0,0 +1,140 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the rest API for Azure Red Hat OpenShift 4 +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List the operation returns the RP operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.RedHatOpenShift/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/redhatopenshiftapi/interfaces.go b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/redhatopenshiftapi/interfaces.go new file mode 100644 index 000000000000..c8450c9bc192 --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/redhatopenshiftapi/interfaces.go @@ -0,0 +1,36 @@ +package redhatopenshiftapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/mgmt/2021-09-01-preview/redhatopenshift" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result redhatopenshift.OperationListPage, err error) + ListComplete(ctx context.Context) (result redhatopenshift.OperationListIterator, err error) +} + +var _ OperationsClientAPI = (*redhatopenshift.OperationsClient)(nil) + +// OpenShiftClustersClientAPI contains the set of methods on the OpenShiftClustersClient type. +type OpenShiftClustersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftCluster) (result redhatopenshift.OpenShiftClustersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftCluster, err error) + List(ctx context.Context) (result redhatopenshift.OpenShiftClusterListPage, err error) + ListComplete(ctx context.Context) (result redhatopenshift.OpenShiftClusterListIterator, err error) + ListAdminCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterAdminKubeconfig, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterListIterator, err error) + ListCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterCredentials, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftClusterUpdate) (result redhatopenshift.OpenShiftClustersUpdateFuture, err error) +} + +var _ OpenShiftClustersClientAPI = (*redhatopenshift.OpenShiftClustersClient)(nil) diff --git a/services/preview/mgmt/2021-09-01-preview/redhatopenshift/version.go b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/version.go new file mode 100644 index 000000000000..f70a4dc6277c --- /dev/null +++ b/services/preview/mgmt/2021-09-01-preview/redhatopenshift/version.go @@ -0,0 +1,19 @@ +package redhatopenshift + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " redhatopenshift/2021-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/CHANGELOG.md b/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/CHANGELOG.md +++ b/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/_meta.json b/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/_meta.json index 389f1b6249c7..95ec38e2b406 100644 --- a/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/_meta.json +++ b/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "20b3d0478638e6b9382d49574084a8d6ad165129", "readme": "/_/azure-rest-api-specs/specification/redhatopenshift/resource-manager/readme.md", "tag": "package-2020-04-30", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/openshiftclusters.go b/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/openshiftclusters.go index d6f23b07c019..434011899fe1 100644 --- a/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/openshiftclusters.go +++ b/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/openshiftclusters.go @@ -53,8 +53,7 @@ func (client OpenShiftClustersClient) CreateOrUpdate(ctx context.Context, resour Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "CreateOrUpdate", err.Error()) } @@ -144,8 +143,7 @@ func (client OpenShiftClustersClient) Delete(ctx context.Context, resourceGroupN Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Delete", err.Error()) } @@ -232,8 +230,7 @@ func (client OpenShiftClustersClient) Get(ctx context.Context, resourceGroupName Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Get", err.Error()) } @@ -436,8 +433,7 @@ func (client OpenShiftClustersClient) ListByResourceGroup(ctx context.Context, r Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", err.Error()) } @@ -563,8 +559,7 @@ func (client OpenShiftClustersClient) ListCredentials(ctx context.Context, resou Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListCredentials", err.Error()) } @@ -650,8 +645,7 @@ func (client OpenShiftClustersClient) Update(ctx context.Context, resourceGroupN Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, {TargetValue: resourceGroupName, Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, - {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Update", err.Error()) } diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/CHANGELOG.md b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/_meta.json b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/_meta.json new file mode 100644 index 000000000000..93730e8f0fff --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "20b3d0478638e6b9382d49574084a8d6ad165129", + "readme": "/_/azure-rest-api-specs/specification/redhatopenshift/resource-manager/readme.md", + "tag": "package-2022-04-01", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2022-04-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/redhatopenshift/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/client.go b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/client.go new file mode 100644 index 000000000000..72e814e4fa2d --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/client.go @@ -0,0 +1,41 @@ +// Package redhatopenshift implements the Azure ARM Redhatopenshift service API version 2022-04-01. +// +// Rest API for Azure Red Hat OpenShift 4 +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Redhatopenshift + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Redhatopenshift. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/enums.go b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/enums.go new file mode 100644 index 000000000000..fdb5b16aee17 --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/enums.go @@ -0,0 +1,94 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// EncryptionAtHost enumerates the values for encryption at host. +type EncryptionAtHost string + +const ( + // Disabled ... + Disabled EncryptionAtHost = "Disabled" + // Enabled ... + Enabled EncryptionAtHost = "Enabled" +) + +// PossibleEncryptionAtHostValues returns an array of possible values for the EncryptionAtHost const type. +func PossibleEncryptionAtHostValues() []EncryptionAtHost { + return []EncryptionAtHost{Disabled, Enabled} +} + +// FipsValidatedModules enumerates the values for fips validated modules. +type FipsValidatedModules string + +const ( + // FipsValidatedModulesDisabled ... + FipsValidatedModulesDisabled FipsValidatedModules = "Disabled" + // FipsValidatedModulesEnabled ... + FipsValidatedModulesEnabled FipsValidatedModules = "Enabled" +) + +// PossibleFipsValidatedModulesValues returns an array of possible values for the FipsValidatedModules const type. +func PossibleFipsValidatedModulesValues() []FipsValidatedModules { + return []FipsValidatedModules{FipsValidatedModulesDisabled, FipsValidatedModulesEnabled} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // AdminUpdating ... + AdminUpdating ProvisioningState = "AdminUpdating" + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{AdminUpdating, Creating, Deleting, Failed, Succeeded, Updating} +} + +// Visibility enumerates the values for visibility. +type Visibility string + +const ( + // Private ... + Private Visibility = "Private" + // Public ... + Public Visibility = "Public" +) + +// PossibleVisibilityValues returns an array of possible values for the Visibility const type. +func PossibleVisibilityValues() []Visibility { + return []Visibility{Private, Public} +} diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/models.go b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/models.go new file mode 100644 index 000000000000..efc4ab99e128 --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/models.go @@ -0,0 +1,897 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift" + +// APIServerProfile aPIServerProfile represents an API server profile. +type APIServerProfile struct { + // Visibility - API server visibility. Possible values include: 'Private', 'Public' + Visibility Visibility `json:"visibility,omitempty"` + // URL - The URL to access the cluster API server. + URL *string `json:"url,omitempty"` + // IP - The IP of the cluster API server. + IP *string `json:"ip,omitempty"` +} + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CloudError cloudError represents a cloud error. +type CloudError struct { + // Error - An error response from the service. + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody cloudErrorBody represents the body of a cloud error. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` + // Details - A list of additional details about the error. + Details *[]CloudErrorBody `json:"details,omitempty"` +} + +// ClusterProfile clusterProfile represents a cluster profile. +type ClusterProfile struct { + // PullSecret - The pull secret for the cluster. + PullSecret *string `json:"pullSecret,omitempty"` + // Domain - The domain for the cluster. + Domain *string `json:"domain,omitempty"` + // Version - The version of the cluster. + Version *string `json:"version,omitempty"` + // ResourceGroupID - The ID of the cluster resource group. + ResourceGroupID *string `json:"resourceGroupId,omitempty"` + // FipsValidatedModules - If FIPS validated crypto modules are used. Possible values include: 'FipsValidatedModulesDisabled', 'FipsValidatedModulesEnabled' + FipsValidatedModules FipsValidatedModules `json:"fipsValidatedModules,omitempty"` +} + +// ConsoleProfile consoleProfile represents a console profile. +type ConsoleProfile struct { + // URL - The URL to access the cluster console. + URL *string `json:"url,omitempty"` +} + +// Display display represents the display details of an operation. +type Display struct { + // Provider - Friendly name of the resource provider. + Provider *string `json:"provider,omitempty"` + // Resource - Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: read, write, delete, listKeys/action, etc. + Operation *string `json:"operation,omitempty"` + // Description - Friendly name of the operation. + Description *string `json:"description,omitempty"` +} + +// IngressProfile ingressProfile represents an ingress profile. +type IngressProfile struct { + // Name - The ingress profile name. + Name *string `json:"name,omitempty"` + // Visibility - Ingress visibility. Possible values include: 'Private', 'Public' + Visibility Visibility `json:"visibility,omitempty"` + // IP - The IP of the ingress. + IP *string `json:"ip,omitempty"` +} + +// MasterProfile masterProfile represents a master profile. +type MasterProfile struct { + // VMSize - The size of the master VMs. + VMSize *string `json:"vmSize,omitempty"` + // SubnetID - The Azure resource ID of the master subnet. + SubnetID *string `json:"subnetId,omitempty"` + // EncryptionAtHost - Whether master virtual machines are encrypted at host. Possible values include: 'Disabled', 'Enabled' + EncryptionAtHost EncryptionAtHost `json:"encryptionAtHost,omitempty"` + // DiskEncryptionSetID - The resource ID of an associated DiskEncryptionSet, if applicable. + DiskEncryptionSetID *string `json:"diskEncryptionSetId,omitempty"` +} + +// NetworkProfile networkProfile represents a network profile. +type NetworkProfile struct { + // PodCidr - The CIDR used for OpenShift/Kubernetes Pods. + PodCidr *string `json:"podCidr,omitempty"` + // ServiceCidr - The CIDR used for OpenShift/Kubernetes Services. + ServiceCidr *string `json:"serviceCidr,omitempty"` +} + +// OpenShiftCluster openShiftCluster represents an Azure Red Hat OpenShift cluster. +type OpenShiftCluster struct { + autorest.Response `json:"-"` + // OpenShiftClusterProperties - The cluster properties. + *OpenShiftClusterProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for OpenShiftCluster. +func (osc OpenShiftCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if osc.OpenShiftClusterProperties != nil { + objectMap["properties"] = osc.OpenShiftClusterProperties + } + if osc.Tags != nil { + objectMap["tags"] = osc.Tags + } + if osc.Location != nil { + objectMap["location"] = osc.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OpenShiftCluster struct. +func (osc *OpenShiftCluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var openShiftClusterProperties OpenShiftClusterProperties + err = json.Unmarshal(*v, &openShiftClusterProperties) + if err != nil { + return err + } + osc.OpenShiftClusterProperties = &openShiftClusterProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + osc.SystemData = &systemData + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + osc.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + osc.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + osc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + osc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + osc.Type = &typeVar + } + } + } + + return nil +} + +// OpenShiftClusterAdminKubeconfig openShiftClusterAdminKubeconfig represents an OpenShift cluster's admin +// kubeconfig. +type OpenShiftClusterAdminKubeconfig struct { + autorest.Response `json:"-"` + // Kubeconfig - The base64-encoded kubeconfig file. + Kubeconfig *string `json:"kubeconfig,omitempty"` +} + +// OpenShiftClusterCredentials openShiftClusterCredentials represents an OpenShift cluster's credentials. +type OpenShiftClusterCredentials struct { + autorest.Response `json:"-"` + // KubeadminUsername - The username for the kubeadmin user. + KubeadminUsername *string `json:"kubeadminUsername,omitempty"` + // KubeadminPassword - The password for the kubeadmin user. + KubeadminPassword *string `json:"kubeadminPassword,omitempty"` +} + +// OpenShiftClusterList openShiftClusterList represents a list of OpenShift clusters. +type OpenShiftClusterList struct { + autorest.Response `json:"-"` + // Value - The list of OpenShift clusters. + Value *[]OpenShiftCluster `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// OpenShiftClusterListIterator provides access to a complete listing of OpenShiftCluster values. +type OpenShiftClusterListIterator struct { + i int + page OpenShiftClusterListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OpenShiftClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClusterListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OpenShiftClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OpenShiftClusterListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OpenShiftClusterListIterator) Response() OpenShiftClusterList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OpenShiftClusterListIterator) Value() OpenShiftCluster { + if !iter.page.NotDone() { + return OpenShiftCluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OpenShiftClusterListIterator type. +func NewOpenShiftClusterListIterator(page OpenShiftClusterListPage) OpenShiftClusterListIterator { + return OpenShiftClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oscl OpenShiftClusterList) IsEmpty() bool { + return oscl.Value == nil || len(*oscl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (oscl OpenShiftClusterList) hasNextLink() bool { + return oscl.NextLink != nil && len(*oscl.NextLink) != 0 +} + +// openShiftClusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oscl OpenShiftClusterList) openShiftClusterListPreparer(ctx context.Context) (*http.Request, error) { + if !oscl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oscl.NextLink))) +} + +// OpenShiftClusterListPage contains a page of OpenShiftCluster values. +type OpenShiftClusterListPage struct { + fn func(context.Context, OpenShiftClusterList) (OpenShiftClusterList, error) + oscl OpenShiftClusterList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OpenShiftClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClusterListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.oscl) + if err != nil { + return err + } + page.oscl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OpenShiftClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OpenShiftClusterListPage) NotDone() bool { + return !page.oscl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OpenShiftClusterListPage) Response() OpenShiftClusterList { + return page.oscl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OpenShiftClusterListPage) Values() []OpenShiftCluster { + if page.oscl.IsEmpty() { + return nil + } + return *page.oscl.Value +} + +// Creates a new instance of the OpenShiftClusterListPage type. +func NewOpenShiftClusterListPage(cur OpenShiftClusterList, getNextPage func(context.Context, OpenShiftClusterList) (OpenShiftClusterList, error)) OpenShiftClusterListPage { + return OpenShiftClusterListPage{ + fn: getNextPage, + oscl: cur, + } +} + +// OpenShiftClusterProperties openShiftClusterProperties represents an OpenShift cluster's properties. +type OpenShiftClusterProperties struct { + // ProvisioningState - The cluster provisioning state. Possible values include: 'AdminUpdating', 'Creating', 'Deleting', 'Failed', 'Succeeded', 'Updating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ClusterProfile - The cluster profile. + ClusterProfile *ClusterProfile `json:"clusterProfile,omitempty"` + // ConsoleProfile - The console profile. + ConsoleProfile *ConsoleProfile `json:"consoleProfile,omitempty"` + // ServicePrincipalProfile - The cluster service principal profile. + ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"` + // NetworkProfile - The cluster network profile. + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + // MasterProfile - The cluster master profile. + MasterProfile *MasterProfile `json:"masterProfile,omitempty"` + // WorkerProfiles - The cluster worker profiles. + WorkerProfiles *[]WorkerProfile `json:"workerProfiles,omitempty"` + // ApiserverProfile - The cluster API server profile. + ApiserverProfile *APIServerProfile `json:"apiserverProfile,omitempty"` + // IngressProfiles - The cluster ingress profiles. + IngressProfiles *[]IngressProfile `json:"ingressProfiles,omitempty"` +} + +// OpenShiftClustersCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type OpenShiftClustersCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OpenShiftClustersClient) (OpenShiftCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OpenShiftClustersCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OpenShiftClustersCreateOrUpdateFuture.Result. +func (future *OpenShiftClustersCreateOrUpdateFuture) result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + osc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { + osc, err = client.CreateOrUpdateResponder(osc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateOrUpdateFuture", "Result", osc.Response.Response, "Failure responding to request") + } + } + return +} + +// OpenShiftClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OpenShiftClustersDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OpenShiftClustersClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OpenShiftClustersDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OpenShiftClustersDeleteFuture.Result. +func (future *OpenShiftClustersDeleteFuture) result(client OpenShiftClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// OpenShiftClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OpenShiftClustersUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(OpenShiftClustersClient) (OpenShiftCluster, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *OpenShiftClustersUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for OpenShiftClustersUpdateFuture.Result. +func (future *OpenShiftClustersUpdateFuture) result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + osc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { + osc, err = client.UpdateResponder(osc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", osc.Response.Response, "Failure responding to request") + } + } + return +} + +// OpenShiftClusterUpdate openShiftCluster represents an Azure Red Hat OpenShift cluster. +type OpenShiftClusterUpdate struct { + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // OpenShiftClusterProperties - The cluster properties. + *OpenShiftClusterProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for OpenShiftClusterUpdate. +func (oscu OpenShiftClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oscu.Tags != nil { + objectMap["tags"] = oscu.Tags + } + if oscu.OpenShiftClusterProperties != nil { + objectMap["properties"] = oscu.OpenShiftClusterProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OpenShiftClusterUpdate struct. +func (oscu *OpenShiftClusterUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + oscu.Tags = tags + } + case "properties": + if v != nil { + var openShiftClusterProperties OpenShiftClusterProperties + err = json.Unmarshal(*v, &openShiftClusterProperties) + if err != nil { + return err + } + oscu.OpenShiftClusterProperties = &openShiftClusterProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + oscu.SystemData = &systemData + } + } + } + + return nil +} + +// Operation operation represents an RP operation. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The object that describes the operation. + Display *Display `json:"display,omitempty"` + // Origin - Sources of requests to this operation. Comma separated list with valid values user or system, e.g. "user,system". + Origin *string `json:"origin,omitempty"` +} + +// OperationList operationList represents an RP operation list. +type OperationList struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListIterator) Response() OperationList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ol) + if err != nil { + return err + } + page.ol = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ServicePrincipalProfile servicePrincipalProfile represents a service principal profile. +type ServicePrincipalProfile struct { + // ClientID - The client ID used for the cluster. + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - The client secret used for the cluster. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// WorkerProfile workerProfile represents a worker profile. +type WorkerProfile struct { + // Name - The worker profile name. + Name *string `json:"name,omitempty"` + // VMSize - The size of the worker VMs. + VMSize *string `json:"vmSize,omitempty"` + // DiskSizeGB - The disk size of the worker VMs. + DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` + // SubnetID - The Azure resource ID of the worker subnet. + SubnetID *string `json:"subnetId,omitempty"` + // Count - The number of worker VMs. + Count *int32 `json:"count,omitempty"` + // EncryptionAtHost - Whether master virtual machines are encrypted at host. Possible values include: 'Disabled', 'Enabled' + EncryptionAtHost EncryptionAtHost `json:"encryptionAtHost,omitempty"` + // DiskEncryptionSetID - The resource ID of an associated DiskEncryptionSet, if applicable. + DiskEncryptionSetID *string `json:"diskEncryptionSetId,omitempty"` +} diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/openshiftclusters.go b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/openshiftclusters.go new file mode 100644 index 000000000000..1a6528345a76 --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/openshiftclusters.go @@ -0,0 +1,803 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OpenShiftClustersClient is the rest API for Azure Red Hat OpenShift 4 +type OpenShiftClustersClient struct { + BaseClient +} + +// NewOpenShiftClustersClient creates an instance of the OpenShiftClustersClient client. +func NewOpenShiftClustersClient(subscriptionID string) OpenShiftClustersClient { + return NewOpenShiftClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOpenShiftClustersClientWithBaseURI creates an instance of the OpenShiftClustersClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewOpenShiftClustersClientWithBaseURI(baseURI string, subscriptionID string) OpenShiftClustersClient { + return OpenShiftClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +// parameters - the OpenShift cluster resource. +func (client OpenShiftClustersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (result OpenShiftClustersCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client OpenShiftClustersClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) CreateOrUpdateSender(req *http.Request) (future OpenShiftClustersCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) CreateOrUpdateResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation returns nothing. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OpenShiftClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) DeleteSender(req *http.Request) (future OpenShiftClustersDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get the operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftCluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OpenShiftClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) GetResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List the operation returns properties of each OpenShift cluster. +func (client OpenShiftClustersClient) List(ctx context.Context) (result OpenShiftClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.List") + defer func() { + sc := -1 + if result.oscl.Response.Response != nil { + sc = result.oscl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.oscl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure sending request") + return + } + + result.oscl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure responding to request") + return + } + if result.oscl.hasNextLink() && result.oscl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OpenShiftClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListResponder(resp *http.Response) (result OpenShiftClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OpenShiftClustersClient) listNextResults(ctx context.Context, lastResults OpenShiftClusterList) (result OpenShiftClusterList, err error) { + req, err := lastResults.openShiftClusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OpenShiftClustersClient) ListComplete(ctx context.Context) (result OpenShiftClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListAdminCredentials the operation returns the admin kubeconfig. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) ListAdminCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClusterAdminKubeconfig, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListAdminCredentials") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", err.Error()) + } + + req, err := client.ListAdminCredentialsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListAdminCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListAdminCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListAdminCredentials", resp, "Failure responding to request") + return + } + + return +} + +// ListAdminCredentialsPreparer prepares the ListAdminCredentials request. +func (client OpenShiftClustersClient) ListAdminCredentialsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listAdminCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAdminCredentialsSender sends the ListAdminCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListAdminCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListAdminCredentialsResponder handles the response to the ListAdminCredentials request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListAdminCredentialsResponder(resp *http.Response) (result OpenShiftClusterAdminKubeconfig, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup the operation returns properties of each OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +func (client OpenShiftClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result OpenShiftClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.oscl.Response.Response != nil { + sc = result.oscl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.oscl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.oscl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.oscl.hasNextLink() && result.oscl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client OpenShiftClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListByResourceGroupResponder(resp *http.Response) (result OpenShiftClusterList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client OpenShiftClustersClient) listByResourceGroupNextResults(ctx context.Context, lastResults OpenShiftClusterList) (result OpenShiftClusterList, err error) { + req, err := lastResults.openShiftClusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client OpenShiftClustersClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result OpenShiftClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListCredentials the operation returns the credentials. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) ListCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClusterCredentials, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListCredentials") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "ListCredentials", err.Error()) + } + + req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.ListCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListCredentials", resp, "Failure responding to request") + return + } + + return +} + +// ListCredentialsPreparer prepares the ListCredentials request. +func (client OpenShiftClustersClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/listCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListCredentialsSender sends the ListCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListCredentialsResponder handles the response to the ListCredentials request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListCredentialsResponder(resp *http.Response) (result OpenShiftClusterCredentials, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. The name is case insensitive. +// resourceName - the name of the OpenShift cluster resource. +// parameters - the OpenShift cluster resource. +func (client OpenShiftClustersClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftClusterUpdate) (result OpenShiftClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("redhatopenshift.OpenShiftClustersClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client OpenShiftClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) UpdateSender(req *http.Request) (future OpenShiftClustersUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) UpdateResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/operations.go b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/operations.go new file mode 100644 index 000000000000..2abeb0c70bae --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/operations.go @@ -0,0 +1,140 @@ +package redhatopenshift + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the rest API for Azure Red Hat OpenShift 4 +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List the operation returns the RP operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2022-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.RedHatOpenShift/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/redhatopenshiftapi/interfaces.go b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/redhatopenshiftapi/interfaces.go new file mode 100644 index 000000000000..13d1d2b8057c --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/redhatopenshiftapi/interfaces.go @@ -0,0 +1,36 @@ +package redhatopenshiftapi + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result redhatopenshift.OperationListPage, err error) + ListComplete(ctx context.Context) (result redhatopenshift.OperationListIterator, err error) +} + +var _ OperationsClientAPI = (*redhatopenshift.OperationsClient)(nil) + +// OpenShiftClustersClientAPI contains the set of methods on the OpenShiftClustersClient type. +type OpenShiftClustersClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftCluster) (result redhatopenshift.OpenShiftClustersCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftCluster, err error) + List(ctx context.Context) (result redhatopenshift.OpenShiftClusterListPage, err error) + ListComplete(ctx context.Context) (result redhatopenshift.OpenShiftClusterListIterator, err error) + ListAdminCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterAdminKubeconfig, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterListIterator, err error) + ListCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterCredentials, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftClusterUpdate) (result redhatopenshift.OpenShiftClustersUpdateFuture, err error) +} + +var _ OpenShiftClustersClientAPI = (*redhatopenshift.OpenShiftClustersClient)(nil) diff --git a/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/version.go b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/version.go new file mode 100644 index 000000000000..83278239b4fb --- /dev/null +++ b/services/redhatopenshift/mgmt/2022-04-01/redhatopenshift/version.go @@ -0,0 +1,19 @@ +package redhatopenshift + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " redhatopenshift/2022-04-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}