From d4d4094b6249508fc43abfaab9339418230a2909 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 30 Apr 2019 11:38:25 -0700 Subject: [PATCH] [AutoPR customproviders/resource-manager] Add Swagger and Examples for custom resource provider to Azure (#4707) * Generated from 6978e76e3cd1985d6084841a96875aa45b9bc1b1 Add Swagger and Examples for custom resource provider to Azure * Generated from aa7e89837bf343bcfd3766558a6f54fad5b66f66 Apply suggestions from code review Fix typos in strings for RP. Co-Authored-By: jjbfour --- .../customprovidersapi/models.go | 25 + .../mgmt/customproviders/models.go | 132 ++++ .../customproviders/client.go | 51 ++ .../customprovidersapi/interfaces.go | 42 ++ .../customproviders/customresourceprovider.go | 607 ++++++++++++++++ .../customproviders/models.go | 667 ++++++++++++++++++ .../customproviders/operations.go | 147 ++++ .../customproviders/version.go | 30 + 8 files changed, 1701 insertions(+) create mode 100644 profiles/preview/preview/customproviders/mgmt/customproviders/customprovidersapi/models.go create mode 100644 profiles/preview/preview/customproviders/mgmt/customproviders/models.go create mode 100644 services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/client.go create mode 100644 services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customprovidersapi/interfaces.go create mode 100644 services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customresourceprovider.go create mode 100644 services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/models.go create mode 100644 services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/operations.go create mode 100644 services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/version.go diff --git a/profiles/preview/preview/customproviders/mgmt/customproviders/customprovidersapi/models.go b/profiles/preview/preview/customproviders/mgmt/customproviders/customprovidersapi/models.go new file mode 100644 index 000000000000..c90ddd7aac4a --- /dev/null +++ b/profiles/preview/preview/customproviders/mgmt/customproviders/customprovidersapi/models.go @@ -0,0 +1,25 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package customprovidersapi + +import original "github.com/Azure/azure-sdk-for-go/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customprovidersapi" + +type CustomResourceProviderClientAPI = original.CustomResourceProviderClientAPI +type OperationsClientAPI = original.OperationsClientAPI diff --git a/profiles/preview/preview/customproviders/mgmt/customproviders/models.go b/profiles/preview/preview/customproviders/mgmt/customproviders/models.go new file mode 100644 index 000000000000..5c31a7c5a6ee --- /dev/null +++ b/profiles/preview/preview/customproviders/mgmt/customproviders/models.go @@ -0,0 +1,132 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package customproviders + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type ActionRouting = original.ActionRouting + +const ( + Proxy ActionRouting = original.Proxy +) + +type ProvisioningState = original.ProvisioningState + +const ( + Accepted ProvisioningState = original.Accepted + Deleting ProvisioningState = original.Deleting + Failed ProvisioningState = original.Failed + Running ProvisioningState = original.Running + Succeeded ProvisioningState = original.Succeeded +) + +type ResourceTypeRouting = original.ResourceTypeRouting + +const ( + ResourceTypeRoutingProxy ResourceTypeRouting = original.ResourceTypeRoutingProxy + ResourceTypeRoutingProxyCache ResourceTypeRouting = original.ResourceTypeRoutingProxyCache +) + +type ValidationType = original.ValidationType + +const ( + Swagger ValidationType = original.Swagger +) + +type BaseClient = original.BaseClient +type CustomRPActionRouteDefinition = original.CustomRPActionRouteDefinition +type CustomRPManifest = original.CustomRPManifest +type CustomRPManifestProperties = original.CustomRPManifestProperties +type CustomRPResourceTypeRouteDefinition = original.CustomRPResourceTypeRouteDefinition +type CustomRPRouteDefinition = original.CustomRPRouteDefinition +type CustomRPValidations = original.CustomRPValidations +type CustomResourceProviderClient = original.CustomResourceProviderClient +type CustomResourceProviderCreateOrUpdateFuture = original.CustomResourceProviderCreateOrUpdateFuture +type CustomResourceProviderDeleteFuture = original.CustomResourceProviderDeleteFuture +type ErrorDefinition = original.ErrorDefinition +type ErrorResponse = original.ErrorResponse +type ListByCustomRPManifest = original.ListByCustomRPManifest +type ListByCustomRPManifestIterator = original.ListByCustomRPManifestIterator +type ListByCustomRPManifestPage = original.ListByCustomRPManifestPage +type OperationsClient = original.OperationsClient +type Resource = original.Resource +type ResourceProviderOperation = original.ResourceProviderOperation +type ResourceProviderOperationDisplay = original.ResourceProviderOperationDisplay +type ResourceProviderOperationList = original.ResourceProviderOperationList +type ResourceProviderOperationListIterator = original.ResourceProviderOperationListIterator +type ResourceProviderOperationListPage = original.ResourceProviderOperationListPage +type ResourceProvidersUpdate = original.ResourceProvidersUpdate + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewCustomResourceProviderClient(subscriptionID string) CustomResourceProviderClient { + return original.NewCustomResourceProviderClient(subscriptionID) +} +func NewCustomResourceProviderClientWithBaseURI(baseURI string, subscriptionID string) CustomResourceProviderClient { + return original.NewCustomResourceProviderClientWithBaseURI(baseURI, subscriptionID) +} +func NewListByCustomRPManifestIterator(page ListByCustomRPManifestPage) ListByCustomRPManifestIterator { + return original.NewListByCustomRPManifestIterator(page) +} +func NewListByCustomRPManifestPage(getNextPage func(context.Context, ListByCustomRPManifest) (ListByCustomRPManifest, error)) ListByCustomRPManifestPage { + return original.NewListByCustomRPManifestPage(getNextPage) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceProviderOperationListIterator(page ResourceProviderOperationListPage) ResourceProviderOperationListIterator { + return original.NewResourceProviderOperationListIterator(page) +} +func NewResourceProviderOperationListPage(getNextPage func(context.Context, ResourceProviderOperationList) (ResourceProviderOperationList, error)) ResourceProviderOperationListPage { + return original.NewResourceProviderOperationListPage(getNextPage) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleActionRoutingValues() []ActionRouting { + return original.PossibleActionRoutingValues() +} +func PossibleProvisioningStateValues() []ProvisioningState { + return original.PossibleProvisioningStateValues() +} +func PossibleResourceTypeRoutingValues() []ResourceTypeRouting { + return original.PossibleResourceTypeRoutingValues() +} +func PossibleValidationTypeValues() []ValidationType { + return original.PossibleValidationTypeValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/client.go b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/client.go new file mode 100644 index 000000000000..f4b2f603ed9c --- /dev/null +++ b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/client.go @@ -0,0 +1,51 @@ +// Package customproviders implements the Azure ARM Customproviders service API version 2018-09-01-preview. +// +// Allows extension of ARM control plane with custom resource providers. +package customproviders + +// 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 Customproviders + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Customproviders. +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. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customprovidersapi/interfaces.go b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customprovidersapi/interfaces.go new file mode 100644 index 000000000000..4db5bafb89de --- /dev/null +++ b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customprovidersapi/interfaces.go @@ -0,0 +1,42 @@ +package customprovidersapi + +// 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/customproviders/mgmt/2018-09-01-preview/customproviders" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result customproviders.ResourceProviderOperationListPage, err error) +} + +var _ OperationsClientAPI = (*customproviders.OperationsClient)(nil) + +// CustomResourceProviderClientAPI contains the set of methods on the CustomResourceProviderClient type. +type CustomResourceProviderClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderName string, resourceProvider customproviders.CustomRPManifest) (result customproviders.CustomResourceProviderCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceProviderName string) (result customproviders.CustomResourceProviderDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceProviderName string) (result customproviders.CustomRPManifest, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result customproviders.ListByCustomRPManifestPage, err error) + ListBySubscription(ctx context.Context) (result customproviders.ListByCustomRPManifestPage, err error) + Update(ctx context.Context, resourceGroupName string, resourceProviderName string, patchableResource customproviders.ResourceProvidersUpdate) (result customproviders.CustomRPManifest, err error) +} + +var _ CustomResourceProviderClientAPI = (*customproviders.CustomResourceProviderClient)(nil) diff --git a/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customresourceprovider.go b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customresourceprovider.go new file mode 100644 index 000000000000..88375574057b --- /dev/null +++ b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/customresourceprovider.go @@ -0,0 +1,607 @@ +package customproviders + +// 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" +) + +// CustomResourceProviderClient is the allows extension of ARM control plane with custom resource providers. +type CustomResourceProviderClient struct { + BaseClient +} + +// NewCustomResourceProviderClient creates an instance of the CustomResourceProviderClient client. +func NewCustomResourceProviderClient(subscriptionID string) CustomResourceProviderClient { + return NewCustomResourceProviderClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCustomResourceProviderClientWithBaseURI creates an instance of the CustomResourceProviderClient client. +func NewCustomResourceProviderClientWithBaseURI(baseURI string, subscriptionID string) CustomResourceProviderClient { + return CustomResourceProviderClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the custom resource provider. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceProviderName - the name of the resource provider. +// resourceProvider - the parameters required to create or update a custom resource provider definition. +func (client CustomResourceProviderClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderName string, resourceProvider CustomRPManifest) (result CustomResourceProviderCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.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: resourceProviderName, + Constraints: []validation.Constraint{{Target: "resourceProviderName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceProviderName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("customproviders.CustomResourceProviderClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceProviderName, resourceProvider) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CustomResourceProviderClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderName string, resourceProvider CustomRPManifest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceProviderName": autorest.Encode("path", resourceProviderName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-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.CustomProviders/resourceProviders/{resourceProviderName}", pathParameters), + autorest.WithJSON(resourceProvider), + 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 CustomResourceProviderClient) CreateOrUpdateSender(req *http.Request) (future CustomResourceProviderCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, 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 CustomResourceProviderClient) CreateOrUpdateResponder(resp *http.Response) (result CustomRPManifest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the custom resource provider. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceProviderName - the name of the resource provider. +func (client CustomResourceProviderClient) Delete(ctx context.Context, resourceGroupName string, resourceProviderName string) (result CustomResourceProviderDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.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: resourceProviderName, + Constraints: []validation.Constraint{{Target: "resourceProviderName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceProviderName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("customproviders.CustomResourceProviderClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceProviderName) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CustomResourceProviderClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceProviderName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceProviderName": autorest.Encode("path", resourceProviderName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", 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 CustomResourceProviderClient) DeleteSender(req *http.Request) (future CustomResourceProviderDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, 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 CustomResourceProviderClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the custom resource provider manifest. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceProviderName - the name of the resource provider. +func (client CustomResourceProviderClient) Get(ctx context.Context, resourceGroupName string, resourceProviderName string) (result CustomRPManifest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.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: resourceProviderName, + Constraints: []validation.Constraint{{Target: "resourceProviderName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceProviderName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("customproviders.CustomResourceProviderClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceProviderName) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CustomResourceProviderClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceProviderName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceProviderName": autorest.Encode("path", resourceProviderName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}", 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 CustomResourceProviderClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CustomResourceProviderClient) GetResponder(resp *http.Response) (result CustomRPManifest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets all the custom resource providers within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client CustomResourceProviderClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListByCustomRPManifestPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.lbcrm.Response.Response != nil { + sc = result.lbcrm.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.lbcrm.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.lbcrm, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client CustomResourceProviderClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders", 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 CustomResourceProviderClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client CustomResourceProviderClient) ListByResourceGroupResponder(resp *http.Response) (result ListByCustomRPManifest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 CustomResourceProviderClient) listByResourceGroupNextResults(ctx context.Context, lastResults ListByCustomRPManifest) (result ListByCustomRPManifest, err error) { + req, err := lastResults.listByCustomRPManifestPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "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, "customproviders.CustomResourceProviderClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client CustomResourceProviderClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListByCustomRPManifestIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription gets all the custom resource providers within a subscription. +func (client CustomResourceProviderClient) ListBySubscription(ctx context.Context) (result ListByCustomRPManifestPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.ListBySubscription") + defer func() { + sc := -1 + if result.lbcrm.Response.Response != nil { + sc = result.lbcrm.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.lbcrm.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.lbcrm, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client CustomResourceProviderClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client CustomResourceProviderClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client CustomResourceProviderClient) ListBySubscriptionResponder(resp *http.Response) (result ListByCustomRPManifest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client CustomResourceProviderClient) listBySubscriptionNextResults(ctx context.Context, lastResults ListByCustomRPManifest) (result ListByCustomRPManifest, err error) { + req, err := lastResults.listByCustomRPManifestPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client CustomResourceProviderClient) ListBySubscriptionComplete(ctx context.Context) (result ListByCustomRPManifestIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.ListBySubscription") + 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.ListBySubscription(ctx) + return +} + +// Update updates an existing custom resource provider. The only value that can be updated via PATCH currently is the +// tags. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceProviderName - the name of the resource provider. +// patchableResource - the updatable fields of a custom resource provider. +func (client CustomResourceProviderClient) Update(ctx context.Context, resourceGroupName string, resourceProviderName string, patchableResource ResourceProvidersUpdate) (result CustomRPManifest, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomResourceProviderClient.Update") + 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: resourceProviderName, + Constraints: []validation.Constraint{{Target: "resourceProviderName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceProviderName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("customproviders.CustomResourceProviderClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceProviderName, patchableResource) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CustomResourceProviderClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderName string, patchableResource ResourceProvidersUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceProviderName": autorest.Encode("path", resourceProviderName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-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.CustomProviders/resourceProviders/{resourceProviderName}", pathParameters), + autorest.WithJSON(patchableResource), + 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 CustomResourceProviderClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CustomResourceProviderClient) UpdateResponder(resp *http.Response) (result CustomRPManifest, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/models.go b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/models.go new file mode 100644 index 000000000000..c3a3f664265c --- /dev/null +++ b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/models.go @@ -0,0 +1,667 @@ +package customproviders + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders" + +// ActionRouting enumerates the values for action routing. +type ActionRouting string + +const ( + // Proxy ... + Proxy ActionRouting = "Proxy" +) + +// PossibleActionRoutingValues returns an array of possible values for the ActionRouting const type. +func PossibleActionRoutingValues() []ActionRouting { + return []ActionRouting{Proxy} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Accepted ... + Accepted ProvisioningState = "Accepted" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Running ... + Running ProvisioningState = "Running" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Accepted, Deleting, Failed, Running, Succeeded} +} + +// ResourceTypeRouting enumerates the values for resource type routing. +type ResourceTypeRouting string + +const ( + // ResourceTypeRoutingProxy ... + ResourceTypeRoutingProxy ResourceTypeRouting = "Proxy" + // ResourceTypeRoutingProxyCache ... + ResourceTypeRoutingProxyCache ResourceTypeRouting = "Proxy,Cache" +) + +// PossibleResourceTypeRoutingValues returns an array of possible values for the ResourceTypeRouting const type. +func PossibleResourceTypeRoutingValues() []ResourceTypeRouting { + return []ResourceTypeRouting{ResourceTypeRoutingProxy, ResourceTypeRoutingProxyCache} +} + +// ValidationType enumerates the values for validation type. +type ValidationType string + +const ( + // Swagger ... + Swagger ValidationType = "Swagger" +) + +// PossibleValidationTypeValues returns an array of possible values for the ValidationType const type. +func PossibleValidationTypeValues() []ValidationType { + return []ValidationType{Swagger} +} + +// CustomResourceProviderCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CustomResourceProviderCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CustomResourceProviderCreateOrUpdateFuture) Result(client CustomResourceProviderClient) (crm CustomRPManifest, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("customproviders.CustomResourceProviderCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if crm.Response.Response, err = future.GetResult(sender); err == nil && crm.Response.Response.StatusCode != http.StatusNoContent { + crm, err = client.CreateOrUpdateResponder(crm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderCreateOrUpdateFuture", "Result", crm.Response.Response, "Failure responding to request") + } + } + return +} + +// CustomResourceProviderDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type CustomResourceProviderDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CustomResourceProviderDeleteFuture) Result(client CustomResourceProviderClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.CustomResourceProviderDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("customproviders.CustomResourceProviderDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// CustomRPActionRouteDefinition the route definition for an action implemented by the custom resource +// provider. +type CustomRPActionRouteDefinition struct { + // RoutingType - The routing types that are supported for action requests. Possible values include: 'Proxy' + RoutingType ActionRouting `json:"routingType,omitempty"` + // Name - The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + Name *string `json:"name,omitempty"` + // Endpoint - The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') + Endpoint *string `json:"endpoint,omitempty"` +} + +// CustomRPManifest a manifest file that defines the custom resource provider resources. +type CustomRPManifest struct { + autorest.Response `json:"-"` + // CustomRPManifestProperties - The manifest for the custom resource provider + *CustomRPManifestProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for CustomRPManifest. +func (crm CustomRPManifest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if crm.CustomRPManifestProperties != nil { + objectMap["properties"] = crm.CustomRPManifestProperties + } + if crm.Location != nil { + objectMap["location"] = crm.Location + } + if crm.Tags != nil { + objectMap["tags"] = crm.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CustomRPManifest struct. +func (crm *CustomRPManifest) 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 customRPManifestProperties CustomRPManifestProperties + err = json.Unmarshal(*v, &customRPManifestProperties) + if err != nil { + return err + } + crm.CustomRPManifestProperties = &customRPManifestProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + crm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + crm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + crm.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + crm.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + crm.Tags = tags + } + } + } + + return nil +} + +// CustomRPManifestProperties the manifest for the custom resource provider +type CustomRPManifestProperties struct { + // Actions - A list of actions that the custom resource provider implements. + Actions *[]CustomRPActionRouteDefinition `json:"actions,omitempty"` + // ResourceTypes - A list of resource types that the custom resource provider implements. + ResourceTypes *[]CustomRPResourceTypeRouteDefinition `json:"resourceTypes,omitempty"` + // Validations - A list of validations to run on the custom resource provider's requests. + Validations *[]CustomRPValidations `json:"validations,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state of the resource provider. Possible values include: 'Accepted', 'Deleting', 'Running', 'Succeeded', 'Failed' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// CustomRPResourceTypeRouteDefinition the route definition for a resource implemented by the custom +// resource provider. +type CustomRPResourceTypeRouteDefinition struct { + // RoutingType - The routing types that are supported for resource requests. Possible values include: 'ResourceTypeRoutingProxy', 'ResourceTypeRoutingProxyCache' + RoutingType ResourceTypeRouting `json:"routingType,omitempty"` + // Name - The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + Name *string `json:"name,omitempty"` + // Endpoint - The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') + Endpoint *string `json:"endpoint,omitempty"` +} + +// CustomRPRouteDefinition a route definition that defines an action or resource that can be interacted +// with through the custom resource provider. +type CustomRPRouteDefinition struct { + // Name - The name of the route definition. This becomes the name for the ARM extension (e.g. '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + Name *string `json:"name,omitempty"` + // Endpoint - The route definition endpoint URI that the custom resource provider will proxy requests to. This can be in the form of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a path (e.g. 'https://testendpoint/{requestPath}') + Endpoint *string `json:"endpoint,omitempty"` +} + +// CustomRPValidations a validation to apply on custom resource provider requests. +type CustomRPValidations struct { + // ValidationType - The type of validation to run against a matching request. Possible values include: 'Swagger' + ValidationType ValidationType `json:"validationType,omitempty"` + // Specification - A link to the validation specification. The specification must be hosted on raw.githubusercontent.com. + Specification *string `json:"specification,omitempty"` +} + +// ErrorDefinition error definition. +type ErrorDefinition struct { + // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Description of the error. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; Internal error details. + Details *[]ErrorDefinition `json:"details,omitempty"` +} + +// ErrorResponse error response. +type ErrorResponse struct { + // Error - The error details. + Error *ErrorDefinition `json:"error,omitempty"` +} + +// ListByCustomRPManifest list of custom resource providers. +type ListByCustomRPManifest struct { + autorest.Response `json:"-"` + // Value - The array of custom resource provider manifests. + Value *[]CustomRPManifest `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListByCustomRPManifestIterator provides access to a complete listing of CustomRPManifest values. +type ListByCustomRPManifestIterator struct { + i int + page ListByCustomRPManifestPage +} + +// 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 *ListByCustomRPManifestIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListByCustomRPManifestIterator.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 *ListByCustomRPManifestIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListByCustomRPManifestIterator) 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 ListByCustomRPManifestIterator) Response() ListByCustomRPManifest { + 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 ListByCustomRPManifestIterator) Value() CustomRPManifest { + if !iter.page.NotDone() { + return CustomRPManifest{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ListByCustomRPManifestIterator type. +func NewListByCustomRPManifestIterator(page ListByCustomRPManifestPage) ListByCustomRPManifestIterator { + return ListByCustomRPManifestIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lbcrm ListByCustomRPManifest) IsEmpty() bool { + return lbcrm.Value == nil || len(*lbcrm.Value) == 0 +} + +// listByCustomRPManifestPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lbcrm ListByCustomRPManifest) listByCustomRPManifestPreparer(ctx context.Context) (*http.Request, error) { + if lbcrm.NextLink == nil || len(to.String(lbcrm.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lbcrm.NextLink))) +} + +// ListByCustomRPManifestPage contains a page of CustomRPManifest values. +type ListByCustomRPManifestPage struct { + fn func(context.Context, ListByCustomRPManifest) (ListByCustomRPManifest, error) + lbcrm ListByCustomRPManifest +} + +// 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 *ListByCustomRPManifestPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListByCustomRPManifestPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.lbcrm) + if err != nil { + return err + } + page.lbcrm = next + 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 *ListByCustomRPManifestPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListByCustomRPManifestPage) NotDone() bool { + return !page.lbcrm.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListByCustomRPManifestPage) Response() ListByCustomRPManifest { + return page.lbcrm +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ListByCustomRPManifestPage) Values() []CustomRPManifest { + if page.lbcrm.IsEmpty() { + return nil + } + return *page.lbcrm.Value +} + +// Creates a new instance of the ListByCustomRPManifestPage type. +func NewListByCustomRPManifestPage(getNextPage func(context.Context, ListByCustomRPManifest) (ListByCustomRPManifest, error)) ListByCustomRPManifestPage { + return ListByCustomRPManifestPage{fn: getNextPage} +} + +// Resource the resource definition. +type Resource struct { + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - Resource tags + 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) +} + +// ResourceProviderOperation supported operations of this resource provider. +type ResourceProviderOperation struct { + // Name - Operation name, in format of {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - Display metadata associated with the operation. + Display *ResourceProviderOperationDisplay `json:"display,omitempty"` +} + +// ResourceProviderOperationDisplay display metadata associated with the operation. +type ResourceProviderOperationDisplay struct { + // Provider - Resource provider: Microsoft Custom Providers. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - Type of operation: get, read, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Description of this operation. + Description *string `json:"description,omitempty"` +} + +// ResourceProviderOperationList results of the request to list operations. +type ResourceProviderOperationList struct { + autorest.Response `json:"-"` + // Value - List of operations supported by this resource provider. + Value *[]ResourceProviderOperation `json:"value,omitempty"` + // NextLink - The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceProviderOperationListIterator provides access to a complete listing of ResourceProviderOperation +// values. +type ResourceProviderOperationListIterator struct { + i int + page ResourceProviderOperationListPage +} + +// 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 *ResourceProviderOperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceProviderOperationListIterator.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 *ResourceProviderOperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceProviderOperationListIterator) 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 ResourceProviderOperationListIterator) Response() ResourceProviderOperationList { + 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 ResourceProviderOperationListIterator) Value() ResourceProviderOperation { + if !iter.page.NotDone() { + return ResourceProviderOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceProviderOperationListIterator type. +func NewResourceProviderOperationListIterator(page ResourceProviderOperationListPage) ResourceProviderOperationListIterator { + return ResourceProviderOperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rpol ResourceProviderOperationList) IsEmpty() bool { + return rpol.Value == nil || len(*rpol.Value) == 0 +} + +// resourceProviderOperationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rpol ResourceProviderOperationList) resourceProviderOperationListPreparer(ctx context.Context) (*http.Request, error) { + if rpol.NextLink == nil || len(to.String(rpol.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rpol.NextLink))) +} + +// ResourceProviderOperationListPage contains a page of ResourceProviderOperation values. +type ResourceProviderOperationListPage struct { + fn func(context.Context, ResourceProviderOperationList) (ResourceProviderOperationList, error) + rpol ResourceProviderOperationList +} + +// 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 *ResourceProviderOperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceProviderOperationListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rpol) + if err != nil { + return err + } + page.rpol = next + 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 *ResourceProviderOperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceProviderOperationListPage) NotDone() bool { + return !page.rpol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceProviderOperationListPage) Response() ResourceProviderOperationList { + return page.rpol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceProviderOperationListPage) Values() []ResourceProviderOperation { + if page.rpol.IsEmpty() { + return nil + } + return *page.rpol.Value +} + +// Creates a new instance of the ResourceProviderOperationListPage type. +func NewResourceProviderOperationListPage(getNextPage func(context.Context, ResourceProviderOperationList) (ResourceProviderOperationList, error)) ResourceProviderOperationListPage { + return ResourceProviderOperationListPage{fn: getNextPage} +} + +// ResourceProvidersUpdate custom resource provider update information. +type ResourceProvidersUpdate struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ResourceProvidersUpdate. +func (rpu ResourceProvidersUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rpu.Tags != nil { + objectMap["tags"] = rpu.Tags + } + return json.Marshal(objectMap) +} diff --git a/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/operations.go b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/operations.go new file mode 100644 index 000000000000..114bebad92cb --- /dev/null +++ b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/operations.go @@ -0,0 +1,147 @@ +package customproviders + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the allows extension of ARM control plane with custom resource providers. +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. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List the list of operations provided by Microsoft CustomProviders. +func (client OperationsClient) List(ctx context.Context) (result ResourceProviderOperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.rpol.Response.Response != nil { + sc = result.rpol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rpol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customproviders.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.rpol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.CustomProviders/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 autorest.SendWithSender(client, 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 ResourceProviderOperationList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + 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 ResourceProviderOperationList) (result ResourceProviderOperationList, err error) { + req, err := lastResults.resourceProviderOperationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "customproviders.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, "customproviders.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customproviders.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result ResourceProviderOperationListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/version.go b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/version.go new file mode 100644 index 000000000000..f979d7f225c8 --- /dev/null +++ b/services/preview/customproviders/mgmt/2018-09-01-preview/customproviders/version.go @@ -0,0 +1,30 @@ +package customproviders + +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.Number + " customproviders/2018-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}