diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/client.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/client.go new file mode 100644 index 000000000000..e1a7d45ac278 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/client.go @@ -0,0 +1,52 @@ +// Package redisenterprise implements the Azure ARM Redisenterprise service API version 2020-10-01-preview. +// +// REST API for managing Redis Enterprise resources in Azure. +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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 Redisenterprise + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Redisenterprise. +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/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/database.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/database.go new file mode 100644 index 000000000000..af2948e176d7 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/database.go @@ -0,0 +1,370 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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" +) + +// DatabaseClient is the REST API for managing Redis Enterprise resources in Azure. +type DatabaseClient struct { + BaseClient +} + +// NewDatabaseClient creates an instance of the DatabaseClient client. +func NewDatabaseClient(subscriptionID string) DatabaseClient { + return NewDatabaseClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabaseClientWithBaseURI creates an instance of the DatabaseClient 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 NewDatabaseClientWithBaseURI(baseURI string, subscriptionID string) DatabaseClient { + return DatabaseClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Export exports a database file from target database. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +// parameters - storage information for exporting into the cluster +func (client DatabaseClient) Export(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters ExportClusterParameters) (result DatabaseExportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.Export") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SasURI", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("redisenterprise.DatabaseClient", "Export", err.Error()) + } + + req, err := client.ExportPreparer(ctx, resourceGroupName, clusterName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "Export", nil, "Failure preparing request") + return + } + + result, err = client.ExportSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "Export", result.Response(), "Failure sending request") + return + } + + return +} + +// ExportPreparer prepares the Export request. +func (client DatabaseClient) ExportPreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters ExportClusterParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/export", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) ExportSender(req *http.Request) (future DatabaseExportFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ExportResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Import imports a database file to target database. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +// parameters - storage information for importing into the cluster +func (client DatabaseClient) Import(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters ImportClusterParameters) (result DatabaseImportFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.Import") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.SasURI", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("redisenterprise.DatabaseClient", "Import", err.Error()) + } + + req, err := client.ImportPreparer(ctx, resourceGroupName, clusterName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "Import", nil, "Failure preparing request") + return + } + + result, err = client.ImportSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "Import", result.Response(), "Failure sending request") + return + } + + return +} + +// ImportPreparer prepares the Import request. +func (client DatabaseClient) ImportPreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters ImportClusterParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/import", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ImportSender sends the Import request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) ImportSender(req *http.Request) (future DatabaseImportFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// ImportResponder handles the response to the Import request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ImportResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListKeys retrieves the access keys for the RedisEnterprise database. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +func (client DatabaseClient) ListKeys(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (result AccessKeys, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysPreparer(ctx, resourceGroupName, clusterName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "ListKeys", resp, "Failure responding to request") + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client DatabaseClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/listKeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client DatabaseClient) ListKeysResponder(resp *http.Response) (result AccessKeys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateKey regenerates the RedisEnterprise database's access keys. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +// parameters - specifies which key to regenerate. +func (client DatabaseClient) RegenerateKey(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters RegenerateKeyParameters) (result DatabaseRegenerateKeyFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseClient.RegenerateKey") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, clusterName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + result, err = client.RegenerateKeySender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseClient", "RegenerateKey", result.Response(), "Failure sending request") + return + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client DatabaseClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters RegenerateKeyParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}/regenerateKey", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RegenerateKeySender sends the RegenerateKey request. The method will close the +// http.Response Body if it receives an error. +func (client DatabaseClient) RegenerateKeySender(req *http.Request) (future DatabaseRegenerateKeyFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client DatabaseClient) RegenerateKeyResponder(resp *http.Response) (result AccessKeys, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/databases.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/databases.go new file mode 100644 index 000000000000..9c4d8fb2214a --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/databases.go @@ -0,0 +1,471 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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" +) + +// DatabasesClient is the REST API for managing Redis Enterprise resources in Azure. +type DatabasesClient struct { + BaseClient +} + +// NewDatabasesClient creates an instance of the DatabasesClient client. +func NewDatabasesClient(subscriptionID string) DatabasesClient { + return NewDatabasesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDatabasesClientWithBaseURI creates an instance of the DatabasesClient 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 NewDatabasesClientWithBaseURI(baseURI string, subscriptionID string) DatabasesClient { + return DatabasesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a database +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +// parameters - parameters supplied to the create or update database operation. +func (client DatabasesClient) Create(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters Database) (result DatabasesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client DatabasesClient) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters Database) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) CreateSender(req *http.Request) (future DatabasesCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client DatabasesClient) CreateResponder(resp *http.Response) (result Database, 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 deletes a single database +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +func (client DatabasesClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (result DatabasesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DatabasesClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/databases/{databaseName}", 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 DatabasesClient) DeleteSender(req *http.Request) (future DatabasesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DatabasesClient) 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 +} + +// GetMethod gets information about a database in a RedisEnterprise cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +func (client DatabasesClient) GetMethod(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (result Database, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.GetMethod") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetMethodPreparer(ctx, resourceGroupName, clusterName, databaseName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "GetMethod", nil, "Failure preparing request") + return + } + + resp, err := client.GetMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "GetMethod", resp, "Failure sending request") + return + } + + result, err = client.GetMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "GetMethod", resp, "Failure responding to request") + } + + return +} + +// GetMethodPreparer prepares the GetMethod request. +func (client DatabasesClient) GetMethodPreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/databases/{databaseName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMethodSender sends the GetMethod request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) GetMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMethodResponder handles the response to the GetMethod request. The method always +// closes the http.Response Body. +func (client DatabasesClient) GetMethodResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByCluster gets all databases in the specified RedisEnterprise cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +func (client DatabasesClient) ListByCluster(ctx context.Context, resourceGroupName string, clusterName string) (result DatabaseListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByCluster") + defer func() { + sc := -1 + if result.dl.Response.Response != nil { + sc = result.dl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByClusterNextResults + req, err := client.ListByClusterPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "ListByCluster", nil, "Failure preparing request") + return + } + + resp, err := client.ListByClusterSender(req) + if err != nil { + result.dl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "ListByCluster", resp, "Failure sending request") + return + } + + result.dl, err = client.ListByClusterResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "ListByCluster", resp, "Failure responding to request") + } + if result.dl.hasNextLink() && result.dl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByClusterPreparer prepares the ListByCluster request. +func (client DatabasesClient) ListByClusterPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/databases", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByClusterSender sends the ListByCluster request. The method will close the +// http.Response Body if it receives an error. +func (client DatabasesClient) ListByClusterSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByClusterResponder handles the response to the ListByCluster request. The method always +// closes the http.Response Body. +func (client DatabasesClient) ListByClusterResponder(resp *http.Response) (result DatabaseList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByClusterNextResults retrieves the next set of results, if any. +func (client DatabasesClient) listByClusterNextResults(ctx context.Context, lastResults DatabaseList) (result DatabaseList, err error) { + req, err := lastResults.databaseListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "listByClusterNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByClusterSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "listByClusterNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByClusterResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "listByClusterNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByClusterComplete enumerates all values, automatically crossing page boundaries as required. +func (client DatabasesClient) ListByClusterComplete(ctx context.Context, resourceGroupName string, clusterName string) (result DatabaseListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.ListByCluster") + 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.ListByCluster(ctx, resourceGroupName, clusterName) + return +} + +// Update updates a database +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// databaseName - the name of the database. +// parameters - parameters supplied to the create or update database operation. +func (client DatabasesClient) Update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseUpdate) (result DatabasesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabasesClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, databaseName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DatabasesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "databaseName": autorest.Encode("path", databaseName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/databases/{databaseName}", 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 DatabasesClient) UpdateSender(req *http.Request) (future DatabasesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DatabasesClient) UpdateResponder(resp *http.Response) (result Database, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/enums.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/enums.go new file mode 100644 index 000000000000..33f1ab91da83 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/enums.go @@ -0,0 +1,240 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// AccessKeyType enumerates the values for access key type. +type AccessKeyType string + +const ( + // Primary ... + Primary AccessKeyType = "Primary" + // Secondary ... + Secondary AccessKeyType = "Secondary" +) + +// PossibleAccessKeyTypeValues returns an array of possible values for the AccessKeyType const type. +func PossibleAccessKeyTypeValues() []AccessKeyType { + return []AccessKeyType{Primary, Secondary} +} + +// ActionType enumerates the values for action type. +type ActionType string + +const ( + // Internal ... + Internal ActionType = "Internal" +) + +// PossibleActionTypeValues returns an array of possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{Internal} +} + +// ClusteringPolicy enumerates the values for clustering policy. +type ClusteringPolicy string + +const ( + // EnterpriseCluster ... + EnterpriseCluster ClusteringPolicy = "EnterpriseCluster" + // OSSCluster ... + OSSCluster ClusteringPolicy = "OSSCluster" +) + +// PossibleClusteringPolicyValues returns an array of possible values for the ClusteringPolicy const type. +func PossibleClusteringPolicyValues() []ClusteringPolicy { + return []ClusteringPolicy{EnterpriseCluster, OSSCluster} +} + +// EvictionPolicy enumerates the values for eviction policy. +type EvictionPolicy string + +const ( + // AllKeysLFU ... + AllKeysLFU EvictionPolicy = "AllKeysLFU" + // AllKeysLRU ... + AllKeysLRU EvictionPolicy = "AllKeysLRU" + // AllKeysRandom ... + AllKeysRandom EvictionPolicy = "AllKeysRandom" + // NoEviction ... + NoEviction EvictionPolicy = "NoEviction" + // VolatileLFU ... + VolatileLFU EvictionPolicy = "VolatileLFU" + // VolatileLRU ... + VolatileLRU EvictionPolicy = "VolatileLRU" + // VolatileRandom ... + VolatileRandom EvictionPolicy = "VolatileRandom" + // VolatileTTL ... + VolatileTTL EvictionPolicy = "VolatileTTL" +) + +// PossibleEvictionPolicyValues returns an array of possible values for the EvictionPolicy const type. +func PossibleEvictionPolicyValues() []EvictionPolicy { + return []EvictionPolicy{AllKeysLFU, AllKeysLRU, AllKeysRandom, NoEviction, VolatileLFU, VolatileLRU, VolatileRandom, VolatileTTL} +} + +// Origin enumerates the values for origin. +type Origin string + +const ( + // System ... + System Origin = "system" + // User ... + User Origin = "user" + // Usersystem ... + Usersystem Origin = "user,system" +) + +// PossibleOriginValues returns an array of possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{System, User, Usersystem} +} + +// PrivateEndpointConnectionProvisioningState enumerates the values for private endpoint connection +// provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + // Creating ... + Creating PrivateEndpointConnectionProvisioningState = "Creating" + // Deleting ... + Deleting PrivateEndpointConnectionProvisioningState = "Deleting" + // Failed ... + Failed PrivateEndpointConnectionProvisioningState = "Failed" + // Succeeded ... + Succeeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns an array of possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{Creating, Deleting, Failed, Succeeded} +} + +// PrivateEndpointServiceConnectionStatus enumerates the values for private endpoint service connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + // Approved ... + Approved PrivateEndpointServiceConnectionStatus = "Approved" + // Pending ... + Pending PrivateEndpointServiceConnectionStatus = "Pending" + // Rejected ... + Rejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns an array of possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{Approved, Pending, Rejected} +} + +// Protocol enumerates the values for protocol. +type Protocol string + +const ( + // Encrypted ... + Encrypted Protocol = "Encrypted" + // Plaintext ... + Plaintext Protocol = "Plaintext" +) + +// PossibleProtocolValues returns an array of possible values for the Protocol const type. +func PossibleProtocolValues() []Protocol { + return []Protocol{Encrypted, Plaintext} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating ... + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateCreating, ProvisioningStateDeleting, ProvisioningStateFailed, ProvisioningStateSucceeded, ProvisioningStateUpdating} +} + +// ResourceState enumerates the values for resource state. +type ResourceState string + +const ( + // ResourceStateCreateFailed ... + ResourceStateCreateFailed ResourceState = "CreateFailed" + // ResourceStateCreating ... + ResourceStateCreating ResourceState = "Creating" + // ResourceStateDeleteFailed ... + ResourceStateDeleteFailed ResourceState = "DeleteFailed" + // ResourceStateDeleting ... + ResourceStateDeleting ResourceState = "Deleting" + // ResourceStateDisabled ... + ResourceStateDisabled ResourceState = "Disabled" + // ResourceStateDisableFailed ... + ResourceStateDisableFailed ResourceState = "DisableFailed" + // ResourceStateDisabling ... + ResourceStateDisabling ResourceState = "Disabling" + // ResourceStateEnableFailed ... + ResourceStateEnableFailed ResourceState = "EnableFailed" + // ResourceStateEnabling ... + ResourceStateEnabling ResourceState = "Enabling" + // ResourceStateRunning ... + ResourceStateRunning ResourceState = "Running" + // ResourceStateUpdateFailed ... + ResourceStateUpdateFailed ResourceState = "UpdateFailed" + // ResourceStateUpdating ... + ResourceStateUpdating ResourceState = "Updating" +) + +// PossibleResourceStateValues returns an array of possible values for the ResourceState const type. +func PossibleResourceStateValues() []ResourceState { + return []ResourceState{ResourceStateCreateFailed, ResourceStateCreating, ResourceStateDeleteFailed, ResourceStateDeleting, ResourceStateDisabled, ResourceStateDisableFailed, ResourceStateDisabling, ResourceStateEnableFailed, ResourceStateEnabling, ResourceStateRunning, ResourceStateUpdateFailed, ResourceStateUpdating} +} + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // EnterpriseE10 ... + EnterpriseE10 SkuName = "Enterprise_E10" + // EnterpriseE100 ... + EnterpriseE100 SkuName = "Enterprise_E100" + // EnterpriseE20 ... + EnterpriseE20 SkuName = "Enterprise_E20" + // EnterpriseE50 ... + EnterpriseE50 SkuName = "Enterprise_E50" + // EnterpriseFlashF1500 ... + EnterpriseFlashF1500 SkuName = "EnterpriseFlash_F1500" + // EnterpriseFlashF300 ... + EnterpriseFlashF300 SkuName = "EnterpriseFlash_F300" + // EnterpriseFlashF700 ... + EnterpriseFlashF700 SkuName = "EnterpriseFlash_F700" +) + +// PossibleSkuNameValues returns an array of possible values for the SkuName const type. +func PossibleSkuNameValues() []SkuName { + return []SkuName{EnterpriseE10, EnterpriseE100, EnterpriseE20, EnterpriseE50, EnterpriseFlashF1500, EnterpriseFlashF300, EnterpriseFlashF700} +} diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/get.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/get.go new file mode 100644 index 000000000000..dd36befa976d --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/get.go @@ -0,0 +1,117 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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" +) + +// GetClient is the REST API for managing Redis Enterprise resources in Azure. +type GetClient struct { + BaseClient +} + +// NewGetClient creates an instance of the GetClient client. +func NewGetClient(subscriptionID string) GetClient { + return NewGetClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGetClientWithBaseURI creates an instance of the GetClient 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 NewGetClientWithBaseURI(baseURI string, subscriptionID string) GetClient { + return GetClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// OperationStatusMethod gets the status of operation. +// Parameters: +// location - the region the operation is in. +// operationID - the operation's unique identifier. +func (client GetClient) OperationStatusMethod(ctx context.Context, location string, operationID string) (result OperationStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GetClient.OperationStatusMethod") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.OperationStatusMethodPreparer(ctx, location, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.GetClient", "OperationStatusMethod", nil, "Failure preparing request") + return + } + + resp, err := client.OperationStatusMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.GetClient", "OperationStatusMethod", resp, "Failure sending request") + return + } + + result, err = client.OperationStatusMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.GetClient", "OperationStatusMethod", resp, "Failure responding to request") + } + + return +} + +// OperationStatusMethodPreparer prepares the OperationStatusMethod request. +func (client GetClient) OperationStatusMethodPreparer(ctx context.Context, location string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "operationId": autorest.Encode("path", operationID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/operationsStatus/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// OperationStatusMethodSender sends the OperationStatusMethod request. The method will close the +// http.Response Body if it receives an error. +func (client GetClient) OperationStatusMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// OperationStatusMethodResponder handles the response to the OperationStatusMethod request. The method always +// closes the http.Response Body. +func (client GetClient) OperationStatusMethodResponder(resp *http.Response) (result OperationStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/models.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/models.go new file mode 100644 index 000000000000..d36aa5e4ae52 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/models.go @@ -0,0 +1,1567 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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/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/redisenterprise/mgmt/2020-10-01-preview/redisenterprise" + +// AccessKeys the secret access keys used for authenticating connections to redis +type AccessKeys struct { + autorest.Response `json:"-"` + // PrimaryKey - READ-ONLY; The current primary key that clients can use to authenticate + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - READ-ONLY; The current secondary key that clients can use to authenticate + SecondaryKey *string `json:"secondaryKey,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"` +} + +// Cluster describes the RedisEnterprise cluster +type Cluster struct { + autorest.Response `json:"-"` + // Sku - The SKU to create, which affects price, performance, and features. + Sku *Sku `json:"sku,omitempty"` + // Zones - The zones where this cluster will be deployed. + Zones *[]string `json:"zones,omitempty"` + // ClusterProperties - Other properties of the cluster. + *ClusterProperties `json:"properties,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 Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Sku != nil { + objectMap["sku"] = c.Sku + } + if c.Zones != nil { + objectMap["zones"] = c.Zones + } + if c.ClusterProperties != nil { + objectMap["properties"] = c.ClusterProperties + } + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + if c.Location != nil { + objectMap["location"] = c.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cluster struct. +func (c *Cluster) 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 "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + c.Sku = &sku + } + case "zones": + if v != nil { + var zones []string + err = json.Unmarshal(*v, &zones) + if err != nil { + return err + } + c.Zones = &zones + } + case "properties": + if v != nil { + var clusterProperties ClusterProperties + err = json.Unmarshal(*v, &clusterProperties) + if err != nil { + return err + } + c.ClusterProperties = &clusterProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// ClusterList the response of a list-all operation. +type ClusterList struct { + autorest.Response `json:"-"` + // Value - List of clusters. + Value *[]Cluster `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterList. +func (cl ClusterList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cl.Value != nil { + objectMap["value"] = cl.Value + } + return json.Marshal(objectMap) +} + +// ClusterListIterator provides access to a complete listing of Cluster values. +type ClusterListIterator struct { + i int + page ClusterListPage +} + +// 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 *ClusterListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListIterator.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 *ClusterListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ClusterListIterator) 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 ClusterListIterator) Response() ClusterList { + 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 ClusterListIterator) Value() Cluster { + if !iter.page.NotDone() { + return Cluster{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ClusterListIterator type. +func NewClusterListIterator(page ClusterListPage) ClusterListIterator { + return ClusterListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cl ClusterList) IsEmpty() bool { + return cl.Value == nil || len(*cl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cl ClusterList) hasNextLink() bool { + return cl.NextLink != nil && len(*cl.NextLink) != 0 +} + +// clusterListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cl ClusterList) clusterListPreparer(ctx context.Context) (*http.Request, error) { + if !cl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cl.NextLink))) +} + +// ClusterListPage contains a page of Cluster values. +type ClusterListPage struct { + fn func(context.Context, ClusterList) (ClusterList, error) + cl ClusterList +} + +// 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 *ClusterListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClusterListPage.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.cl) + if err != nil { + return err + } + page.cl = 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 *ClusterListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ClusterListPage) NotDone() bool { + return !page.cl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ClusterListPage) Response() ClusterList { + return page.cl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ClusterListPage) Values() []Cluster { + if page.cl.IsEmpty() { + return nil + } + return *page.cl.Value +} + +// Creates a new instance of the ClusterListPage type. +func NewClusterListPage(cur ClusterList, getNextPage func(context.Context, ClusterList) (ClusterList, error)) ClusterListPage { + return ClusterListPage{ + fn: getNextPage, + cl: cur, + } +} + +// ClusterProperties properties of RedisEnterprise clusters, as opposed to general resource properties like +// location, tags +type ClusterProperties struct { + // MinimumTLSVersion - The minimum TLS version for the cluster to support, e.g. '1.2' + MinimumTLSVersion *string `json:"minimumTlsVersion,omitempty"` + // HostName - READ-ONLY; DNS name of the cluster endpoint + HostName *string `json:"hostName,omitempty"` + // ProvisioningState - READ-ONLY; Current provisioning status of the cluster. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ResourceState - READ-ONLY; Current resource status of the cluster. Possible values include: 'ResourceStateRunning', 'ResourceStateCreating', 'ResourceStateCreateFailed', 'ResourceStateUpdating', 'ResourceStateUpdateFailed', 'ResourceStateDeleting', 'ResourceStateDeleteFailed', 'ResourceStateEnabling', 'ResourceStateEnableFailed', 'ResourceStateDisabling', 'ResourceStateDisableFailed', 'ResourceStateDisabled' + ResourceState ResourceState `json:"resourceState,omitempty"` + // RedisVersion - READ-ONLY; Version of redis the cluster supports, e.g. '6' + RedisVersion *string `json:"redisVersion,omitempty"` + // PrivateEndpointConnections - READ-ONLY; List of private endpoint connections associated with the specified RedisEnterprise cluster + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` +} + +// MarshalJSON is the custom marshaler for ClusterProperties. +func (cp ClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.MinimumTLSVersion != nil { + objectMap["minimumTlsVersion"] = cp.MinimumTLSVersion + } + return json.Marshal(objectMap) +} + +// ClusterUpdate a partial update to the RedisEnterprise cluster +type ClusterUpdate struct { + // Sku - The SKU to create, which affects price, performance, and features. + Sku *Sku `json:"sku,omitempty"` + // ClusterProperties - Other properties of the cluster. + *ClusterProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ClusterUpdate. +func (cu ClusterUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cu.Sku != nil { + objectMap["sku"] = cu.Sku + } + if cu.ClusterProperties != nil { + objectMap["properties"] = cu.ClusterProperties + } + if cu.Tags != nil { + objectMap["tags"] = cu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ClusterUpdate struct. +func (cu *ClusterUpdate) 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 "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + cu.Sku = &sku + } + case "properties": + if v != nil { + var clusterProperties ClusterProperties + err = json.Unmarshal(*v, &clusterProperties) + if err != nil { + return err + } + cu.ClusterProperties = &clusterProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + cu.Tags = tags + } + } + } + + return nil +} + +// CreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CreateFuture) Result(client Client) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.CreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.CreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.CreateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// Database describes a database on the RedisEnterprise cluster +type Database struct { + autorest.Response `json:"-"` + // DatabaseProperties - Other properties of the database. + *DatabaseProperties `json:"properties,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 Database. +func (d Database) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DatabaseProperties != nil { + objectMap["properties"] = d.DatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Database struct. +func (d *Database) 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 databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + d.DatabaseProperties = &databaseProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + } + } + + return nil +} + +// DatabaseExportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabaseExportFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabaseExportFuture) Result(client DatabaseClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseExportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.DatabaseExportFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseImportFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabaseImportFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabaseImportFuture) Result(client DatabaseClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseImportFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.DatabaseImportFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabaseList the response of a list-all operation. +type DatabaseList struct { + autorest.Response `json:"-"` + // Value - List of databases + Value *[]Database `json:"value,omitempty"` + // NextLink - READ-ONLY; The URI to fetch the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseList. +func (dl DatabaseList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dl.Value != nil { + objectMap["value"] = dl.Value + } + return json.Marshal(objectMap) +} + +// DatabaseListIterator provides access to a complete listing of Database values. +type DatabaseListIterator struct { + i int + page DatabaseListPage +} + +// 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 *DatabaseListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListIterator.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 *DatabaseListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DatabaseListIterator) 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 DatabaseListIterator) Response() DatabaseList { + 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 DatabaseListIterator) Value() Database { + if !iter.page.NotDone() { + return Database{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DatabaseListIterator type. +func NewDatabaseListIterator(page DatabaseListPage) DatabaseListIterator { + return DatabaseListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dl DatabaseList) IsEmpty() bool { + return dl.Value == nil || len(*dl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dl DatabaseList) hasNextLink() bool { + return dl.NextLink != nil && len(*dl.NextLink) != 0 +} + +// databaseListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dl DatabaseList) databaseListPreparer(ctx context.Context) (*http.Request, error) { + if !dl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dl.NextLink))) +} + +// DatabaseListPage contains a page of Database values. +type DatabaseListPage struct { + fn func(context.Context, DatabaseList) (DatabaseList, error) + dl DatabaseList +} + +// 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 *DatabaseListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DatabaseListPage.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.dl) + if err != nil { + return err + } + page.dl = 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 *DatabaseListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DatabaseListPage) NotDone() bool { + return !page.dl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DatabaseListPage) Response() DatabaseList { + return page.dl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DatabaseListPage) Values() []Database { + if page.dl.IsEmpty() { + return nil + } + return *page.dl.Value +} + +// Creates a new instance of the DatabaseListPage type. +func NewDatabaseListPage(cur DatabaseList, getNextPage func(context.Context, DatabaseList) (DatabaseList, error)) DatabaseListPage { + return DatabaseListPage{ + fn: getNextPage, + dl: cur, + } +} + +// DatabaseProperties properties of RedisEnterprise databases, as opposed to general resource properties +// like location, tags +type DatabaseProperties struct { + // ClientProtocol - Specifies whether redis clients can connect using TLS-encrypted or plaintext redis protocols. Default is TLS-encrypted. Possible values include: 'Encrypted', 'Plaintext' + ClientProtocol Protocol `json:"clientProtocol,omitempty"` + // Port - TCP port of the database endpoint. Specified at create time. Defaults to an available port. + Port *int32 `json:"port,omitempty"` + // ProvisioningState - READ-ONLY; Current provisioning status of the database. Possible values include: 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateDeleting' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ResourceState - READ-ONLY; Current resource status of the database. Possible values include: 'ResourceStateRunning', 'ResourceStateCreating', 'ResourceStateCreateFailed', 'ResourceStateUpdating', 'ResourceStateUpdateFailed', 'ResourceStateDeleting', 'ResourceStateDeleteFailed', 'ResourceStateEnabling', 'ResourceStateEnableFailed', 'ResourceStateDisabling', 'ResourceStateDisableFailed', 'ResourceStateDisabled' + ResourceState ResourceState `json:"resourceState,omitempty"` + // ClusteringPolicy - Clustering policy - default is OSSCluster. Specified at create time. Possible values include: 'EnterpriseCluster', 'OSSCluster' + ClusteringPolicy ClusteringPolicy `json:"clusteringPolicy,omitempty"` + // EvictionPolicy - Redis eviction policy - default is VolatileLRU. Possible values include: 'AllKeysLFU', 'AllKeysLRU', 'AllKeysRandom', 'VolatileLRU', 'VolatileLFU', 'VolatileTTL', 'VolatileRandom', 'NoEviction' + EvictionPolicy EvictionPolicy `json:"evictionPolicy,omitempty"` + // Modules - Optional set of redis modules to enable in this database - modules can only be added at creation time. + Modules *[]Module `json:"modules,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseProperties. +func (dp DatabaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.ClientProtocol != "" { + objectMap["clientProtocol"] = dp.ClientProtocol + } + if dp.Port != nil { + objectMap["port"] = dp.Port + } + if dp.ClusteringPolicy != "" { + objectMap["clusteringPolicy"] = dp.ClusteringPolicy + } + if dp.EvictionPolicy != "" { + objectMap["evictionPolicy"] = dp.EvictionPolicy + } + if dp.Modules != nil { + objectMap["modules"] = dp.Modules + } + return json.Marshal(objectMap) +} + +// DatabaseRegenerateKeyFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabaseRegenerateKeyFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabaseRegenerateKeyFuture) Result(client DatabaseClient) (ak AccessKeys, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseRegenerateKeyFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.DatabaseRegenerateKeyFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ak.Response.Response, err = future.GetResult(sender); err == nil && ak.Response.Response.StatusCode != http.StatusNoContent { + ak, err = client.RegenerateKeyResponder(ak.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabaseRegenerateKeyFuture", "Result", ak.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabasesCreateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.DatabasesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesCreateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabasesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabasesDeleteFuture) Result(client DatabasesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.DatabasesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DatabasesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DatabasesUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DatabasesUpdateFuture) Result(client DatabasesClient) (d Database, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.DatabasesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.UpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DatabasesUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DatabaseUpdate a partial update to the RedisEnterprise database +type DatabaseUpdate struct { + // DatabaseProperties - Properties of the database. + *DatabaseProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DatabaseUpdate. +func (du DatabaseUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if du.DatabaseProperties != nil { + objectMap["properties"] = du.DatabaseProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DatabaseUpdate struct. +func (du *DatabaseUpdate) 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 databaseProperties DatabaseProperties + err = json.Unmarshal(*v, &databaseProperties) + if err != nil { + return err + } + du.DatabaseProperties = &databaseProperties + } + } + } + + return nil +} + +// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *DeleteFuture) Result(client Client) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.DeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.DeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// ErrorDetail the error detail. +type ErrorDetail struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorDetail `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for +// failed operations. (This also follows the OData error response format.). +type ErrorResponse struct { + // Error - The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// ExportClusterParameters parameters for a Redis Enterprise export operation. +type ExportClusterParameters struct { + // SasURI - SAS Uri for the target directory to export to + SasURI *string `json:"sasUri,omitempty"` +} + +// ImportClusterParameters parameters for a Redis Enterprise import operation. +type ImportClusterParameters struct { + // SasURI - SAS Uri for the target blob to import from + SasURI *string `json:"sasUri,omitempty"` +} + +// Module specifies configuration of a redis module +type Module struct { + // Name - The name of the module, e.g. 'RedisBloom', 'RediSearch', 'RedisTimeSeries' + Name *string `json:"name,omitempty"` + // Args - Configuration options for the module, e.g. 'ERROR_RATE 0.00 INITIAL_SIZE 400'. + Args *string `json:"args,omitempty"` + // Version - READ-ONLY; The version of the module, e.g. '1.0'. + Version *string `json:"version,omitempty"` +} + +// MarshalJSON is the custom marshaler for Module. +func (mVar Module) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.Name != nil { + objectMap["name"] = mVar.Name + } + if mVar.Args != nil { + objectMap["args"] = mVar.Args + } + return json.Marshal(objectMap) +} + +// Operation details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Name - READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty"` + // IsDataAction - READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". Possible values include: 'User', 'System', 'Usersystem' + Origin Origin `json:"origin,omitempty"` + // ActionType - READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. Possible values include: 'Internal' + ActionType ActionType `json:"actionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay localized display information for this particular operation. +type OperationDisplay struct { + // Provider - READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty"` +} + +// OperationListResult a list of REST API operations supported by an Azure Resource Provider. It contains +// an URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of operations supported by the resource provider + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.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 *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.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.olr) + if err != nil { + return err + } + page.olr = 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 *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// OperationStatus the status of a long-running operation. +type OperationStatus struct { + autorest.Response `json:"-"` + // ID - The operation's unique id. + ID *string `json:"id,omitempty"` + // Name - The operation's name. + Name *string `json:"name,omitempty"` + // StartTime - The start time of the operation. + StartTime *string `json:"startTime,omitempty"` + // EndTime - The end time of the operation. + EndTime *string `json:"endTime,omitempty"` + // Status - The current status of the operation. + Status *string `json:"status,omitempty"` + // Error - Error response describing why the operation failed. + Error *ErrorResponse `json:"error,omitempty"` +} + +// PrivateEndpoint the Private Endpoint resource. +type PrivateEndpoint struct { + // ID - READ-ONLY; The ARM identifier for Private Endpoint + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointConnection the Private Endpoint Connection resource. +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,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 PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) 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 privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult list of private endpoint connection associated with the specified +// storage account +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - Array of private endpoint connections + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// PrivateEndpointConnectionProperties properties of the PrivateEndpointConnectProperties. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - The resource of private end point. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - The provisioning state of the private endpoint connection resource. Possible values include: 'Succeeded', 'Creating', 'Deleting', 'Failed' + ProvisioningState PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} + +// PrivateEndpointConnectionsPutFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsPutFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateEndpointConnectionsPutFuture) Result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsPutFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.PrivateEndpointConnectionsPutFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.PutResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsPutFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,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 PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) 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 privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceListResult a list of private link resources +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - Array of private link resources + Value *[]PrivateLinkResource `json:"value,omitempty"` +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - The private link resource Private link DNS zone name. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plrp.RequiredZoneNames != nil { + objectMap["requiredZoneNames"] = plrp.RequiredZoneNames + } + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionState a collection of information about the state of the connection between +// service consumer and provider. +type PrivateLinkServiceConnectionState struct { + // Status - Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: 'Pending', 'Approved', 'Rejected' + Status PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` + // Description - The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + // ActionsRequired - A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// ProxyResource the resource model definition for an Azure Resource Manager proxy resource. It will have +// everything other than required location and tags +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"` +} + +// RegenerateKeyParameters specifies which access keys to reset to a new random value. +type RegenerateKeyParameters struct { + // KeyType - Which access key to regenerate. Possible values include: 'Primary', 'Secondary' + KeyType AccessKeyType `json:"keyType,omitempty"` +} + +// 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"` +} + +// Sku SKU parameters supplied to the create RedisEnterprise operation. +type Sku struct { + // Name - The type of RedisEnterprise cluster to deploy. Possible values: (Enterprise_E10, EnterpriseFlash_F300 etc.). Possible values include: 'EnterpriseE10', 'EnterpriseE20', 'EnterpriseE50', 'EnterpriseE100', 'EnterpriseFlashF300', 'EnterpriseFlashF700', 'EnterpriseFlashF1500' + Name SkuName `json:"name,omitempty"` + // Capacity - The size of the RedisEnterprise cluster. Defaults to 2 or 3 depending on SKU. Valid values are (2, 4, 6, ...) for Enterprise SKUs and (3, 9, 15, ...) for Flash SKUs. + Capacity *int32 `json:"capacity,omitempty"` +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +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) +} + +// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type UpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *UpdateFuture) Result(client Client) (c Cluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.UpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redisenterprise.UpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.UpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.UpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/operations.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/operations.go new file mode 100644 index 000000000000..3076f83a3597 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/operations.go @@ -0,0 +1,149 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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 managing Redis Enterprise resources in Azure. +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 lists all of the available REST API operations of the Microsoft.Cache provider. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.OperationsClient", "List", resp, "Failure responding to request") + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Cache/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 OperationListResult, 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 OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redisenterprise.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, "redisenterprise.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.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 OperationListResultIterator, 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/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/privateendpointconnections.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/privateendpointconnections.go new file mode 100644 index 000000000000..146c29d3cf91 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/privateendpointconnections.go @@ -0,0 +1,362 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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" +) + +// PrivateEndpointConnectionsClient is the REST API for managing Redis Enterprise resources in Azure. +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient 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 NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete deletes the specified private endpoint connection associated with the RedisEnterprise cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GetMethod gets the specified private endpoint connection associated with the RedisEnterprise cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsClient) GetMethod(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.GetMethod") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetMethodPreparer(ctx, resourceGroupName, clusterName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "GetMethod", nil, "Failure preparing request") + return + } + + resp, err := client.GetMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "GetMethod", resp, "Failure sending request") + return + } + + result, err = client.GetMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "GetMethod", resp, "Failure responding to request") + } + + return +} + +// GetMethodPreparer prepares the GetMethod request. +func (client PrivateEndpointConnectionsClient) GetMethodPreparer(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMethodSender sends the GetMethod request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMethodResponder handles the response to the GetMethod request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetMethodResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all the private endpoint connections associated with the RedisEnterprise cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, clusterName string) (result PrivateEndpointConnectionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) 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 PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Put updates the state of the specified private endpoint connection associated with the RedisEnterprise cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsClient) Put(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsPutFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Put") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("redisenterprise.PrivateEndpointConnectionsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, resourceGroupName, clusterName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") + return + } + + result, err = client.PutSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateEndpointConnectionsClient", "Put", result.Response(), "Failure sending request") + return + } + + return +} + +// PutPreparer prepares the Put request. +func (client PrivateEndpointConnectionsClient) PutPreparer(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutSender sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) PutSender(req *http.Request) (future PrivateEndpointConnectionsPutFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) PutResponder(resp *http.Response) (result PrivateEndpointConnection, 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/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/privatelinkresources.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/privatelinkresources.go new file mode 100644 index 000000000000..74dcff0c4fd4 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/privatelinkresources.go @@ -0,0 +1,118 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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" +) + +// PrivateLinkResourcesClient is the REST API for managing Redis Enterprise resources in Azure. +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient 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 NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByRedisEnterpriseCache gets the private link resources that need to be created for a RedisEnterprise cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +func (client PrivateLinkResourcesClient) ListByRedisEnterpriseCache(ctx context.Context, resourceGroupName string, clusterName string) (result PrivateLinkResourceListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByRedisEnterpriseCache") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByRedisEnterpriseCachePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateLinkResourcesClient", "ListByRedisEnterpriseCache", nil, "Failure preparing request") + return + } + + resp, err := client.ListByRedisEnterpriseCacheSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateLinkResourcesClient", "ListByRedisEnterpriseCache", resp, "Failure sending request") + return + } + + result, err = client.ListByRedisEnterpriseCacheResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.PrivateLinkResourcesClient", "ListByRedisEnterpriseCache", resp, "Failure responding to request") + } + + return +} + +// ListByRedisEnterpriseCachePreparer prepares the ListByRedisEnterpriseCache request. +func (client PrivateLinkResourcesClient) ListByRedisEnterpriseCachePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByRedisEnterpriseCacheSender sends the ListByRedisEnterpriseCache request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByRedisEnterpriseCacheSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByRedisEnterpriseCacheResponder handles the response to the ListByRedisEnterpriseCache request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByRedisEnterpriseCacheResponder(resp *http.Response) (result PrivateLinkResourceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/redisenterprise.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/redisenterprise.go new file mode 100644 index 000000000000..3b1d6d641524 --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/redisenterprise.go @@ -0,0 +1,579 @@ +package redisenterprise + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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" +) + +// Client is the REST API for managing Redis Enterprise resources in Azure. +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient(subscriptionID string) Client { + return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClientWithBaseURI creates an instance of the Client 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 NewClientWithBaseURI(baseURI string, subscriptionID string) Client { + return Client{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates or updates an existing (overwrite/recreate, with potential downtime) cache cluster +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// parameters - parameters supplied to the Create RedisEnterprise operation. +func (client Client) Create(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster) (result CreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("redisenterprise.Client", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, clusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client Client) CreatePreparer(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CreateSender(req *http.Request) (future CreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client Client) CreateResponder(resp *http.Response) (result Cluster, 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 deletes a RedisEnterprise cache cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +func (client Client) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result DeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}", 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 Client) DeleteSender(req *http.Request) (future DeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client Client) 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 +} + +// GetMethod gets information about a RedisEnterprise cluster +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +func (client Client) GetMethod(ctx context.Context, resourceGroupName string, clusterName string) (result Cluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetMethod") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetMethodPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "GetMethod", nil, "Failure preparing request") + return + } + + resp, err := client.GetMethodSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "GetMethod", resp, "Failure sending request") + return + } + + result, err = client.GetMethodResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "GetMethod", resp, "Failure responding to request") + } + + return +} + +// GetMethodPreparer prepares the GetMethod request. +func (client Client) GetMethodPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-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.Cache/redisEnterprise/{clusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetMethodSender sends the GetMethod request. The method will close the +// http.Response Body if it receives an error. +func (client Client) GetMethodSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetMethodResponder handles the response to the GetMethod request. The method always +// closes the http.Response Body. +func (client Client) GetMethodResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets all RedisEnterprise clusters in the specified subscription. +func (client Client) List(ctx context.Context) (result ClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "List", resp, "Failure sending request") + return + } + + result.cl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "List", resp, "Failure responding to request") + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client Client) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Cache/redisEnterprise", 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 Client) 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 Client) ListResponder(resp *http.Response) (result ClusterList, 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 Client) listNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { + req, err := lastResults.clusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redisenterprise.Client", "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, "redisenterprise.Client", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListComplete(ctx context.Context) (result ClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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 +} + +// ListByResourceGroup lists all RedisEnterprise clusters in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ClusterListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.cl.Response.Response != nil { + sc = result.cl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.cl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.cl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.cl.hasNextLink() && result.cl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client Client) 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 = "2020-10-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.Cache/redisEnterprise", 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 Client) 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 Client) ListByResourceGroupResponder(resp *http.Response) (result ClusterList, 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 Client) listByResourceGroupNextResults(ctx context.Context, lastResults ClusterList) (result ClusterList, err error) { + req, err := lastResults.clusterListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "redisenterprise.Client", "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, "redisenterprise.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ClusterListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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 +} + +// Update updates an existing RedisEnterprise cluster +// Parameters: +// resourceGroupName - the name of the resource group. +// clusterName - the name of the RedisEnterprise cluster. +// parameters - parameters supplied to the Update RedisEnterprise operation. +func (client Client) Update(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdate) (result UpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, clusterName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redisenterprise.Client", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-10-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redisEnterprise/{clusterName}", 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 Client) UpdateSender(req *http.Request) (future UpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client Client) UpdateResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/redisenterpriseapi/interfaces.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/redisenterpriseapi/interfaces.go new file mode 100644 index 000000000000..2e13e57ad83d --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/redisenterpriseapi/interfaces.go @@ -0,0 +1,92 @@ +package redisenterpriseapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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/redisenterprise/mgmt/2020-10-01-preview/redisenterprise" + "github.com/Azure/go-autorest/autorest" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result redisenterprise.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result redisenterprise.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*redisenterprise.OperationsClient)(nil) + +// GetClientAPI contains the set of methods on the GetClient type. +type GetClientAPI interface { + OperationStatusMethod(ctx context.Context, location string, operationID string) (result redisenterprise.OperationStatus, err error) +} + +var _ GetClientAPI = (*redisenterprise.GetClient)(nil) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + Create(ctx context.Context, resourceGroupName string, clusterName string, parameters redisenterprise.Cluster) (result redisenterprise.CreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string) (result redisenterprise.DeleteFuture, err error) + GetMethod(ctx context.Context, resourceGroupName string, clusterName string) (result redisenterprise.Cluster, err error) + List(ctx context.Context) (result redisenterprise.ClusterListPage, err error) + ListComplete(ctx context.Context) (result redisenterprise.ClusterListIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result redisenterprise.ClusterListPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result redisenterprise.ClusterListIterator, err error) + Update(ctx context.Context, resourceGroupName string, clusterName string, parameters redisenterprise.ClusterUpdate) (result redisenterprise.UpdateFuture, err error) +} + +var _ ClientAPI = (*redisenterprise.Client)(nil) + +// DatabasesClientAPI contains the set of methods on the DatabasesClient type. +type DatabasesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters redisenterprise.Database) (result redisenterprise.DatabasesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (result redisenterprise.DatabasesDeleteFuture, err error) + GetMethod(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (result redisenterprise.Database, err error) + ListByCluster(ctx context.Context, resourceGroupName string, clusterName string) (result redisenterprise.DatabaseListPage, err error) + ListByClusterComplete(ctx context.Context, resourceGroupName string, clusterName string) (result redisenterprise.DatabaseListIterator, err error) + Update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters redisenterprise.DatabaseUpdate) (result redisenterprise.DatabasesUpdateFuture, err error) +} + +var _ DatabasesClientAPI = (*redisenterprise.DatabasesClient)(nil) + +// DatabaseClientAPI contains the set of methods on the DatabaseClient type. +type DatabaseClientAPI interface { + Export(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters redisenterprise.ExportClusterParameters) (result redisenterprise.DatabaseExportFuture, err error) + Import(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters redisenterprise.ImportClusterParameters) (result redisenterprise.DatabaseImportFuture, err error) + ListKeys(ctx context.Context, resourceGroupName string, clusterName string, databaseName string) (result redisenterprise.AccessKeys, err error) + RegenerateKey(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters redisenterprise.RegenerateKeyParameters) (result redisenterprise.DatabaseRegenerateKeyFuture, err error) +} + +var _ DatabaseClientAPI = (*redisenterprise.DatabaseClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string) (result autorest.Response, err error) + GetMethod(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string) (result redisenterprise.PrivateEndpointConnection, err error) + List(ctx context.Context, resourceGroupName string, clusterName string) (result redisenterprise.PrivateEndpointConnectionListResult, err error) + Put(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, properties redisenterprise.PrivateEndpointConnection) (result redisenterprise.PrivateEndpointConnectionsPutFuture, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*redisenterprise.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + ListByRedisEnterpriseCache(ctx context.Context, resourceGroupName string, clusterName string) (result redisenterprise.PrivateLinkResourceListResult, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*redisenterprise.PrivateLinkResourcesClient)(nil) diff --git a/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/version.go b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/version.go new file mode 100644 index 000000000000..8f50bbd50dfd --- /dev/null +++ b/services/preview/redisenterprise/mgmt/2020-10-01-preview/redisenterprise/version.go @@ -0,0 +1,30 @@ +package redisenterprise + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by 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() + " redisenterprise/2020-10-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}