diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/appconfigurationapi/interfaces.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/appconfigurationapi/interfaces.go new file mode 100644 index 000000000000..69ea96a551ae --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/appconfigurationapi/interfaces.go @@ -0,0 +1,80 @@ +package appconfigurationapi + +// 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/appconfiguration/mgmt/2020-07-01-preview/appconfiguration" +) + +// ConfigurationStoresClientAPI contains the set of methods on the ConfigurationStoresClient type. +type ConfigurationStoresClientAPI interface { + Create(ctx context.Context, resourceGroupName string, configStoreName string, configStoreCreationParameters appconfiguration.ConfigurationStore) (result appconfiguration.ConfigurationStoresCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, configStoreName string) (result appconfiguration.ConfigurationStoresDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, configStoreName string) (result appconfiguration.ConfigurationStore, err error) + List(ctx context.Context, skipToken string) (result appconfiguration.ConfigurationStoreListResultPage, err error) + ListComplete(ctx context.Context, skipToken string) (result appconfiguration.ConfigurationStoreListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string, skipToken string) (result appconfiguration.ConfigurationStoreListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, skipToken string) (result appconfiguration.ConfigurationStoreListResultIterator, err error) + ListKeys(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result appconfiguration.APIKeyListResultPage, err error) + ListKeysComplete(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result appconfiguration.APIKeyListResultIterator, err error) + RegenerateKey(ctx context.Context, resourceGroupName string, configStoreName string, regenerateKeyParameters appconfiguration.RegenerateKeyParameters) (result appconfiguration.APIKey, err error) + Update(ctx context.Context, resourceGroupName string, configStoreName string, configStoreUpdateParameters appconfiguration.ConfigurationStoreUpdateParameters) (result appconfiguration.ConfigurationStoresUpdateFuture, err error) +} + +var _ ConfigurationStoresClientAPI = (*appconfiguration.ConfigurationStoresClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + CheckNameAvailability(ctx context.Context, checkNameAvailabilityParameters appconfiguration.CheckNameAvailabilityParameters) (result appconfiguration.NameAvailabilityStatus, err error) + List(ctx context.Context, skipToken string) (result appconfiguration.OperationDefinitionListResultPage, err error) + ListComplete(ctx context.Context, skipToken string) (result appconfiguration.OperationDefinitionListResultIterator, err error) +} + +var _ OperationsClientAPI = (*appconfiguration.OperationsClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string, privateEndpointConnection appconfiguration.PrivateEndpointConnection) (result appconfiguration.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string) (result appconfiguration.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string) (result appconfiguration.PrivateEndpointConnection, err error) + ListByConfigurationStore(ctx context.Context, resourceGroupName string, configStoreName string) (result appconfiguration.PrivateEndpointConnectionListResultPage, err error) + ListByConfigurationStoreComplete(ctx context.Context, resourceGroupName string, configStoreName string) (result appconfiguration.PrivateEndpointConnectionListResultIterator, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*appconfiguration.PrivateEndpointConnectionsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, configStoreName string, groupName string) (result appconfiguration.PrivateLinkResource, err error) + ListByConfigurationStore(ctx context.Context, resourceGroupName string, configStoreName string) (result appconfiguration.PrivateLinkResourceListResultPage, err error) + ListByConfigurationStoreComplete(ctx context.Context, resourceGroupName string, configStoreName string) (result appconfiguration.PrivateLinkResourceListResultIterator, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*appconfiguration.PrivateLinkResourcesClient)(nil) + +// KeyValuesClientAPI contains the set of methods on the KeyValuesClient type. +type KeyValuesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string, keyValueParameters *appconfiguration.KeyValue) (result appconfiguration.KeyValue, err error) + Delete(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string) (result appconfiguration.KeyValuesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string) (result appconfiguration.KeyValue, err error) + ListByConfigurationStore(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result appconfiguration.KeyValueListResultPage, err error) + ListByConfigurationStoreComplete(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result appconfiguration.KeyValueListResultIterator, err error) +} + +var _ KeyValuesClientAPI = (*appconfiguration.KeyValuesClient)(nil) diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/client.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/client.go new file mode 100644 index 000000000000..d9ac144e76ab --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/client.go @@ -0,0 +1,52 @@ +// Package appconfiguration implements the Azure ARM Appconfiguration service API version 2020-07-01-preview. +// +// +package appconfiguration + +// 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 Appconfiguration + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Appconfiguration. +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/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/configurationstores.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/configurationstores.go new file mode 100644 index 000000000000..d81ad137cf32 --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/configurationstores.go @@ -0,0 +1,838 @@ +package appconfiguration + +// 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" +) + +// ConfigurationStoresClient is the client for the ConfigurationStores methods of the Appconfiguration service. +type ConfigurationStoresClient struct { + BaseClient +} + +// NewConfigurationStoresClient creates an instance of the ConfigurationStoresClient client. +func NewConfigurationStoresClient(subscriptionID string) ConfigurationStoresClient { + return NewConfigurationStoresClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConfigurationStoresClientWithBaseURI creates an instance of the ConfigurationStoresClient 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 NewConfigurationStoresClientWithBaseURI(baseURI string, subscriptionID string) ConfigurationStoresClient { + return ConfigurationStoresClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a configuration store with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// configStoreCreationParameters - the parameters for creating a configuration store. +func (client ConfigurationStoresClient) Create(ctx context.Context, resourceGroupName string, configStoreName string, configStoreCreationParameters ConfigurationStore) (result ConfigurationStoresCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.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: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}, + {TargetValue: configStoreCreationParameters, + Constraints: []validation.Constraint{{Target: "configStoreCreationParameters.Sku", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "configStoreCreationParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("appconfiguration.ConfigurationStoresClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, configStoreName, configStoreCreationParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ConfigurationStoresClient) CreatePreparer(ctx context.Context, resourceGroupName string, configStoreName string, configStoreCreationParameters ConfigurationStore) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}", pathParameters), + autorest.WithJSON(configStoreCreationParameters), + 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 ConfigurationStoresClient) CreateSender(req *http.Request) (future ConfigurationStoresCreateFuture, 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 ConfigurationStoresClient) CreateResponder(resp *http.Response) (result ConfigurationStore, 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 configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +func (client ConfigurationStoresClient) Delete(ctx context.Context, resourceGroupName string, configStoreName string) (result ConfigurationStoresDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.ConfigurationStoresClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, configStoreName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConfigurationStoresClient) DeletePreparer(ctx context.Context, resourceGroupName string, configStoreName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}", 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 ConfigurationStoresClient) DeleteSender(req *http.Request) (future ConfigurationStoresDeleteFuture, 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 ConfigurationStoresClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +func (client ConfigurationStoresClient) Get(ctx context.Context, resourceGroupName string, configStoreName string) (result ConfigurationStore, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.ConfigurationStoresClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, configStoreName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConfigurationStoresClient) GetPreparer(ctx context.Context, resourceGroupName string, configStoreName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ConfigurationStoresClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ConfigurationStoresClient) GetResponder(resp *http.Response) (result ConfigurationStore, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the configuration stores for a given subscription. +// Parameters: +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client ConfigurationStoresClient) List(ctx context.Context, skipToken string) (result ConfigurationStoreListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.List") + defer func() { + sc := -1 + if result.cslr.Response.Response != nil { + sc = result.cslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.cslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "List", resp, "Failure sending request") + return + } + + result.cslr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "List", resp, "Failure responding to request") + } + if result.cslr.hasNextLink() && result.cslr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client ConfigurationStoresClient) ListPreparer(ctx context.Context, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AppConfiguration/configurationStores", 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 ConfigurationStoresClient) 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 ConfigurationStoresClient) ListResponder(resp *http.Response) (result ConfigurationStoreListResult, 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 ConfigurationStoresClient) listNextResults(ctx context.Context, lastResults ConfigurationStoreListResult) (result ConfigurationStoreListResult, err error) { + req, err := lastResults.configurationStoreListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "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, "appconfiguration.ConfigurationStoresClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConfigurationStoresClient) ListComplete(ctx context.Context, skipToken string) (result ConfigurationStoreListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.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, skipToken) + return +} + +// ListByResourceGroup lists the configuration stores for a given resource group. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client ConfigurationStoresClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, skipToken string) (result ConfigurationStoreListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.cslr.Response.Response != nil { + sc = result.cslr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.cslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.cslr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.cslr.hasNextLink() && result.cslr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ConfigurationStoresClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores", 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 ConfigurationStoresClient) 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 ConfigurationStoresClient) ListByResourceGroupResponder(resp *http.Response) (result ConfigurationStoreListResult, 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 ConfigurationStoresClient) listByResourceGroupNextResults(ctx context.Context, lastResults ConfigurationStoreListResult) (result ConfigurationStoreListResult, err error) { + req, err := lastResults.configurationStoreListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "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, "appconfiguration.ConfigurationStoresClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConfigurationStoresClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, skipToken string) (result ConfigurationStoreListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.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, skipToken) + return +} + +// ListKeys lists the access key for the specified configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client ConfigurationStoresClient) ListKeys(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result APIKeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.ListKeys") + defer func() { + sc := -1 + if result.aklr.Response.Response != nil { + sc = result.aklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.ConfigurationStoresClient", "ListKeys", err.Error()) + } + + result.fn = client.listKeysNextResults + req, err := client.ListKeysPreparer(ctx, resourceGroupName, configStoreName, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.aklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "ListKeys", resp, "Failure sending request") + return + } + + result.aklr, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "ListKeys", resp, "Failure responding to request") + } + if result.aklr.hasNextLink() && result.aklr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client ConfigurationStoresClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/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 ConfigurationStoresClient) 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 ConfigurationStoresClient) ListKeysResponder(resp *http.Response) (result APIKeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listKeysNextResults retrieves the next set of results, if any. +func (client ConfigurationStoresClient) listKeysNextResults(ctx context.Context, lastResults APIKeyListResult) (result APIKeyListResult, err error) { + req, err := lastResults.aPIKeyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "listKeysNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "listKeysNextResults", resp, "Failure sending next results request") + } + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "listKeysNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListKeysComplete enumerates all values, automatically crossing page boundaries as required. +func (client ConfigurationStoresClient) ListKeysComplete(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result APIKeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.ListKeys") + 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.ListKeys(ctx, resourceGroupName, configStoreName, skipToken) + return +} + +// RegenerateKey regenerates an access key for the specified configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// regenerateKeyParameters - the parameters for regenerating an access key. +func (client ConfigurationStoresClient) RegenerateKey(ctx context.Context, resourceGroupName string, configStoreName string, regenerateKeyParameters RegenerateKeyParameters) (result APIKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.RegenerateKey") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.ConfigurationStoresClient", "RegenerateKey", err.Error()) + } + + req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, configStoreName, regenerateKeyParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "RegenerateKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "RegenerateKey", resp, "Failure responding to request") + } + + return +} + +// RegenerateKeyPreparer prepares the RegenerateKey request. +func (client ConfigurationStoresClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, configStoreName string, regenerateKeyParameters RegenerateKeyParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/regenerateKey", pathParameters), + autorest.WithJSON(regenerateKeyParameters), + 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 ConfigurationStoresClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (client ConfigurationStoresClient) RegenerateKeyResponder(resp *http.Response) (result APIKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates a configuration store with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// configStoreUpdateParameters - the parameters for updating a configuration store. +func (client ConfigurationStoresClient) Update(ctx context.Context, resourceGroupName string, configStoreName string, configStoreUpdateParameters ConfigurationStoreUpdateParameters) (result ConfigurationStoresUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoresClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.ConfigurationStoresClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, configStoreName, configStoreUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConfigurationStoresClient) UpdatePreparer(ctx context.Context, resourceGroupName string, configStoreName string, configStoreUpdateParameters ConfigurationStoreUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}", pathParameters), + autorest.WithJSON(configStoreUpdateParameters), + 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 ConfigurationStoresClient) UpdateSender(req *http.Request) (future ConfigurationStoresUpdateFuture, 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 ConfigurationStoresClient) UpdateResponder(resp *http.Response) (result ConfigurationStore, 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/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/enums.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/enums.go new file mode 100644 index 000000000000..0b51de9fb1e6 --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/enums.go @@ -0,0 +1,109 @@ +package appconfiguration + +// 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. + +// ActionsRequired enumerates the values for actions required. +type ActionsRequired string + +const ( + // None ... + None ActionsRequired = "None" + // Recreate ... + Recreate ActionsRequired = "Recreate" +) + +// PossibleActionsRequiredValues returns an array of possible values for the ActionsRequired const type. +func PossibleActionsRequiredValues() []ActionsRequired { + return []ActionsRequired{None, Recreate} +} + +// ConnectionStatus enumerates the values for connection status. +type ConnectionStatus string + +const ( + // Approved ... + Approved ConnectionStatus = "Approved" + // Disconnected ... + Disconnected ConnectionStatus = "Disconnected" + // Pending ... + Pending ConnectionStatus = "Pending" + // Rejected ... + Rejected ConnectionStatus = "Rejected" +) + +// PossibleConnectionStatusValues returns an array of possible values for the ConnectionStatus const type. +func PossibleConnectionStatusValues() []ConnectionStatus { + return []ConnectionStatus{Approved, Disconnected, Pending, Rejected} +} + +// IdentityType enumerates the values for identity type. +type IdentityType string + +const ( + // IdentityTypeNone ... + IdentityTypeNone IdentityType = "None" + // IdentityTypeSystemAssigned ... + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + // IdentityTypeSystemAssignedUserAssigned ... + IdentityTypeSystemAssignedUserAssigned IdentityType = "SystemAssigned, UserAssigned" + // IdentityTypeUserAssigned ... + IdentityTypeUserAssigned IdentityType = "UserAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{IdentityTypeNone, IdentityTypeSystemAssigned, IdentityTypeSystemAssignedUserAssigned, IdentityTypeUserAssigned} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Canceled ... + Canceled ProvisioningState = "Canceled" + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Canceled, Creating, Deleting, Failed, Succeeded, Updating} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // Disabled ... + Disabled PublicNetworkAccess = "Disabled" + // Enabled ... + Enabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled} +} diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/keyvalues.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/keyvalues.go new file mode 100644 index 000000000000..e8641227037a --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/keyvalues.go @@ -0,0 +1,439 @@ +package appconfiguration + +// 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" +) + +// KeyValuesClient is the client for the KeyValues methods of the Appconfiguration service. +type KeyValuesClient struct { + BaseClient +} + +// NewKeyValuesClient creates an instance of the KeyValuesClient client. +func NewKeyValuesClient(subscriptionID string) KeyValuesClient { + return NewKeyValuesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewKeyValuesClientWithBaseURI creates an instance of the KeyValuesClient 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 NewKeyValuesClientWithBaseURI(baseURI string, subscriptionID string) KeyValuesClient { + return KeyValuesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a key-value. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// keyValueName - identifier of key and label combination. Key and label are joined by $ character. Label is +// optional. +// keyValueParameters - the parameters for creating a key-value. +func (client KeyValuesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string, keyValueParameters *KeyValue) (result KeyValue, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyValuesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.KeyValuesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, configStoreName, keyValueName, keyValueParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client KeyValuesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string, keyValueParameters *KeyValue) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "keyValueName": autorest.Encode("path", keyValueName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + keyValueParameters.ID = nil + keyValueParameters.Name = nil + keyValueParameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if keyValueParameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(keyValueParameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client KeyValuesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client KeyValuesClient) CreateOrUpdateResponder(resp *http.Response) (result KeyValue, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a key-value. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// keyValueName - identifier of key and label combination. Key and label are joined by $ character. Label is +// optional. +func (client KeyValuesClient) Delete(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string) (result KeyValuesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyValuesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.KeyValuesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, configStoreName, keyValueName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client KeyValuesClient) DeletePreparer(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "keyValueName": autorest.Encode("path", keyValueName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}", 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 KeyValuesClient) DeleteSender(req *http.Request) (future KeyValuesDeleteFuture, 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 KeyValuesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified key-value. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// keyValueName - identifier of key and label combination. Key and label are joined by $ character. Label is +// optional. +func (client KeyValuesClient) Get(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string) (result KeyValue, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyValuesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.KeyValuesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, configStoreName, keyValueName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client KeyValuesClient) GetPreparer(ctx context.Context, resourceGroupName string, configStoreName string, keyValueName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "keyValueName": autorest.Encode("path", keyValueName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/keyValues/{keyValueName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client KeyValuesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client KeyValuesClient) GetResponder(resp *http.Response) (result KeyValue, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByConfigurationStore lists the key-values for a given configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client KeyValuesClient) ListByConfigurationStore(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result KeyValueListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyValuesClient.ListByConfigurationStore") + defer func() { + sc := -1 + if result.kvlr.Response.Response != nil { + sc = result.kvlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.KeyValuesClient", "ListByConfigurationStore", err.Error()) + } + + result.fn = client.listByConfigurationStoreNextResults + req, err := client.ListByConfigurationStorePreparer(ctx, resourceGroupName, configStoreName, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "ListByConfigurationStore", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationStoreSender(req) + if err != nil { + result.kvlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "ListByConfigurationStore", resp, "Failure sending request") + return + } + + result.kvlr, err = client.ListByConfigurationStoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "ListByConfigurationStore", resp, "Failure responding to request") + } + if result.kvlr.hasNextLink() && result.kvlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByConfigurationStorePreparer prepares the ListByConfigurationStore request. +func (client KeyValuesClient) ListByConfigurationStorePreparer(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/keyValues", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationStoreSender sends the ListByConfigurationStore request. The method will close the +// http.Response Body if it receives an error. +func (client KeyValuesClient) ListByConfigurationStoreSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationStoreResponder handles the response to the ListByConfigurationStore request. The method always +// closes the http.Response Body. +func (client KeyValuesClient) ListByConfigurationStoreResponder(resp *http.Response) (result KeyValueListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByConfigurationStoreNextResults retrieves the next set of results, if any. +func (client KeyValuesClient) listByConfigurationStoreNextResults(ctx context.Context, lastResults KeyValueListResult) (result KeyValueListResult, err error) { + req, err := lastResults.keyValueListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "listByConfigurationStoreNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByConfigurationStoreSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "listByConfigurationStoreNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByConfigurationStoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesClient", "listByConfigurationStoreNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByConfigurationStoreComplete enumerates all values, automatically crossing page boundaries as required. +func (client KeyValuesClient) ListByConfigurationStoreComplete(ctx context.Context, resourceGroupName string, configStoreName string, skipToken string) (result KeyValueListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyValuesClient.ListByConfigurationStore") + 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.ListByConfigurationStore(ctx, resourceGroupName, configStoreName, skipToken) + return +} diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/models.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/models.go new file mode 100644 index 000000000000..b69f4e891573 --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/models.go @@ -0,0 +1,2018 @@ +package appconfiguration + +// 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/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration" + +// APIKey an API key used for authenticating with a configuration store endpoint. +type APIKey struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The key ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; A name for the key describing its usage. + Name *string `json:"name,omitempty"` + // Value - READ-ONLY; The value of the key that is used for authentication purposes. + Value *string `json:"value,omitempty"` + // ConnectionString - READ-ONLY; A connection string that can be used by supporting clients for authentication. + ConnectionString *string `json:"connectionString,omitempty"` + // LastModified - READ-ONLY; The last time any of the key's properties were modified. + LastModified *date.Time `json:"lastModified,omitempty"` + // ReadOnly - READ-ONLY; Whether this key can only be used for read operations. + ReadOnly *bool `json:"readOnly,omitempty"` +} + +// APIKeyListResult the result of a request to list API keys. +type APIKeyListResult struct { + autorest.Response `json:"-"` + // Value - The collection value. + Value *[]APIKey `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` +} + +// APIKeyListResultIterator provides access to a complete listing of APIKey values. +type APIKeyListResultIterator struct { + i int + page APIKeyListResultPage +} + +// 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 *APIKeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeyListResultIterator.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 *APIKeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APIKeyListResultIterator) 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 APIKeyListResultIterator) Response() APIKeyListResult { + 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 APIKeyListResultIterator) Value() APIKey { + if !iter.page.NotDone() { + return APIKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APIKeyListResultIterator type. +func NewAPIKeyListResultIterator(page APIKeyListResultPage) APIKeyListResultIterator { + return APIKeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aklr APIKeyListResult) IsEmpty() bool { + return aklr.Value == nil || len(*aklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aklr APIKeyListResult) hasNextLink() bool { + return aklr.NextLink != nil && len(*aklr.NextLink) != 0 +} + +// aPIKeyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aklr APIKeyListResult) aPIKeyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !aklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aklr.NextLink))) +} + +// APIKeyListResultPage contains a page of APIKey values. +type APIKeyListResultPage struct { + fn func(context.Context, APIKeyListResult) (APIKeyListResult, error) + aklr APIKeyListResult +} + +// 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 *APIKeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeyListResultPage.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.aklr) + if err != nil { + return err + } + page.aklr = 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 *APIKeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APIKeyListResultPage) NotDone() bool { + return !page.aklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APIKeyListResultPage) Response() APIKeyListResult { + return page.aklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APIKeyListResultPage) Values() []APIKey { + if page.aklr.IsEmpty() { + return nil + } + return *page.aklr.Value +} + +// Creates a new instance of the APIKeyListResultPage type. +func NewAPIKeyListResultPage(cur APIKeyListResult, getNextPage func(context.Context, APIKeyListResult) (APIKeyListResult, error)) APIKeyListResultPage { + return APIKeyListResultPage{ + fn: getNextPage, + aklr: cur, + } +} + +// CheckNameAvailabilityParameters parameters used for checking whether a resource name is available. +type CheckNameAvailabilityParameters struct { + // Name - The name to check for availability. + Name *string `json:"name,omitempty"` + // Type - The resource type to check for name availability. + Type *string `json:"type,omitempty"` +} + +// ConfigurationStore the configuration store along with all resource properties. The Configuration Store +// will have all information to begin utilizing it. +type ConfigurationStore struct { + autorest.Response `json:"-"` + // Identity - The managed identity information, if configured. + Identity *ResourceIdentity `json:"identity,omitempty"` + // ConfigurationStoreProperties - The properties of a configuration store. + *ConfigurationStoreProperties `json:"properties,omitempty"` + // Sku - The sku of the configuration store. + Sku *Sku `json:"sku,omitempty"` + // ID - READ-ONLY; The resource ID. + 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. + Type *string `json:"type,omitempty"` + // Location - The location of the resource. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ConfigurationStore. +func (cs ConfigurationStore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cs.Identity != nil { + objectMap["identity"] = cs.Identity + } + if cs.ConfigurationStoreProperties != nil { + objectMap["properties"] = cs.ConfigurationStoreProperties + } + if cs.Sku != nil { + objectMap["sku"] = cs.Sku + } + if cs.Location != nil { + objectMap["location"] = cs.Location + } + if cs.Tags != nil { + objectMap["tags"] = cs.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConfigurationStore struct. +func (cs *ConfigurationStore) 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 "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + cs.Identity = &identity + } + case "properties": + if v != nil { + var configurationStoreProperties ConfigurationStoreProperties + err = json.Unmarshal(*v, &configurationStoreProperties) + if err != nil { + return err + } + cs.ConfigurationStoreProperties = &configurationStoreProperties + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + cs.Sku = &sku + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cs.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + cs.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + cs.Tags = tags + } + } + } + + return nil +} + +// ConfigurationStoreListResult the result of a request to list configuration stores. +type ConfigurationStoreListResult struct { + autorest.Response `json:"-"` + // Value - The collection value. + Value *[]ConfigurationStore `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ConfigurationStoreListResultIterator provides access to a complete listing of ConfigurationStore values. +type ConfigurationStoreListResultIterator struct { + i int + page ConfigurationStoreListResultPage +} + +// 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 *ConfigurationStoreListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoreListResultIterator.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 *ConfigurationStoreListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ConfigurationStoreListResultIterator) 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 ConfigurationStoreListResultIterator) Response() ConfigurationStoreListResult { + 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 ConfigurationStoreListResultIterator) Value() ConfigurationStore { + if !iter.page.NotDone() { + return ConfigurationStore{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ConfigurationStoreListResultIterator type. +func NewConfigurationStoreListResultIterator(page ConfigurationStoreListResultPage) ConfigurationStoreListResultIterator { + return ConfigurationStoreListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cslr ConfigurationStoreListResult) IsEmpty() bool { + return cslr.Value == nil || len(*cslr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (cslr ConfigurationStoreListResult) hasNextLink() bool { + return cslr.NextLink != nil && len(*cslr.NextLink) != 0 +} + +// configurationStoreListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cslr ConfigurationStoreListResult) configurationStoreListResultPreparer(ctx context.Context) (*http.Request, error) { + if !cslr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cslr.NextLink))) +} + +// ConfigurationStoreListResultPage contains a page of ConfigurationStore values. +type ConfigurationStoreListResultPage struct { + fn func(context.Context, ConfigurationStoreListResult) (ConfigurationStoreListResult, error) + cslr ConfigurationStoreListResult +} + +// 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 *ConfigurationStoreListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ConfigurationStoreListResultPage.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.cslr) + if err != nil { + return err + } + page.cslr = 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 *ConfigurationStoreListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ConfigurationStoreListResultPage) NotDone() bool { + return !page.cslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ConfigurationStoreListResultPage) Response() ConfigurationStoreListResult { + return page.cslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ConfigurationStoreListResultPage) Values() []ConfigurationStore { + if page.cslr.IsEmpty() { + return nil + } + return *page.cslr.Value +} + +// Creates a new instance of the ConfigurationStoreListResultPage type. +func NewConfigurationStoreListResultPage(cur ConfigurationStoreListResult, getNextPage func(context.Context, ConfigurationStoreListResult) (ConfigurationStoreListResult, error)) ConfigurationStoreListResultPage { + return ConfigurationStoreListResultPage{ + fn: getNextPage, + cslr: cur, + } +} + +// ConfigurationStoreProperties the properties of a configuration store. +type ConfigurationStoreProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state of the configuration store. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // CreationDate - READ-ONLY; The creation date of configuration store. + CreationDate *date.Time `json:"creationDate,omitempty"` + // Endpoint - READ-ONLY; The DNS endpoint where the configuration store API will be available. + Endpoint *string `json:"endpoint,omitempty"` + // Encryption - The encryption settings of the configuration store. + Encryption *EncryptionProperties `json:"encryption,omitempty"` + // PrivateEndpointConnections - READ-ONLY; The list of private endpoint connections that are set up for this resource. + PrivateEndpointConnections *[]PrivateEndpointConnectionReference `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConfigurationStoreProperties. +func (csp ConfigurationStoreProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if csp.Encryption != nil { + objectMap["encryption"] = csp.Encryption + } + if csp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = csp.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// ConfigurationStorePropertiesUpdateParameters the properties for updating a configuration store. +type ConfigurationStorePropertiesUpdateParameters struct { + // Encryption - The encryption settings of the configuration store. + Encryption *EncryptionProperties `json:"encryption,omitempty"` +} + +// ConfigurationStoresCreateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ConfigurationStoresCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ConfigurationStoresCreateFuture) Result(client ConfigurationStoresClient) (cs ConfigurationStore, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appconfiguration.ConfigurationStoresCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if cs.Response.Response, err = future.GetResult(sender); err == nil && cs.Response.Response.StatusCode != http.StatusNoContent { + cs, err = client.CreateResponder(cs.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresCreateFuture", "Result", cs.Response.Response, "Failure responding to request") + } + } + return +} + +// ConfigurationStoresDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ConfigurationStoresDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ConfigurationStoresDeleteFuture) Result(client ConfigurationStoresClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appconfiguration.ConfigurationStoresDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ConfigurationStoresUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type ConfigurationStoresUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ConfigurationStoresUpdateFuture) Result(client ConfigurationStoresClient) (cs ConfigurationStore, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appconfiguration.ConfigurationStoresUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if cs.Response.Response, err = future.GetResult(sender); err == nil && cs.Response.Response.StatusCode != http.StatusNoContent { + cs, err = client.UpdateResponder(cs.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.ConfigurationStoresUpdateFuture", "Result", cs.Response.Response, "Failure responding to request") + } + } + return +} + +// ConfigurationStoreUpdateParameters the parameters for updating a configuration store. +type ConfigurationStoreUpdateParameters struct { + // ConfigurationStorePropertiesUpdateParameters - The properties for updating a configuration store. + *ConfigurationStorePropertiesUpdateParameters `json:"properties,omitempty"` + // Identity - The managed identity information for the configuration store. + Identity *ResourceIdentity `json:"identity,omitempty"` + // Sku - The SKU of the configuration store. + Sku *Sku `json:"sku,omitempty"` + // Tags - The ARM resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ConfigurationStoreUpdateParameters. +func (csup ConfigurationStoreUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if csup.ConfigurationStorePropertiesUpdateParameters != nil { + objectMap["properties"] = csup.ConfigurationStorePropertiesUpdateParameters + } + if csup.Identity != nil { + objectMap["identity"] = csup.Identity + } + if csup.Sku != nil { + objectMap["sku"] = csup.Sku + } + if csup.Tags != nil { + objectMap["tags"] = csup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConfigurationStoreUpdateParameters struct. +func (csup *ConfigurationStoreUpdateParameters) 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 configurationStorePropertiesUpdateParameters ConfigurationStorePropertiesUpdateParameters + err = json.Unmarshal(*v, &configurationStorePropertiesUpdateParameters) + if err != nil { + return err + } + csup.ConfigurationStorePropertiesUpdateParameters = &configurationStorePropertiesUpdateParameters + } + case "identity": + if v != nil { + var identity ResourceIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + csup.Identity = &identity + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + csup.Sku = &sku + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + csup.Tags = tags + } + } + } + + return nil +} + +// EncryptionProperties the encryption settings for a configuration store. +type EncryptionProperties struct { + // KeyVaultProperties - Key vault properties. + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` +} + +// 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"` +} + +// ErrorDetails the details of the error. +type ErrorDetails struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// ErrorResponse error response indicates that the service is not able to process the incoming request. The +// reason is provided in the error message. +type ErrorResponse struct { + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// KeyValue the key-value resource along with all resource properties. +type KeyValue struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource ID. + 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. + Type *string `json:"type,omitempty"` + // KeyValueProperties - All key-value properties. + *KeyValueProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for KeyValue. +func (kv KeyValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if kv.KeyValueProperties != nil { + objectMap["properties"] = kv.KeyValueProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for KeyValue struct. +func (kv *KeyValue) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + kv.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + kv.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + kv.Type = &typeVar + } + case "properties": + if v != nil { + var keyValueProperties KeyValueProperties + err = json.Unmarshal(*v, &keyValueProperties) + if err != nil { + return err + } + kv.KeyValueProperties = &keyValueProperties + } + } + } + + return nil +} + +// KeyValueListResult the result of a request to list key-values. +type KeyValueListResult struct { + autorest.Response `json:"-"` + // Value - The collection value. + Value *[]KeyValue `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` +} + +// KeyValueListResultIterator provides access to a complete listing of KeyValue values. +type KeyValueListResultIterator struct { + i int + page KeyValueListResultPage +} + +// 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 *KeyValueListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyValueListResultIterator.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 *KeyValueListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter KeyValueListResultIterator) 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 KeyValueListResultIterator) Response() KeyValueListResult { + 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 KeyValueListResultIterator) Value() KeyValue { + if !iter.page.NotDone() { + return KeyValue{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the KeyValueListResultIterator type. +func NewKeyValueListResultIterator(page KeyValueListResultPage) KeyValueListResultIterator { + return KeyValueListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (kvlr KeyValueListResult) IsEmpty() bool { + return kvlr.Value == nil || len(*kvlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (kvlr KeyValueListResult) hasNextLink() bool { + return kvlr.NextLink != nil && len(*kvlr.NextLink) != 0 +} + +// keyValueListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (kvlr KeyValueListResult) keyValueListResultPreparer(ctx context.Context) (*http.Request, error) { + if !kvlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(kvlr.NextLink))) +} + +// KeyValueListResultPage contains a page of KeyValue values. +type KeyValueListResultPage struct { + fn func(context.Context, KeyValueListResult) (KeyValueListResult, error) + kvlr KeyValueListResult +} + +// 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 *KeyValueListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyValueListResultPage.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.kvlr) + if err != nil { + return err + } + page.kvlr = 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 *KeyValueListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page KeyValueListResultPage) NotDone() bool { + return !page.kvlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page KeyValueListResultPage) Response() KeyValueListResult { + return page.kvlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page KeyValueListResultPage) Values() []KeyValue { + if page.kvlr.IsEmpty() { + return nil + } + return *page.kvlr.Value +} + +// Creates a new instance of the KeyValueListResultPage type. +func NewKeyValueListResultPage(cur KeyValueListResult, getNextPage func(context.Context, KeyValueListResult) (KeyValueListResult, error)) KeyValueListResultPage { + return KeyValueListResultPage{ + fn: getNextPage, + kvlr: cur, + } +} + +// KeyValueProperties all key-value properties. +type KeyValueProperties struct { + // Key - READ-ONLY; The primary identifier of a key-value. + // The key is used in unison with the label to uniquely identify a key-value. + Key *string `json:"key,omitempty"` + // Label - READ-ONLY; A value used to group key-values. + // The label is used in unison with the key to uniquely identify a key-value. + Label *string `json:"label,omitempty"` + // Value - The value of the key-value. + Value *string `json:"value,omitempty"` + // ContentType - The content type of the key-value's value. + // Providing a proper content-type can enable transformations of values when they are retrieved by applications. + ContentType *string `json:"contentType,omitempty"` + // ETag - READ-ONLY; An ETag indicating the state of a key-value within a configuration store. + ETag *string `json:"eTag,omitempty"` + // LastModified - READ-ONLY; The last time a modifying operation was performed on the given key-value. + LastModified *date.Time `json:"lastModified,omitempty"` + // Locked - READ-ONLY; A value indicating whether the key-value is locked. + // A locked key-value may not be modified until it is unlocked. + Locked *bool `json:"locked,omitempty"` + // Tags - A dictionary of tags that can help identify what a key-value may be applicable for. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for KeyValueProperties. +func (kvp KeyValueProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if kvp.Value != nil { + objectMap["value"] = kvp.Value + } + if kvp.ContentType != nil { + objectMap["contentType"] = kvp.ContentType + } + if kvp.Tags != nil { + objectMap["tags"] = kvp.Tags + } + return json.Marshal(objectMap) +} + +// KeyValuesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type KeyValuesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *KeyValuesDeleteFuture) Result(client KeyValuesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.KeyValuesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appconfiguration.KeyValuesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// KeyVaultProperties settings concerning key vault encryption for a configuration store. +type KeyVaultProperties struct { + // KeyIdentifier - The URI of the key vault key used to encrypt data. + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + // IdentityClientID - The client id of the identity which will be used to access key vault. + IdentityClientID *string `json:"identityClientId,omitempty"` +} + +// LogSpecification specifications of the Log for Azure Monitoring +type LogSpecification struct { + // Name - Name of the log + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the log + DisplayName *string `json:"displayName,omitempty"` + // BlobDuration - Blob duration of the log + BlobDuration *string `json:"blobDuration,omitempty"` +} + +// MetricDimension specifications of the Dimension of metrics +type MetricDimension struct { + // Name - Name of the dimension + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the dimension + DisplayName *string `json:"displayName,omitempty"` + // InternalName - Internal name of the dimension. + InternalName *string `json:"internalName,omitempty"` +} + +// MetricSpecification specifications of the Metrics for Azure Monitoring +type MetricSpecification struct { + // Name - Name of the metric + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the metric + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - Localized friendly description of the metric + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - Unit that makes sense for the metric + Unit *string `json:"unit,omitempty"` + // AggregationType - Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + // InternalMetricName - Internal metric name. + InternalMetricName *string `json:"internalMetricName,omitempty"` + // Dimensions - Dimensions of the metric + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` +} + +// NameAvailabilityStatus the result of a request to check the availability of a resource name. +type NameAvailabilityStatus struct { + autorest.Response `json:"-"` + // NameAvailable - READ-ONLY; The value indicating whether the resource name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Message - READ-ONLY; If any, the error message that provides more detail for the reason that the name is not available. + Message *string `json:"message,omitempty"` + // Reason - READ-ONLY; If any, the reason that the name is not available. + Reason *string `json:"reason,omitempty"` +} + +// OperationDefinition the definition of a configuration store operation. +type OperationDefinition struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - The display information for the configuration store operation. + Display *OperationDefinitionDisplay `json:"display,omitempty"` + // Origin - Origin of the operation + Origin *string `json:"origin,omitempty"` + // Properties - Properties of the operation + Properties *OperationProperties `json:"properties,omitempty"` +} + +// OperationDefinitionDisplay the display information for a configuration store operation. +type OperationDefinitionDisplay struct { + // Provider - READ-ONLY; The resource provider name: Microsoft App Configuration." + Provider *string `json:"provider,omitempty"` + // Resource - The resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - The operation that users can perform. + Operation *string `json:"operation,omitempty"` + // Description - The description for the operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDefinitionDisplay. +func (odd OperationDefinitionDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if odd.Resource != nil { + objectMap["resource"] = odd.Resource + } + if odd.Operation != nil { + objectMap["operation"] = odd.Operation + } + if odd.Description != nil { + objectMap["description"] = odd.Description + } + return json.Marshal(objectMap) +} + +// OperationDefinitionListResult the result of a request to list configuration store operations. +type OperationDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The collection value. + Value *[]OperationDefinition `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationDefinitionListResultIterator provides access to a complete listing of OperationDefinition +// values. +type OperationDefinitionListResultIterator struct { + i int + page OperationDefinitionListResultPage +} + +// 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 *OperationDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationDefinitionListResultIterator.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 *OperationDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationDefinitionListResultIterator) 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 OperationDefinitionListResultIterator) Response() OperationDefinitionListResult { + 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 OperationDefinitionListResultIterator) Value() OperationDefinition { + if !iter.page.NotDone() { + return OperationDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationDefinitionListResultIterator type. +func NewOperationDefinitionListResultIterator(page OperationDefinitionListResultPage) OperationDefinitionListResultIterator { + return OperationDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (odlr OperationDefinitionListResult) IsEmpty() bool { + return odlr.Value == nil || len(*odlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (odlr OperationDefinitionListResult) hasNextLink() bool { + return odlr.NextLink != nil && len(*odlr.NextLink) != 0 +} + +// operationDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (odlr OperationDefinitionListResult) operationDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !odlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(odlr.NextLink))) +} + +// OperationDefinitionListResultPage contains a page of OperationDefinition values. +type OperationDefinitionListResultPage struct { + fn func(context.Context, OperationDefinitionListResult) (OperationDefinitionListResult, error) + odlr OperationDefinitionListResult +} + +// 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 *OperationDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationDefinitionListResultPage.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.odlr) + if err != nil { + return err + } + page.odlr = 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 *OperationDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationDefinitionListResultPage) NotDone() bool { + return !page.odlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationDefinitionListResultPage) Response() OperationDefinitionListResult { + return page.odlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationDefinitionListResultPage) Values() []OperationDefinition { + if page.odlr.IsEmpty() { + return nil + } + return *page.odlr.Value +} + +// Creates a new instance of the OperationDefinitionListResultPage type. +func NewOperationDefinitionListResultPage(cur OperationDefinitionListResult, getNextPage func(context.Context, OperationDefinitionListResult) (OperationDefinitionListResult, error)) OperationDefinitionListResultPage { + return OperationDefinitionListResultPage{ + fn: getNextPage, + odlr: cur, + } +} + +// OperationProperties extra Operation properties +type OperationProperties struct { + // ServiceSpecification - Service specifications of the operation + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// PrivateEndpoint private endpoint which a connection belongs to. +type PrivateEndpoint struct { + // ID - The resource Id for private endpoint + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource ID. + 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. + Type *string `json:"type,omitempty"` + // PrivateEndpointConnectionProperties - The properties of a private endpoint. + *PrivateEndpointConnectionProperties `json:"properties,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 "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 + } + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult a list of private endpoint connections +type PrivateEndpointConnectionListResult struct { + autorest.Response `json:"-"` + // Value - The collection value. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateEndpointConnectionListResultIterator provides access to a complete listing of +// PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultIterator struct { + i int + page PrivateEndpointConnectionListResultPage +} + +// 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 *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.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 *PrivateEndpointConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListResultIterator) 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 PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { + 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 PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. +func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { + return PrivateEndpointConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { + return peclr.Value == nil || len(*peclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { + return peclr.NextLink != nil && len(*peclr.NextLink) != 0 +} + +// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !peclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(peclr.NextLink))) +} + +// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListResultPage struct { + fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) + peclr PrivateEndpointConnectionListResult +} + +// 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 *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.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.peclr) + if err != nil { + return err + } + page.peclr = 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 *PrivateEndpointConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListResultPage) NotDone() bool { + return !page.peclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { + return page.peclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { + if page.peclr.IsEmpty() { + return nil + } + return *page.peclr.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListResultPage type. +func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { + return PrivateEndpointConnectionListResultPage{ + fn: getNextPage, + peclr: cur, + } +} + +// PrivateEndpointConnectionProperties properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // ProvisioningState - READ-ONLY; The provisioning status of the private endpoint connection. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // PrivateEndpoint - The resource of private endpoint. + 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"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionReference a reference to a related private endpoint connection. +type PrivateEndpointConnectionReference struct { + // ID - READ-ONLY; The resource ID. + 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. + Type *string `json:"type,omitempty"` + // PrivateEndpointConnectionProperties - The properties of a private endpoint connection. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionReference. +func (pecr PrivateEndpointConnectionReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecr.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pecr.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnectionReference struct. +func (pecr *PrivateEndpointConnectionReference) 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 "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pecr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pecr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pecr.Type = &typeVar + } + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pecr.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + } + } + + return nil +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) Result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appconfiguration.PrivateEndpointConnectionsCreateOrUpdateFuture") + 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.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateEndpointConnectionsDeleteFuture) Result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("appconfiguration.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkResource a resource that supports private link capabilities. +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource ID. + 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. + Type *string `json:"type,omitempty"` + // PrivateLinkResourceProperties - Private link resource properties. + *PrivateLinkResourceProperties `json:"properties,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 "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 + } + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + } + } + + return nil +} + +// PrivateLinkResourceListResult a list of private link resources. +type PrivateLinkResourceListResult struct { + autorest.Response `json:"-"` + // Value - The collection value. + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateLinkResourceListResultIterator provides access to a complete listing of PrivateLinkResource +// values. +type PrivateLinkResourceListResultIterator struct { + i int + page PrivateLinkResourceListResultPage +} + +// 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 *PrivateLinkResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultIterator.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 *PrivateLinkResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListResultIterator) 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 PrivateLinkResourceListResultIterator) Response() PrivateLinkResourceListResult { + 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 PrivateLinkResourceListResultIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListResultIterator type. +func NewPrivateLinkResourceListResultIterator(page PrivateLinkResourceListResultPage) PrivateLinkResourceListResultIterator { + return PrivateLinkResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrlr PrivateLinkResourceListResult) IsEmpty() bool { + return plrlr.Value == nil || len(*plrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrlr PrivateLinkResourceListResult) hasNextLink() bool { + return plrlr.NextLink != nil && len(*plrlr.NextLink) != 0 +} + +// privateLinkResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrlr PrivateLinkResourceListResult) privateLinkResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !plrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrlr.NextLink))) +} + +// PrivateLinkResourceListResultPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListResultPage struct { + fn func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error) + plrlr PrivateLinkResourceListResult +} + +// 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 *PrivateLinkResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListResultPage.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.plrlr) + if err != nil { + return err + } + page.plrlr = 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 *PrivateLinkResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListResultPage) NotDone() bool { + return !page.plrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListResultPage) Response() PrivateLinkResourceListResult { + return page.plrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListResultPage) Values() []PrivateLinkResource { + if page.plrlr.IsEmpty() { + return nil + } + return *page.plrlr.Value +} + +// Creates a new instance of the PrivateLinkResourceListResultPage type. +func NewPrivateLinkResourceListResultPage(cur PrivateLinkResourceListResult, getNextPage func(context.Context, PrivateLinkResourceListResult) (PrivateLinkResourceListResult, error)) PrivateLinkResourceListResultPage { + return PrivateLinkResourceListResultPage{ + fn: getNextPage, + plrlr: cur, + } +} + +// 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 - READ-ONLY; The list of required DNS zone names of the private link resource. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// PrivateLinkServiceConnectionState the state of a private link service connection. +type PrivateLinkServiceConnectionState struct { + // Status - The private link service connection status. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + Status ConnectionStatus `json:"status,omitempty"` + // Description - The private link service connection description. + Description *string `json:"description,omitempty"` + // ActionsRequired - READ-ONLY; Any action that is required beyond basic workflow (approve/ reject/ disconnect). Possible values include: 'None', 'Recreate' + ActionsRequired ActionsRequired `json:"actionsRequired,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkServiceConnectionState. +func (plscs PrivateLinkServiceConnectionState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plscs.Status != "" { + objectMap["status"] = plscs.Status + } + if plscs.Description != nil { + objectMap["description"] = plscs.Description + } + return json.Marshal(objectMap) +} + +// RegenerateKeyParameters the parameters used to regenerate an API key. +type RegenerateKeyParameters struct { + // ID - The id of the key to regenerate. + ID *string `json:"id,omitempty"` +} + +// Resource an Azure resource. +type Resource struct { + // ID - READ-ONLY; The resource ID. + 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. + Type *string `json:"type,omitempty"` + // Location - The location of the resource. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// ResourceIdentity an identity that can be associated with a resource. +type ResourceIdentity struct { + // Type - The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type 'None' will remove any identities. Possible values include: 'IdentityTypeNone', 'IdentityTypeSystemAssigned', 'IdentityTypeUserAssigned', 'IdentityTypeSystemAssignedUserAssigned' + Type IdentityType `json:"type,omitempty"` + // UserAssignedIdentities - The list of user-assigned identities associated with the resource. The user-assigned identity dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*UserIdentity `json:"userAssignedIdentities"` + // PrincipalID - READ-ONLY; The principal id of the identity. This property will only be provided for a system-assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant id associated with the resource's identity. This property will only be provided for a system-assigned identity. + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceIdentity. +func (ri ResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ri.Type != "" { + objectMap["type"] = ri.Type + } + if ri.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = ri.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ServiceSpecification service specification payload +type ServiceSpecification struct { + // LogSpecifications - Specifications of the Log for Azure Monitoring + LogSpecifications *[]LogSpecification `json:"logSpecifications,omitempty"` + // MetricSpecifications - Specifications of the Metrics for Azure Monitoring + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// Sku describes a configuration store SKU. +type Sku struct { + // Name - The SKU name of the configuration store. + Name *string `json:"name,omitempty"` +} + +// UserIdentity a resource identity that is managed by the user of the service. +type UserIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of the user-assigned identity. + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The client ID of the user-assigned identity. + ClientID *string `json:"clientId,omitempty"` +} diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/operations.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/operations.go new file mode 100644 index 000000000000..a2e5e8ca6c4e --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/operations.go @@ -0,0 +1,238 @@ +package appconfiguration + +// 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" +) + +// OperationsClient is the client for the Operations methods of the Appconfiguration service. +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)} +} + +// CheckNameAvailability checks whether the configuration store name is available for use. +// Parameters: +// checkNameAvailabilityParameters - the object containing information for the availability request. +func (client OperationsClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityParameters CheckNameAvailabilityParameters) (result NameAvailabilityStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: checkNameAvailabilityParameters, + Constraints: []validation.Constraint{{Target: "checkNameAvailabilityParameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "checkNameAvailabilityParameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.OperationsClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, checkNameAvailabilityParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.OperationsClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.OperationsClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.OperationsClient", "CheckNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client OperationsClient) CheckNameAvailabilityPreparer(ctx context.Context, checkNameAvailabilityParameters CheckNameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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}/providers/Microsoft.AppConfiguration/checkNameAvailability", pathParameters), + autorest.WithJSON(checkNameAvailabilityParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client OperationsClient) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailabilityStatus, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the operations available from this provider. +// Parameters: +// skipToken - a skip token is used to continue retrieving items after an operation returns a partial result. +// If a previous response contains a nextLink element, the value of the nextLink element will include a +// skipToken parameter that specifies a starting point to use for subsequent calls. +func (client OperationsClient) List(ctx context.Context, skipToken string) (result OperationDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.odlr.Response.Response != nil { + sc = result.odlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.odlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.odlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.OperationsClient", "List", resp, "Failure responding to request") + } + if result.odlr.hasNextLink() && result.odlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context, skipToken string) (*http.Request, error) { + const APIVersion = "2020-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.AppConfiguration/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 OperationDefinitionListResult, 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 OperationDefinitionListResult) (result OperationDefinitionListResult, err error) { + req, err := lastResults.operationDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "appconfiguration.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, "appconfiguration.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.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, skipToken string) (result OperationDefinitionListResultIterator, 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, skipToken) + return +} diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/privateendpointconnections.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/privateendpointconnections.go new file mode 100644 index 000000000000..1b2b070fa798 --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/privateendpointconnections.go @@ -0,0 +1,433 @@ +package appconfiguration + +// 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 client for the PrivateEndpointConnections methods of the Appconfiguration +// service. +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)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the configuration +// store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// privateEndpointConnectionName - private endpoint connection name +// privateEndpointConnection - the private endpoint connection properties. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}, + {TargetValue: privateEndpointConnection, + Constraints: []validation.Constraint{{Target: "privateEndpointConnection.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "privateEndpointConnection.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("appconfiguration.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, configStoreName, privateEndpointConnectionName, privateEndpointConnection) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + privateEndpointConnection.ID = nil + privateEndpointConnection.Name = nil + privateEndpointConnection.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(privateEndpointConnection), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, 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 +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(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 +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// privateEndpointConnectionName - private endpoint connection name +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, 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) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, configStoreName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/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) (future PrivateEndpointConnectionsDeleteFuture, 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 PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// privateEndpointConnectionName - private endpoint connection name +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, configStoreName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, configStoreName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(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 +} + +// ListByConfigurationStore lists all private endpoint connections for a configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +func (client PrivateEndpointConnectionsClient) ListByConfigurationStore(ctx context.Context, resourceGroupName string, configStoreName string) (result PrivateEndpointConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByConfigurationStore") + defer func() { + sc := -1 + if result.peclr.Response.Response != nil { + sc = result.peclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.PrivateEndpointConnectionsClient", "ListByConfigurationStore", err.Error()) + } + + result.fn = client.listByConfigurationStoreNextResults + req, err := client.ListByConfigurationStorePreparer(ctx, resourceGroupName, configStoreName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "ListByConfigurationStore", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationStoreSender(req) + if err != nil { + result.peclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "ListByConfigurationStore", resp, "Failure sending request") + return + } + + result.peclr, err = client.ListByConfigurationStoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "ListByConfigurationStore", resp, "Failure responding to request") + } + if result.peclr.hasNextLink() && result.peclr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByConfigurationStorePreparer prepares the ListByConfigurationStore request. +func (client PrivateEndpointConnectionsClient) ListByConfigurationStorePreparer(ctx context.Context, resourceGroupName string, configStoreName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationStoreSender sends the ListByConfigurationStore request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByConfigurationStoreSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationStoreResponder handles the response to the ListByConfigurationStore request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByConfigurationStoreResponder(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 +} + +// listByConfigurationStoreNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listByConfigurationStoreNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { + req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "listByConfigurationStoreNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByConfigurationStoreSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "listByConfigurationStoreNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByConfigurationStoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateEndpointConnectionsClient", "listByConfigurationStoreNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByConfigurationStoreComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListByConfigurationStoreComplete(ctx context.Context, resourceGroupName string, configStoreName string) (result PrivateEndpointConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByConfigurationStore") + 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.ListByConfigurationStore(ctx, resourceGroupName, configStoreName) + return +} diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/privatelinkresources.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/privatelinkresources.go new file mode 100644 index 000000000000..9e1fa08a4ef5 --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/privatelinkresources.go @@ -0,0 +1,253 @@ +package appconfiguration + +// 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" +) + +// PrivateLinkResourcesClient is the client for the PrivateLinkResources methods of the Appconfiguration service. +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)} +} + +// Get gets a private link resource that need to be created for a configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, configStoreName string, groupName string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, configStoreName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, configStoreName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByConfigurationStore gets the private link resources that need to be created for a configuration store. +// Parameters: +// resourceGroupName - the name of the resource group to which the container registry belongs. +// configStoreName - the name of the configuration store. +func (client PrivateLinkResourcesClient) ListByConfigurationStore(ctx context.Context, resourceGroupName string, configStoreName string) (result PrivateLinkResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByConfigurationStore") + defer func() { + sc := -1 + if result.plrlr.Response.Response != nil { + sc = result.plrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: configStoreName, + Constraints: []validation.Constraint{{Target: "configStoreName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "configStoreName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "configStoreName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("appconfiguration.PrivateLinkResourcesClient", "ListByConfigurationStore", err.Error()) + } + + result.fn = client.listByConfigurationStoreNextResults + req, err := client.ListByConfigurationStorePreparer(ctx, resourceGroupName, configStoreName) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "ListByConfigurationStore", nil, "Failure preparing request") + return + } + + resp, err := client.ListByConfigurationStoreSender(req) + if err != nil { + result.plrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "ListByConfigurationStore", resp, "Failure sending request") + return + } + + result.plrlr, err = client.ListByConfigurationStoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "ListByConfigurationStore", resp, "Failure responding to request") + } + if result.plrlr.hasNextLink() && result.plrlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByConfigurationStorePreparer prepares the ListByConfigurationStore request. +func (client PrivateLinkResourcesClient) ListByConfigurationStorePreparer(ctx context.Context, resourceGroupName string, configStoreName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configStoreName": autorest.Encode("path", configStoreName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-07-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.AppConfiguration/configurationStores/{configStoreName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByConfigurationStoreSender sends the ListByConfigurationStore request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByConfigurationStoreSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByConfigurationStoreResponder handles the response to the ListByConfigurationStore request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByConfigurationStoreResponder(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 +} + +// listByConfigurationStoreNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listByConfigurationStoreNextResults(ctx context.Context, lastResults PrivateLinkResourceListResult) (result PrivateLinkResourceListResult, err error) { + req, err := lastResults.privateLinkResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "listByConfigurationStoreNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByConfigurationStoreSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "listByConfigurationStoreNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByConfigurationStoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "appconfiguration.PrivateLinkResourcesClient", "listByConfigurationStoreNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByConfigurationStoreComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListByConfigurationStoreComplete(ctx context.Context, resourceGroupName string, configStoreName string) (result PrivateLinkResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByConfigurationStore") + 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.ListByConfigurationStore(ctx, resourceGroupName, configStoreName) + return +} diff --git a/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/version.go b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/version.go new file mode 100644 index 000000000000..0a799e61f5a1 --- /dev/null +++ b/services/preview/appconfiguration/mgmt/2020-07-01-preview/appconfiguration/version.go @@ -0,0 +1,30 @@ +package appconfiguration + +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() + " appconfiguration/2020-07-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}