From 21259d39c37cff9b16b67d7ee4dc15f0211402fa Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 29 Aug 2019 23:22:52 -0700 Subject: [PATCH] [AutoPR storagecache/resource-manager] Dev storagecache microsoft.storagecache 2019 06 01 preview (#5623) * Generated from 570b6f73542c34f1eb0ab0a85e44b4d929ff55b6 Fix output folder path for GO SDK and fix typo in Tag * Generated from 908e3cd2e18a38be0711e03035c7acdc7ab6d1f2 Fix version in the path of output folder for GO SDK --- .../storagecache/mgmt/storagecache/models.go | 217 +++ .../storagecache/storagecacheapi/models.go | 28 + .../mgmt/2017-08-15/storagecache/caches.go | 951 +++++++++++ .../mgmt/2017-08-15/storagecache/client.go | 52 + .../mgmt/2017-08-15/storagecache/models.go | 1480 +++++++++++++++++ .../2017-08-15/storagecache/operations.go | 148 ++ .../mgmt/2017-08-15/storagecache/skus.go | 152 ++ .../storagecacheapi/interfaces.go | 71 + .../2017-08-15/storagecache/storagetargets.go | 543 ++++++ .../2017-08-15/storagecache/usagemodels.go | 152 ++ .../mgmt/2017-08-15/storagecache/version.go | 30 + .../mgmt/2019-08/storagecache/caches.go | 951 +++++++++++ .../mgmt/2019-08/storagecache/client.go | 52 + .../mgmt/2019-08/storagecache/models.go | 1480 +++++++++++++++++ .../mgmt/2019-08/storagecache/operations.go | 148 ++ .../mgmt/2019-08/storagecache/skus.go | 152 ++ .../storagecacheapi/interfaces.go | 71 + .../2019-08/storagecache/storagetargets.go | 543 ++++++ .../mgmt/2019-08/storagecache/usagemodels.go | 152 ++ .../mgmt/2019-08/storagecache/version.go | 30 + 20 files changed, 7403 insertions(+) create mode 100644 profiles/preview/preview/storagecache/mgmt/storagecache/models.go create mode 100644 profiles/preview/preview/storagecache/mgmt/storagecache/storagecacheapi/models.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/caches.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/client.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/models.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/operations.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/skus.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/storagecacheapi/interfaces.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/storagetargets.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/usagemodels.go create mode 100644 services/preview/storagecache/mgmt/2017-08-15/storagecache/version.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/caches.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/client.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/models.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/operations.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/skus.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/storagecacheapi/interfaces.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/storagetargets.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/usagemodels.go create mode 100644 services/preview/storagecache/mgmt/2019-08/storagecache/version.go diff --git a/profiles/preview/preview/storagecache/mgmt/storagecache/models.go b/profiles/preview/preview/storagecache/mgmt/storagecache/models.go new file mode 100644 index 000000000000..8a629f2f3c02 --- /dev/null +++ b/profiles/preview/preview/storagecache/mgmt/storagecache/models.go @@ -0,0 +1,217 @@ +// +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 storagecache + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/preview/storagecache/mgmt/2019-08/storagecache" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type FirmwareStatusType = original.FirmwareStatusType + +const ( + Available FirmwareStatusType = original.Available + Unavailable FirmwareStatusType = original.Unavailable +) + +type HealthStateType = original.HealthStateType + +const ( + Degraded HealthStateType = original.Degraded + Down HealthStateType = original.Down + Flushing HealthStateType = original.Flushing + Healthy HealthStateType = original.Healthy + Stopped HealthStateType = original.Stopped + Stopping HealthStateType = original.Stopping + Transitioning HealthStateType = original.Transitioning + Unknown HealthStateType = original.Unknown + Upgrading HealthStateType = original.Upgrading +) + +type ProvisioningStateType = original.ProvisioningStateType + +const ( + Cancelled ProvisioningStateType = original.Cancelled + Creating ProvisioningStateType = original.Creating + Deleting ProvisioningStateType = original.Deleting + Failed ProvisioningStateType = original.Failed + Succeeded ProvisioningStateType = original.Succeeded + Updating ProvisioningStateType = original.Updating +) + +type ReasonCode = original.ReasonCode + +const ( + NotAvailableForSubscription ReasonCode = original.NotAvailableForSubscription + QuotaID ReasonCode = original.QuotaID +) + +type StorageTargetType = original.StorageTargetType + +const ( + StorageTargetTypeClfs StorageTargetType = original.StorageTargetTypeClfs + StorageTargetTypeNfs3 StorageTargetType = original.StorageTargetTypeNfs3 + StorageTargetTypeUnknown StorageTargetType = original.StorageTargetTypeUnknown +) + +type APIOperation = original.APIOperation +type APIOperationDisplay = original.APIOperationDisplay +type APIOperationListResult = original.APIOperationListResult +type APIOperationListResultIterator = original.APIOperationListResultIterator +type APIOperationListResultPage = original.APIOperationListResultPage +type BaseClient = original.BaseClient +type Cache = original.Cache +type CacheHealth = original.CacheHealth +type CacheProperties = original.CacheProperties +type CacheSku = original.CacheSku +type CacheUpgradeStatus = original.CacheUpgradeStatus +type CachesClient = original.CachesClient +type CachesCreateFuture = original.CachesCreateFuture +type CachesDeleteFuture = original.CachesDeleteFuture +type CachesFlushFuture = original.CachesFlushFuture +type CachesListResult = original.CachesListResult +type CachesListResultIterator = original.CachesListResultIterator +type CachesListResultPage = original.CachesListResultPage +type CachesStartFuture = original.CachesStartFuture +type CachesStopFuture = original.CachesStopFuture +type CachesUpgradeFirmwareFuture = original.CachesUpgradeFirmwareFuture +type ClfsTarget = original.ClfsTarget +type CloudError = original.CloudError +type CloudErrorBody = original.CloudErrorBody +type NamespaceJunction = original.NamespaceJunction +type Nfs3Target = original.Nfs3Target +type OperationsClient = original.OperationsClient +type ResourceSku = original.ResourceSku +type ResourceSkuCapabilities = original.ResourceSkuCapabilities +type ResourceSkuLocationInfo = original.ResourceSkuLocationInfo +type ResourceSkusResult = original.ResourceSkusResult +type ResourceSkusResultIterator = original.ResourceSkusResultIterator +type ResourceSkusResultPage = original.ResourceSkusResultPage +type Restriction = original.Restriction +type SetObject = original.SetObject +type SkusClient = original.SkusClient +type StorageTarget = original.StorageTarget +type StorageTargetProperties = original.StorageTargetProperties +type StorageTargetsClient = original.StorageTargetsClient +type StorageTargetsCreateFuture = original.StorageTargetsCreateFuture +type StorageTargetsDeleteFuture = original.StorageTargetsDeleteFuture +type StorageTargetsResult = original.StorageTargetsResult +type StorageTargetsResultIterator = original.StorageTargetsResultIterator +type StorageTargetsResultPage = original.StorageTargetsResultPage +type UnknownTarget = original.UnknownTarget +type UsageModel = original.UsageModel +type UsageModelDisplay = original.UsageModelDisplay +type UsageModelsClient = original.UsageModelsClient +type UsageModelsResult = original.UsageModelsResult +type UsageModelsResultIterator = original.UsageModelsResultIterator +type UsageModelsResultPage = original.UsageModelsResultPage + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewAPIOperationListResultIterator(page APIOperationListResultPage) APIOperationListResultIterator { + return original.NewAPIOperationListResultIterator(page) +} +func NewAPIOperationListResultPage(getNextPage func(context.Context, APIOperationListResult) (APIOperationListResult, error)) APIOperationListResultPage { + return original.NewAPIOperationListResultPage(getNextPage) +} +func NewCachesClient(subscriptionID string) CachesClient { + return original.NewCachesClient(subscriptionID) +} +func NewCachesClientWithBaseURI(baseURI string, subscriptionID string) CachesClient { + return original.NewCachesClientWithBaseURI(baseURI, subscriptionID) +} +func NewCachesListResultIterator(page CachesListResultPage) CachesListResultIterator { + return original.NewCachesListResultIterator(page) +} +func NewCachesListResultPage(getNextPage func(context.Context, CachesListResult) (CachesListResult, error)) CachesListResultPage { + return original.NewCachesListResultPage(getNextPage) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceSkusResultIterator(page ResourceSkusResultPage) ResourceSkusResultIterator { + return original.NewResourceSkusResultIterator(page) +} +func NewResourceSkusResultPage(getNextPage func(context.Context, ResourceSkusResult) (ResourceSkusResult, error)) ResourceSkusResultPage { + return original.NewResourceSkusResultPage(getNextPage) +} +func NewSkusClient(subscriptionID string) SkusClient { + return original.NewSkusClient(subscriptionID) +} +func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient { + return original.NewSkusClientWithBaseURI(baseURI, subscriptionID) +} +func NewStorageTargetsClient(subscriptionID string) StorageTargetsClient { + return original.NewStorageTargetsClient(subscriptionID) +} +func NewStorageTargetsClientWithBaseURI(baseURI string, subscriptionID string) StorageTargetsClient { + return original.NewStorageTargetsClientWithBaseURI(baseURI, subscriptionID) +} +func NewStorageTargetsResultIterator(page StorageTargetsResultPage) StorageTargetsResultIterator { + return original.NewStorageTargetsResultIterator(page) +} +func NewStorageTargetsResultPage(getNextPage func(context.Context, StorageTargetsResult) (StorageTargetsResult, error)) StorageTargetsResultPage { + return original.NewStorageTargetsResultPage(getNextPage) +} +func NewUsageModelsClient(subscriptionID string) UsageModelsClient { + return original.NewUsageModelsClient(subscriptionID) +} +func NewUsageModelsClientWithBaseURI(baseURI string, subscriptionID string) UsageModelsClient { + return original.NewUsageModelsClientWithBaseURI(baseURI, subscriptionID) +} +func NewUsageModelsResultIterator(page UsageModelsResultPage) UsageModelsResultIterator { + return original.NewUsageModelsResultIterator(page) +} +func NewUsageModelsResultPage(getNextPage func(context.Context, UsageModelsResult) (UsageModelsResult, error)) UsageModelsResultPage { + return original.NewUsageModelsResultPage(getNextPage) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleFirmwareStatusTypeValues() []FirmwareStatusType { + return original.PossibleFirmwareStatusTypeValues() +} +func PossibleHealthStateTypeValues() []HealthStateType { + return original.PossibleHealthStateTypeValues() +} +func PossibleProvisioningStateTypeValues() []ProvisioningStateType { + return original.PossibleProvisioningStateTypeValues() +} +func PossibleReasonCodeValues() []ReasonCode { + return original.PossibleReasonCodeValues() +} +func PossibleStorageTargetTypeValues() []StorageTargetType { + return original.PossibleStorageTargetTypeValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/profiles/preview/preview/storagecache/mgmt/storagecache/storagecacheapi/models.go b/profiles/preview/preview/storagecache/mgmt/storagecache/storagecacheapi/models.go new file mode 100644 index 000000000000..c96cccca7d3b --- /dev/null +++ b/profiles/preview/preview/storagecache/mgmt/storagecache/storagecacheapi/models.go @@ -0,0 +1,28 @@ +// +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 storagecacheapi + +import original "github.com/Azure/azure-sdk-for-go/services/preview/storagecache/mgmt/2019-08/storagecache/storagecacheapi" + +type CachesClientAPI = original.CachesClientAPI +type OperationsClientAPI = original.OperationsClientAPI +type SkusClientAPI = original.SkusClientAPI +type StorageTargetsClientAPI = original.StorageTargetsClientAPI +type UsageModelsClientAPI = original.UsageModelsClientAPI diff --git a/services/preview/storagecache/mgmt/2017-08-15/storagecache/caches.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/caches.go new file mode 100644 index 000000000000..d0f8741fd623 --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/caches.go @@ -0,0 +1,951 @@ +package storagecache + +// 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" +) + +// CachesClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from either +// NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +type CachesClient struct { + BaseClient +} + +// NewCachesClient creates an instance of the CachesClient client. +func NewCachesClient(subscriptionID string) CachesClient { + return NewCachesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCachesClientWithBaseURI creates an instance of the CachesClient client. +func NewCachesClientWithBaseURI(baseURI string, subscriptionID string) CachesClient { + return CachesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create/update a Cache instance. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// cache - object containing the user selectable properties of the new cache. If read-only properties are +// included, they must match the existing values of those properties. +func (client CachesClient) Create(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (result CachesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, cacheName, cache) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client CachesClient) CreatePreparer(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + cache.ID = nil + cache.Name = nil + cache.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.StorageCache/caches/{cacheName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if cache != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(cache)) + } + 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 CachesClient) CreateSender(req *http.Request) (future CachesCreateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 CachesClient) CreateResponder(resp *http.Response) (result Cache, 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 schedules a Cache for deletion. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Delete(ctx context.Context, resourceGroupName string, cacheName string) (result CachesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CachesClient) DeletePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}", 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 CachesClient) DeleteSender(req *http.Request) (future CachesDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 CachesClient) DeleteResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Flush tells a cache to write all dirty data to the StorageTarget(s). During the flush, clients will see errors +// returned until the flush is complete. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Flush(ctx context.Context, resourceGroupName string, cacheName string) (result CachesFlushFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Flush") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Flush", err.Error()) + } + + req, err := client.FlushPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Flush", nil, "Failure preparing request") + return + } + + result, err = client.FlushSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Flush", result.Response(), "Failure sending request") + return + } + + return +} + +// FlushPreparer prepares the Flush request. +func (client CachesClient) FlushPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FlushSender sends the Flush request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) FlushSender(req *http.Request) (future CachesFlushFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// FlushResponder handles the response to the Flush request. The method always +// closes the http.Response Body. +func (client CachesClient) FlushResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get returns a Cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Get(ctx context.Context, resourceGroupName string, cacheName string) (result Cache, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CachesClient) GetPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}", 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 CachesClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CachesClient) GetResponder(resp *http.Response) (result Cache, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List returns all Caches the user has access to under a subscription. +func (client CachesClient) List(ctx context.Context) (result CachesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.List") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", resp, "Failure sending request") + return + } + + result.clr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client CachesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches", 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 CachesClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CachesClient) ListResponder(resp *http.Response) (result CachesListResult, 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 CachesClient) listNextResults(ctx context.Context, lastResults CachesListResult) (result CachesListResult, err error) { + req, err := lastResults.cachesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "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, "storagecache.CachesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client CachesClient) ListComplete(ctx context.Context) (result CachesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup returns all Caches the user has access to under a resource group and subscription. +// Parameters: +// resourceGroupName - target resource group. +func (client CachesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result CachesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.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, "storagecache.CachesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client CachesClient) 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 = "2019-08-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.StorageCache/caches", 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 CachesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client CachesClient) ListByResourceGroupResponder(resp *http.Response) (result CachesListResult, 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 CachesClient) listByResourceGroupNextResults(ctx context.Context, lastResults CachesListResult) (result CachesListResult, err error) { + req, err := lastResults.cachesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "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, "storagecache.CachesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client CachesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result CachesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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 +} + +// Start tells a Stopped state cache to transition to Active state. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Start(ctx context.Context, resourceGroupName string, cacheName string) (result CachesStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Start") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Start", result.Response(), "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client CachesClient) StartPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) StartSender(req *http.Request) (future CachesStartFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client CachesClient) StartResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Stop tells an Active cache to transition to Stopped state. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Stop(ctx context.Context, resourceGroupName string, cacheName string) (result CachesStopFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Stop") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Stop", nil, "Failure preparing request") + return + } + + result, err = client.StopSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Stop", result.Response(), "Failure sending request") + return + } + + return +} + +// StopPreparer prepares the Stop request. +func (client CachesClient) StopPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) StopSender(req *http.Request) (future CachesStopFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client CachesClient) StopResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update a Cache instance. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// cache - object containing the user selectable properties of the new cache. If read-only properties are +// included, they must match the existing values of those properties. +func (client CachesClient) Update(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (result Cache, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, cacheName, cache) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CachesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + cache.ID = nil + cache.Name = nil + cache.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if cache != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(cache)) + } + 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 CachesClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CachesClient) UpdateResponder(resp *http.Response) (result Cache, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpgradeFirmware tells a cache to upgrade its firmware. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) UpgradeFirmware(ctx context.Context, resourceGroupName string, cacheName string) (result CachesUpgradeFirmwareFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.UpgradeFirmware") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "UpgradeFirmware", err.Error()) + } + + req, err := client.UpgradeFirmwarePreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "UpgradeFirmware", nil, "Failure preparing request") + return + } + + result, err = client.UpgradeFirmwareSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "UpgradeFirmware", result.Response(), "Failure sending request") + return + } + + return +} + +// UpgradeFirmwarePreparer prepares the UpgradeFirmware request. +func (client CachesClient) UpgradeFirmwarePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpgradeFirmwareSender sends the UpgradeFirmware request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) UpgradeFirmwareSender(req *http.Request) (future CachesUpgradeFirmwareFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpgradeFirmwareResponder handles the response to the UpgradeFirmware request. The method always +// closes the http.Response Body. +func (client CachesClient) UpgradeFirmwareResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/storagecache/mgmt/2017-08-15/storagecache/client.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/client.go new file mode 100644 index 000000000000..1a9233396c35 --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/client.go @@ -0,0 +1,52 @@ +// Package storagecache implements the Azure ARM Storagecache service API version 2019-08-01-preview. +// +// A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest +// storage (referred to as "Storage Targets"). These operations allow you to manage caches. +package storagecache + +// 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 Storagecache + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Storagecache. +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/storagecache/mgmt/2017-08-15/storagecache/models.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/models.go new file mode 100644 index 000000000000..a46c6b9e128a --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/models.go @@ -0,0 +1,1480 @@ +package storagecache + +// 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/storagecache/mgmt/2017-08-15/storagecache" + +// FirmwareStatusType enumerates the values for firmware status type. +type FirmwareStatusType string + +const ( + // Available ... + Available FirmwareStatusType = "available" + // Unavailable ... + Unavailable FirmwareStatusType = "unavailable" +) + +// PossibleFirmwareStatusTypeValues returns an array of possible values for the FirmwareStatusType const type. +func PossibleFirmwareStatusTypeValues() []FirmwareStatusType { + return []FirmwareStatusType{Available, Unavailable} +} + +// HealthStateType enumerates the values for health state type. +type HealthStateType string + +const ( + // Degraded ... + Degraded HealthStateType = "Degraded" + // Down ... + Down HealthStateType = "Down" + // Flushing ... + Flushing HealthStateType = "Flushing" + // Healthy ... + Healthy HealthStateType = "Healthy" + // Stopped ... + Stopped HealthStateType = "Stopped" + // Stopping ... + Stopping HealthStateType = "Stopping" + // Transitioning ... + Transitioning HealthStateType = "Transitioning" + // Unknown ... + Unknown HealthStateType = "Unknown" + // Upgrading ... + Upgrading HealthStateType = "Upgrading" +) + +// PossibleHealthStateTypeValues returns an array of possible values for the HealthStateType const type. +func PossibleHealthStateTypeValues() []HealthStateType { + return []HealthStateType{Degraded, Down, Flushing, Healthy, Stopped, Stopping, Transitioning, Unknown, Upgrading} +} + +// ProvisioningStateType enumerates the values for provisioning state type. +type ProvisioningStateType string + +const ( + // Cancelled ... + Cancelled ProvisioningStateType = "Cancelled" + // Creating ... + Creating ProvisioningStateType = "Creating" + // Deleting ... + Deleting ProvisioningStateType = "Deleting" + // Failed ... + Failed ProvisioningStateType = "Failed" + // Succeeded ... + Succeeded ProvisioningStateType = "Succeeded" + // Updating ... + Updating ProvisioningStateType = "Updating" +) + +// PossibleProvisioningStateTypeValues returns an array of possible values for the ProvisioningStateType const type. +func PossibleProvisioningStateTypeValues() []ProvisioningStateType { + return []ProvisioningStateType{Cancelled, Creating, Deleting, Failed, Succeeded, Updating} +} + +// ReasonCode enumerates the values for reason code. +type ReasonCode string + +const ( + // NotAvailableForSubscription ... + NotAvailableForSubscription ReasonCode = "NotAvailableForSubscription" + // QuotaID ... + QuotaID ReasonCode = "QuotaId" +) + +// PossibleReasonCodeValues returns an array of possible values for the ReasonCode const type. +func PossibleReasonCodeValues() []ReasonCode { + return []ReasonCode{NotAvailableForSubscription, QuotaID} +} + +// StorageTargetType enumerates the values for storage target type. +type StorageTargetType string + +const ( + // StorageTargetTypeClfs ... + StorageTargetTypeClfs StorageTargetType = "clfs" + // StorageTargetTypeNfs3 ... + StorageTargetTypeNfs3 StorageTargetType = "nfs3" + // StorageTargetTypeUnknown ... + StorageTargetTypeUnknown StorageTargetType = "unknown" +) + +// PossibleStorageTargetTypeValues returns an array of possible values for the StorageTargetType const type. +func PossibleStorageTargetTypeValues() []StorageTargetType { + return []StorageTargetType{StorageTargetTypeClfs, StorageTargetTypeNfs3, StorageTargetTypeUnknown} +} + +// APIOperation REST API operation description: see +// https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/openapi-authoring-automated-guidelines.md#r3023-operationsapiimplementation +type APIOperation struct { + // Display - The object that represents the operation. + Display *APIOperationDisplay `json:"display,omitempty"` + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` +} + +// APIOperationDisplay the object that represents the operation. +type APIOperationDisplay struct { + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + // Provider - Service provider: Microsoft.StorageCache + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: cache, etc. + Resource *string `json:"resource,omitempty"` +} + +// APIOperationListResult result of the request to list Resource Provider operations. It contains a list of +// operations and a URL link to get the next set of results. +type APIOperationListResult struct { + autorest.Response `json:"-"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + // Value - List of Resource Provider operations supported by the Microsoft.StorageCache resource provider. + Value *[]APIOperation `json:"value,omitempty"` +} + +// APIOperationListResultIterator provides access to a complete listing of APIOperation values. +type APIOperationListResultIterator struct { + i int + page APIOperationListResultPage +} + +// 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 *APIOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationListResultIterator.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 *APIOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APIOperationListResultIterator) 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 APIOperationListResultIterator) Response() APIOperationListResult { + 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 APIOperationListResultIterator) Value() APIOperation { + if !iter.page.NotDone() { + return APIOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APIOperationListResultIterator type. +func NewAPIOperationListResultIterator(page APIOperationListResultPage) APIOperationListResultIterator { + return APIOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aolr APIOperationListResult) IsEmpty() bool { + return aolr.Value == nil || len(*aolr.Value) == 0 +} + +// aPIOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aolr APIOperationListResult) aPIOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if aolr.NextLink == nil || len(to.String(aolr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aolr.NextLink))) +} + +// APIOperationListResultPage contains a page of APIOperation values. +type APIOperationListResultPage struct { + fn func(context.Context, APIOperationListResult) (APIOperationListResult, error) + aolr APIOperationListResult +} + +// 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 *APIOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationListResultPage.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.aolr) + if err != nil { + return err + } + page.aolr = 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 *APIOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APIOperationListResultPage) NotDone() bool { + return !page.aolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APIOperationListResultPage) Response() APIOperationListResult { + return page.aolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APIOperationListResultPage) Values() []APIOperation { + if page.aolr.IsEmpty() { + return nil + } + return *page.aolr.Value +} + +// Creates a new instance of the APIOperationListResultPage type. +func NewAPIOperationListResultPage(getNextPage func(context.Context, APIOperationListResult) (APIOperationListResult, error)) APIOperationListResultPage { + return APIOperationListResultPage{fn: getNextPage} +} + +// Cache a cache instance. Follows Azure Resource Manager standards: +// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md +type Cache struct { + autorest.Response `json:"-"` + // Tags - ARM tags as name/value pairs. + Tags interface{} `json:"tags,omitempty"` + // ID - READ-ONLY; Fully qualified URL of the cache. + ID *string `json:"id,omitempty"` + // Location - Region name string. + Location *string `json:"location,omitempty"` + // Name - READ-ONLY; Name of cache. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type for the cache; Microsoft.StorageCache/Cache + Type *string `json:"type,omitempty"` + // CacheProperties - Properties for the cache. + *CacheProperties `json:"properties,omitempty"` + // Sku - Sku for the cache. + Sku *CacheSku `json:"sku,omitempty"` +} + +// MarshalJSON is the custom marshaler for Cache. +func (c Cache) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + if c.Location != nil { + objectMap["location"] = c.Location + } + if c.CacheProperties != nil { + objectMap["properties"] = c.CacheProperties + } + if c.Sku != nil { + objectMap["sku"] = c.Sku + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cache struct. +func (c *Cache) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags interface{} + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + case "properties": + if v != nil { + var cacheProperties CacheProperties + err = json.Unmarshal(*v, &cacheProperties) + if err != nil { + return err + } + c.CacheProperties = &cacheProperties + } + case "sku": + if v != nil { + var sku CacheSku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + c.Sku = &sku + } + } + } + + return nil +} + +// CacheHealth an indication of cache health. Gives more information about health than just that related +// to provisioning. +type CacheHealth struct { + // State - List of cache health states. Possible values include: 'Unknown', 'Healthy', 'Degraded', 'Down', 'Transitioning', 'Stopping', 'Stopped', 'Upgrading', 'Flushing' + State HealthStateType `json:"state,omitempty"` + // StatusDescription - Describes explanation of state. + StatusDescription *string `json:"statusDescription,omitempty"` +} + +// CacheProperties properties for the cache. +type CacheProperties struct { + // CacheSizeGB - The size of this cache's cache, in GB. + CacheSizeGB *int32 `json:"cacheSizeGB,omitempty"` + // Health - READ-ONLY; Health of the cache. + Health *CacheHealth `json:"health,omitempty"` + // MountAddresses - READ-ONLY; Array of IP addresses that can be used by clients mounting this Cache. + MountAddresses *[]string `json:"mountAddresses,omitempty"` + // ProvisioningState - ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Creating', 'Deleting', 'Updating' + ProvisioningState ProvisioningStateType `json:"provisioningState,omitempty"` + // Subnet - Subnet used for the cache. + Subnet *string `json:"subnet,omitempty"` + // UpgradeStatus - Upgrade status of the cache. + UpgradeStatus *CacheUpgradeStatus `json:"upgradeStatus,omitempty"` +} + +// CachesCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesCreateFuture) Result(client CachesClient) (c Cache, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesCreateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesDeleteFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.DeleteResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesDeleteFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesFlushFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesFlushFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesFlushFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesFlushFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesFlushFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.FlushResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesFlushFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CacheSku sku for the cache. +type CacheSku struct { + // Name - Sku name for this cache. + Name *string `json:"name,omitempty"` +} + +// CachesListResult result of the request to list caches. It contains a list of caches and a URL link to +// get the next set of results. +type CachesListResult struct { + autorest.Response `json:"-"` + // NextLink - URL to get the next set of cache list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + // Value - List of caches. + Value *[]Cache `json:"value,omitempty"` +} + +// CachesListResultIterator provides access to a complete listing of Cache values. +type CachesListResultIterator struct { + i int + page CachesListResultPage +} + +// 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 *CachesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesListResultIterator.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 *CachesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CachesListResultIterator) 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 CachesListResultIterator) Response() CachesListResult { + 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 CachesListResultIterator) Value() Cache { + if !iter.page.NotDone() { + return Cache{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CachesListResultIterator type. +func NewCachesListResultIterator(page CachesListResultPage) CachesListResultIterator { + return CachesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CachesListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// cachesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CachesListResult) cachesListResultPreparer(ctx context.Context) (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CachesListResultPage contains a page of Cache values. +type CachesListResultPage struct { + fn func(context.Context, CachesListResult) (CachesListResult, error) + clr CachesListResult +} + +// 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 *CachesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesListResultPage.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.clr) + if err != nil { + return err + } + page.clr = 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 *CachesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CachesListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CachesListResultPage) Response() CachesListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CachesListResultPage) Values() []Cache { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the CachesListResultPage type. +func NewCachesListResultPage(getNextPage func(context.Context, CachesListResult) (CachesListResult, error)) CachesListResultPage { + return CachesListResultPage{fn: getNextPage} +} + +// CachesStartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesStartFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesStartFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesStartFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.StartResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStartFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesStopFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesStopFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesStopFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStopFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesStopFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.StopResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStopFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesUpgradeFirmwareFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CachesUpgradeFirmwareFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesUpgradeFirmwareFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesUpgradeFirmwareFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesUpgradeFirmwareFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.UpgradeFirmwareResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesUpgradeFirmwareFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CacheUpgradeStatus properties describing the software upgrade state of the cache +type CacheUpgradeStatus struct { + // CurrentFirmwareVersion - READ-ONLY; Version string of the firmware currently installed on this cache. + CurrentFirmwareVersion *string `json:"currentFirmwareVersion,omitempty"` + // FirmwareUpdateStatus - READ-ONLY; True if there is a firmware update ready to install on this cache. The firmware will automatically be installed after firmwareUpdateDeadline if not triggered earlier via the upgrade operation. Possible values include: 'Available', 'Unavailable' + FirmwareUpdateStatus FirmwareStatusType `json:"firmwareUpdateStatus,omitempty"` + // FirmwareUpdateDeadline - READ-ONLY; Time at which the pending firmware update will automatically be installed on the cache. + FirmwareUpdateDeadline *date.Time `json:"firmwareUpdateDeadline,omitempty"` + // LastFirmwareUpdate - READ-ONLY; Time of the last successful firmware update. + LastFirmwareUpdate *date.Time `json:"lastFirmwareUpdate,omitempty"` + // PendingFirmwareVersion - READ-ONLY; When firmwareUpdateAvailable is true, this field holds the version string for the update. + PendingFirmwareVersion *string `json:"pendingFirmwareVersion,omitempty"` +} + +// ClfsTarget storage container for use as a CLFS StorageTarget. +type ClfsTarget struct { + // Target - URL of storage container. + Target *string `json:"target,omitempty"` +} + +// CloudError an error response. +type CloudError struct { + // Error - The body of the error. + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody an error response. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Details - A list of additional details about the error. + Details *[]CloudErrorBody `json:"details,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// NamespaceJunction a namespace junction. +type NamespaceJunction struct { + // NamespacePath - Namespace path on a cache for a storage target. + NamespacePath *string `json:"namespacePath,omitempty"` + // TargetPath - Path in storage target to which namespacePath points. + TargetPath *string `json:"targetPath,omitempty"` + // NfsExport - NFS export where targetPath exists. + NfsExport *string `json:"nfsExport,omitempty"` +} + +// Nfs3Target an NFS mount point for use as a StorageTarget. +type Nfs3Target struct { + // Target - IP or name of an NFS Storage Target host, ie: 10.0.44.44 + Target *string `json:"target,omitempty"` + // UsageModel - Identifies the primary usage model to be used for this storage target. GET choices from .../usageModels + UsageModel *string `json:"usageModel,omitempty"` +} + +// ResourceSku a resource SKU +type ResourceSku struct { + // ResourceType - READ-ONLY; The type of resource the sku applies to. + ResourceType *string `json:"resourceType,omitempty"` + // Capabilities - A list of capabilities of this SKU, such as throughput or ops/sec + Capabilities *[]ResourceSkuCapabilities `json:"capabilities,omitempty"` + // Locations - READ-ONLY; The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). + Locations *[]string `json:"locations,omitempty"` + // LocationInfo - The set of locations that the SKU is available. + LocationInfo *[]ResourceSkuLocationInfo `json:"locationInfo,omitempty"` + // Name - The name of this sku. + Name *string `json:"name,omitempty"` + // Restrictions - The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. + Restrictions *[]Restriction `json:"restrictions,omitempty"` +} + +// ResourceSkuCapabilities a resource SKU capability. +type ResourceSkuCapabilities struct { + // Name - Name of a capability, such as ops/sec + Name *string `json:"name,omitempty"` + // Value - Quantity, if the capability is measured by quantity + Value *string `json:"value,omitempty"` +} + +// ResourceSkuLocationInfo resource SKU location information. +type ResourceSkuLocationInfo struct { + // Location - Location where this Sku is available + Location *string `json:"location,omitempty"` + // Zones - Zones if any. + Zones *[]string `json:"zones,omitempty"` +} + +// ResourceSkusResult the response from the List Cache SKUs operation. +type ResourceSkusResult struct { + autorest.Response `json:"-"` + // NextLink - The uri to fetch the next page of cache Skus. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; The list of skus available for the subscription. + Value *[]ResourceSku `json:"value,omitempty"` +} + +// ResourceSkusResultIterator provides access to a complete listing of ResourceSku values. +type ResourceSkusResultIterator struct { + i int + page ResourceSkusResultPage +} + +// 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 *ResourceSkusResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusResultIterator.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 *ResourceSkusResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceSkusResultIterator) 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 ResourceSkusResultIterator) Response() ResourceSkusResult { + 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 ResourceSkusResultIterator) Value() ResourceSku { + if !iter.page.NotDone() { + return ResourceSku{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceSkusResultIterator type. +func NewResourceSkusResultIterator(page ResourceSkusResultPage) ResourceSkusResultIterator { + return ResourceSkusResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rsr ResourceSkusResult) IsEmpty() bool { + return rsr.Value == nil || len(*rsr.Value) == 0 +} + +// resourceSkusResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rsr ResourceSkusResult) resourceSkusResultPreparer(ctx context.Context) (*http.Request, error) { + if rsr.NextLink == nil || len(to.String(rsr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rsr.NextLink))) +} + +// ResourceSkusResultPage contains a page of ResourceSku values. +type ResourceSkusResultPage struct { + fn func(context.Context, ResourceSkusResult) (ResourceSkusResult, error) + rsr ResourceSkusResult +} + +// 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 *ResourceSkusResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusResultPage.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.rsr) + if err != nil { + return err + } + page.rsr = 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 *ResourceSkusResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceSkusResultPage) NotDone() bool { + return !page.rsr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceSkusResultPage) Response() ResourceSkusResult { + return page.rsr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceSkusResultPage) Values() []ResourceSku { + if page.rsr.IsEmpty() { + return nil + } + return *page.rsr.Value +} + +// Creates a new instance of the ResourceSkusResultPage type. +func NewResourceSkusResultPage(getNextPage func(context.Context, ResourceSkusResult) (ResourceSkusResult, error)) ResourceSkusResultPage { + return ResourceSkusResultPage{fn: getNextPage} +} + +// Restriction the restriction because of which SKU cannot be used. +type Restriction struct { + // Type - READ-ONLY; The type of restrictions. As of now only possible value for this is location. + Type *string `json:"type,omitempty"` + // Values - READ-ONLY; The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. + Values *[]string `json:"values,omitempty"` + // ReasonCode - The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription' + ReasonCode ReasonCode `json:"reasonCode,omitempty"` +} + +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + +// StorageTarget a storage system being cached by a Cache. +type StorageTarget struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; A fully qualified URL. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Type for the storage target; Microsoft.StorageCache/Cache/StorageTarget + Type *string `json:"type,omitempty"` + // StorageTargetProperties - Properties of the storage target. + *StorageTargetProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageTarget. +func (st StorageTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if st.StorageTargetProperties != nil { + objectMap["properties"] = st.StorageTargetProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for StorageTarget struct. +func (st *StorageTarget) 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 "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + st.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + st.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + st.Type = &typeVar + } + case "properties": + if v != nil { + var storageTargetProperties StorageTargetProperties + err = json.Unmarshal(*v, &storageTargetProperties) + if err != nil { + return err + } + st.StorageTargetProperties = &storageTargetProperties + } + } + } + + return nil +} + +// StorageTargetProperties properties of the storage target. +type StorageTargetProperties struct { + // Junctions - List of cache namespace to target namespace associations. + Junctions *[]NamespaceJunction `json:"junctions,omitempty"` + // TargetType - Type for storage target. Possible values include: 'StorageTargetTypeNfs3', 'StorageTargetTypeClfs', 'StorageTargetTypeUnknown' + TargetType StorageTargetType `json:"targetType,omitempty"` + // ProvisioningState - ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Creating', 'Deleting', 'Updating' + ProvisioningState ProvisioningStateType `json:"provisioningState,omitempty"` + // Nfs3 - Properties when nfs3 target. + Nfs3 *Nfs3Target `json:"nfs3,omitempty"` + // Clfs - Properties when clfs target. + Clfs *ClfsTarget `json:"clfs,omitempty"` + // Unknown - Properties when unknown target. + Unknown *UnknownTarget `json:"unknown,omitempty"` +} + +// StorageTargetsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type StorageTargetsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *StorageTargetsCreateFuture) Result(client StorageTargetsClient) (st StorageTarget, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.StorageTargetsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if st.Response.Response, err = future.GetResult(sender); err == nil && st.Response.Response.StatusCode != http.StatusNoContent { + st, err = client.CreateResponder(st.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsCreateFuture", "Result", st.Response.Response, "Failure responding to request") + } + } + return +} + +// StorageTargetsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type StorageTargetsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *StorageTargetsDeleteFuture) Result(client StorageTargetsClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.StorageTargetsDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.DeleteResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsDeleteFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// StorageTargetsResult a list of storage targets. +type StorageTargetsResult struct { + autorest.Response `json:"-"` + // NextLink - The uri to fetch the next page of storage targets. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of storage targets defined for the cache. + Value *[]StorageTarget `json:"value,omitempty"` +} + +// StorageTargetsResultIterator provides access to a complete listing of StorageTarget values. +type StorageTargetsResultIterator struct { + i int + page StorageTargetsResultPage +} + +// 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 *StorageTargetsResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsResultIterator.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 *StorageTargetsResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter StorageTargetsResultIterator) 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 StorageTargetsResultIterator) Response() StorageTargetsResult { + 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 StorageTargetsResultIterator) Value() StorageTarget { + if !iter.page.NotDone() { + return StorageTarget{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the StorageTargetsResultIterator type. +func NewStorageTargetsResultIterator(page StorageTargetsResultPage) StorageTargetsResultIterator { + return StorageTargetsResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (str StorageTargetsResult) IsEmpty() bool { + return str.Value == nil || len(*str.Value) == 0 +} + +// storageTargetsResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (str StorageTargetsResult) storageTargetsResultPreparer(ctx context.Context) (*http.Request, error) { + if str.NextLink == nil || len(to.String(str.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(str.NextLink))) +} + +// StorageTargetsResultPage contains a page of StorageTarget values. +type StorageTargetsResultPage struct { + fn func(context.Context, StorageTargetsResult) (StorageTargetsResult, error) + str StorageTargetsResult +} + +// 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 *StorageTargetsResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsResultPage.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.str) + if err != nil { + return err + } + page.str = 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 *StorageTargetsResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page StorageTargetsResultPage) NotDone() bool { + return !page.str.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page StorageTargetsResultPage) Response() StorageTargetsResult { + return page.str +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page StorageTargetsResultPage) Values() []StorageTarget { + if page.str.IsEmpty() { + return nil + } + return *page.str.Value +} + +// Creates a new instance of the StorageTargetsResultPage type. +func NewStorageTargetsResultPage(getNextPage func(context.Context, StorageTargetsResult) (StorageTargetsResult, error)) StorageTargetsResultPage { + return StorageTargetsResultPage{fn: getNextPage} +} + +// UnknownTarget storage container for use as a Unknown StorageTarget. +type UnknownTarget struct { + // UnknownMap - Dictionary of string->string pairs containing information about the StorageTarget. + UnknownMap map[string]*string `json:"unknownMap"` +} + +// MarshalJSON is the custom marshaler for UnknownTarget. +func (ut UnknownTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ut.UnknownMap != nil { + objectMap["unknownMap"] = ut.UnknownMap + } + return json.Marshal(objectMap) +} + +// UsageModel a usage model. +type UsageModel struct { + // Display - Localized information describing this usage model. + Display *UsageModelDisplay `json:"display,omitempty"` + // ModelName - Non localized keyword naming this usage model. + ModelName *string `json:"modelName,omitempty"` + // TargetType - The type of Storage Target to which this model is applicable (only nfs for now) + TargetType *string `json:"targetType,omitempty"` +} + +// UsageModelDisplay localized information describing this usage model. +type UsageModelDisplay struct { + // Description - String to display for this usage model. + Description *string `json:"description,omitempty"` +} + +// UsageModelsResult a list of cache usage models. +type UsageModelsResult struct { + autorest.Response `json:"-"` + // NextLink - The uri to fetch the next page of cache usage models. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of usage models available for the subscription. + Value *[]UsageModel `json:"value,omitempty"` +} + +// UsageModelsResultIterator provides access to a complete listing of UsageModel values. +type UsageModelsResultIterator struct { + i int + page UsageModelsResultPage +} + +// 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 *UsageModelsResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsResultIterator.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 *UsageModelsResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UsageModelsResultIterator) 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 UsageModelsResultIterator) Response() UsageModelsResult { + 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 UsageModelsResultIterator) Value() UsageModel { + if !iter.page.NotDone() { + return UsageModel{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UsageModelsResultIterator type. +func NewUsageModelsResultIterator(page UsageModelsResultPage) UsageModelsResultIterator { + return UsageModelsResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (umr UsageModelsResult) IsEmpty() bool { + return umr.Value == nil || len(*umr.Value) == 0 +} + +// usageModelsResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (umr UsageModelsResult) usageModelsResultPreparer(ctx context.Context) (*http.Request, error) { + if umr.NextLink == nil || len(to.String(umr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(umr.NextLink))) +} + +// UsageModelsResultPage contains a page of UsageModel values. +type UsageModelsResultPage struct { + fn func(context.Context, UsageModelsResult) (UsageModelsResult, error) + umr UsageModelsResult +} + +// 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 *UsageModelsResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsResultPage.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.umr) + if err != nil { + return err + } + page.umr = 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 *UsageModelsResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UsageModelsResultPage) NotDone() bool { + return !page.umr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UsageModelsResultPage) Response() UsageModelsResult { + return page.umr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UsageModelsResultPage) Values() []UsageModel { + if page.umr.IsEmpty() { + return nil + } + return *page.umr.Value +} + +// Creates a new instance of the UsageModelsResultPage type. +func NewUsageModelsResultPage(getNextPage func(context.Context, UsageModelsResult) (UsageModelsResult, error)) UsageModelsResultPage { + return UsageModelsResultPage{fn: getNextPage} +} diff --git a/services/preview/storagecache/mgmt/2017-08-15/storagecache/operations.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/operations.go new file mode 100644 index 000000000000..56a2449617fb --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/operations.go @@ -0,0 +1,148 @@ +package storagecache + +// 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 a Storage Cache provides scalable caching service for NAS clients, serving data from either +// NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +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 lists all of the available RP operations. +func (client OperationsClient) List(ctx context.Context) (result APIOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.aolr.Response.Response != nil { + sc = result.aolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.aolr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.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 = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.StorageCache/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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result APIOperationListResult, 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 APIOperationListResult) (result APIOperationListResult, err error) { + req, err := lastResults.aPIOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.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, "storagecache.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.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 APIOperationListResultIterator, 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/storagecache/mgmt/2017-08-15/storagecache/skus.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/skus.go new file mode 100644 index 000000000000..4bc65998a2a0 --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/skus.go @@ -0,0 +1,152 @@ +package storagecache + +// 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" +) + +// SkusClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 +// or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +type SkusClient struct { + BaseClient +} + +// NewSkusClient creates an instance of the SkusClient client. +func NewSkusClient(subscriptionID string) SkusClient { + return NewSkusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSkusClientWithBaseURI creates an instance of the SkusClient client. +func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient { + return SkusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the list of StorageCache.Cache SKUs available to this subscription. +func (client SkusClient) List(ctx context.Context) (result ResourceSkusResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.List") + defer func() { + sc := -1 + if result.rsr.Response.Response != nil { + sc = result.rsr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rsr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "List", resp, "Failure sending request") + return + } + + result.rsr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/skus", 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 SkusClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SkusClient) ListResponder(resp *http.Response) (result ResourceSkusResult, 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 SkusClient) listNextResults(ctx context.Context, lastResults ResourceSkusResult) (result ResourceSkusResult, err error) { + req, err := lastResults.resourceSkusResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.SkusClient", "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, "storagecache.SkusClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SkusClient) ListComplete(ctx context.Context) (result ResourceSkusResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.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/storagecache/mgmt/2017-08-15/storagecache/storagecacheapi/interfaces.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/storagecacheapi/interfaces.go new file mode 100644 index 000000000000..a4b3cd1daffb --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/storagecacheapi/interfaces.go @@ -0,0 +1,71 @@ +package storagecacheapi + +// 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/storagecache/mgmt/2017-08-15/storagecache" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result storagecache.APIOperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*storagecache.OperationsClient)(nil) + +// SkusClientAPI contains the set of methods on the SkusClient type. +type SkusClientAPI interface { + List(ctx context.Context) (result storagecache.ResourceSkusResultPage, err error) +} + +var _ SkusClientAPI = (*storagecache.SkusClient)(nil) + +// UsageModelsClientAPI contains the set of methods on the UsageModelsClient type. +type UsageModelsClientAPI interface { + List(ctx context.Context) (result storagecache.UsageModelsResultPage, err error) +} + +var _ UsageModelsClientAPI = (*storagecache.UsageModelsClient)(nil) + +// CachesClientAPI contains the set of methods on the CachesClient type. +type CachesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, cacheName string, cache *storagecache.Cache) (result storagecache.CachesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesDeleteFuture, err error) + Flush(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesFlushFuture, err error) + Get(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.Cache, err error) + List(ctx context.Context) (result storagecache.CachesListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result storagecache.CachesListResultPage, err error) + Start(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesStartFuture, err error) + Stop(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesStopFuture, err error) + Update(ctx context.Context, resourceGroupName string, cacheName string, cache *storagecache.Cache) (result storagecache.Cache, err error) + UpgradeFirmware(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesUpgradeFirmwareFuture, err error) +} + +var _ CachesClientAPI = (*storagecache.CachesClient)(nil) + +// StorageTargetsClientAPI contains the set of methods on the StorageTargetsClient type. +type StorageTargetsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *storagecache.StorageTarget) (result storagecache.StorageTargetsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result storagecache.StorageTargetsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result storagecache.StorageTarget, err error) + ListByCache(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.StorageTargetsResultPage, err error) + Update(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *storagecache.StorageTarget) (result storagecache.StorageTarget, err error) +} + +var _ StorageTargetsClientAPI = (*storagecache.StorageTargetsClient)(nil) diff --git a/services/preview/storagecache/mgmt/2017-08-15/storagecache/storagetargets.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/storagetargets.go new file mode 100644 index 000000000000..18ef27d16dd5 --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/storagetargets.go @@ -0,0 +1,543 @@ +package storagecache + +// 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" +) + +// StorageTargetsClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from +// either NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage +// caches. +type StorageTargetsClient struct { + BaseClient +} + +// NewStorageTargetsClient creates an instance of the StorageTargetsClient client. +func NewStorageTargetsClient(subscriptionID string) StorageTargetsClient { + return NewStorageTargetsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStorageTargetsClientWithBaseURI creates an instance of the StorageTargetsClient client. +func NewStorageTargetsClientWithBaseURI(baseURI string, subscriptionID string) StorageTargetsClient { + return StorageTargetsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create/update a storage target. This operation is allowed at any time, but if the cache is down or +// unhealthy, the actual creation/modification of the storage target may be delayed until the cache is healthy again. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +// storagetarget - object containing the definition of a storage target. +func (client StorageTargetsClient) Create(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (result StorageTargetsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storagetarget, + Constraints: []validation.Constraint{{Target: "storagetarget", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties.Nfs3", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties.Nfs3.Target", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties.Nfs3.Target", Name: validation.Pattern, Rule: `^[-.0-9a-zA-Z]+$`, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, cacheName, storageTargetName, storagetarget) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client StorageTargetsClient) CreatePreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + storagetarget.Name = nil + storagetarget.ID = nil + storagetarget.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.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if storagetarget != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(storagetarget)) + } + 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 StorageTargetsClient) CreateSender(req *http.Request) (future StorageTargetsCreateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 StorageTargetsClient) CreateResponder(resp *http.Response) (result StorageTarget, 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 removes a storage target from a cache. This operation is allowed at any time, but if the cache is down or +// unhealthy, the actual removal of the storage target may be delayed until the cache is healthy again. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +func (client StorageTargetsClient) Delete(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result StorageTargetsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, cacheName, storageTargetName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client StorageTargetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", 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 StorageTargetsClient) DeleteSender(req *http.Request) (future StorageTargetsDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 StorageTargetsClient) DeleteResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get returns a storage target from a cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +func (client StorageTargetsClient) Get(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result StorageTarget, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, cacheName, storageTargetName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client StorageTargetsClient) GetPreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", 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 StorageTargetsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) GetResponder(resp *http.Response) (result StorageTarget, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByCache returns the StorageTargets for this cache in the subscription and resource group. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client StorageTargetsClient) ListByCache(ctx context.Context, resourceGroupName string, cacheName string) (result StorageTargetsResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.ListByCache") + defer func() { + sc := -1 + if result.str.Response.Response != nil { + sc = result.str.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "ListByCache", err.Error()) + } + + result.fn = client.listByCacheNextResults + req, err := client.ListByCachePreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "ListByCache", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCacheSender(req) + if err != nil { + result.str.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "ListByCache", resp, "Failure sending request") + return + } + + result.str, err = client.ListByCacheResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "ListByCache", resp, "Failure responding to request") + } + + return +} + +// ListByCachePreparer prepares the ListByCache request. +func (client StorageTargetsClient) ListByCachePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}/storageTargets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByCacheSender sends the ListByCache request. The method will close the +// http.Response Body if it receives an error. +func (client StorageTargetsClient) ListByCacheSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByCacheResponder handles the response to the ListByCache request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) ListByCacheResponder(resp *http.Response) (result StorageTargetsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByCacheNextResults retrieves the next set of results, if any. +func (client StorageTargetsClient) listByCacheNextResults(ctx context.Context, lastResults StorageTargetsResult) (result StorageTargetsResult, err error) { + req, err := lastResults.storageTargetsResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "listByCacheNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCacheSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "listByCacheNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCacheResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "listByCacheNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCacheComplete enumerates all values, automatically crossing page boundaries as required. +func (client StorageTargetsClient) ListByCacheComplete(ctx context.Context, resourceGroupName string, cacheName string) (result StorageTargetsResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.ListByCache") + 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.ListByCache(ctx, resourceGroupName, cacheName) + return +} + +// Update update a storage target. This operation is allowed at any time, but if the cache is down or unhealthy, the +// actual creation/modification of the storage target may be delayed until the cache is healthy again. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +// storagetarget - object containing the definition of a storage target. +func (client StorageTargetsClient) Update(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (result StorageTarget, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, cacheName, storageTargetName, storagetarget) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client StorageTargetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + storagetarget.Name = nil + storagetarget.ID = nil + storagetarget.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if storagetarget != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(storagetarget)) + } + 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 StorageTargetsClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) UpdateResponder(resp *http.Response) (result StorageTarget, 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/storagecache/mgmt/2017-08-15/storagecache/usagemodels.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/usagemodels.go new file mode 100644 index 000000000000..7a6eb3ab86f8 --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/usagemodels.go @@ -0,0 +1,152 @@ +package storagecache + +// 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" +) + +// UsageModelsClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from either +// NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +type UsageModelsClient struct { + BaseClient +} + +// NewUsageModelsClient creates an instance of the UsageModelsClient client. +func NewUsageModelsClient(subscriptionID string) UsageModelsClient { + return NewUsageModelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsageModelsClientWithBaseURI creates an instance of the UsageModelsClient client. +func NewUsageModelsClientWithBaseURI(baseURI string, subscriptionID string) UsageModelsClient { + return UsageModelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the list of cache Usage Models available to this subscription. +func (client UsageModelsClient) List(ctx context.Context) (result UsageModelsResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsClient.List") + defer func() { + sc := -1 + if result.umr.Response.Response != nil { + sc = result.umr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.umr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "List", resp, "Failure sending request") + return + } + + result.umr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client UsageModelsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/usageModels", 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 UsageModelsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UsageModelsClient) ListResponder(resp *http.Response) (result UsageModelsResult, 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 UsageModelsClient) listNextResults(ctx context.Context, lastResults UsageModelsResult) (result UsageModelsResult, err error) { + req, err := lastResults.usageModelsResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "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, "storagecache.UsageModelsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UsageModelsClient) ListComplete(ctx context.Context) (result UsageModelsResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsClient.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/storagecache/mgmt/2017-08-15/storagecache/version.go b/services/preview/storagecache/mgmt/2017-08-15/storagecache/version.go new file mode 100644 index 000000000000..2d84fa9642e6 --- /dev/null +++ b/services/preview/storagecache/mgmt/2017-08-15/storagecache/version.go @@ -0,0 +1,30 @@ +package storagecache + +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 + " storagecache/2019-08-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/storagecache/mgmt/2019-08/storagecache/caches.go b/services/preview/storagecache/mgmt/2019-08/storagecache/caches.go new file mode 100644 index 000000000000..d0f8741fd623 --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/caches.go @@ -0,0 +1,951 @@ +package storagecache + +// 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" +) + +// CachesClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from either +// NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +type CachesClient struct { + BaseClient +} + +// NewCachesClient creates an instance of the CachesClient client. +func NewCachesClient(subscriptionID string) CachesClient { + return NewCachesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCachesClientWithBaseURI creates an instance of the CachesClient client. +func NewCachesClientWithBaseURI(baseURI string, subscriptionID string) CachesClient { + return CachesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create/update a Cache instance. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// cache - object containing the user selectable properties of the new cache. If read-only properties are +// included, they must match the existing values of those properties. +func (client CachesClient) Create(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (result CachesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, cacheName, cache) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client CachesClient) CreatePreparer(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + cache.ID = nil + cache.Name = nil + cache.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.StorageCache/caches/{cacheName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if cache != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(cache)) + } + 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 CachesClient) CreateSender(req *http.Request) (future CachesCreateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 CachesClient) CreateResponder(resp *http.Response) (result Cache, 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 schedules a Cache for deletion. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Delete(ctx context.Context, resourceGroupName string, cacheName string) (result CachesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client CachesClient) DeletePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}", 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 CachesClient) DeleteSender(req *http.Request) (future CachesDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 CachesClient) DeleteResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Flush tells a cache to write all dirty data to the StorageTarget(s). During the flush, clients will see errors +// returned until the flush is complete. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Flush(ctx context.Context, resourceGroupName string, cacheName string) (result CachesFlushFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Flush") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Flush", err.Error()) + } + + req, err := client.FlushPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Flush", nil, "Failure preparing request") + return + } + + result, err = client.FlushSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Flush", result.Response(), "Failure sending request") + return + } + + return +} + +// FlushPreparer prepares the Flush request. +func (client CachesClient) FlushPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// FlushSender sends the Flush request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) FlushSender(req *http.Request) (future CachesFlushFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// FlushResponder handles the response to the Flush request. The method always +// closes the http.Response Body. +func (client CachesClient) FlushResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get returns a Cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Get(ctx context.Context, resourceGroupName string, cacheName string) (result Cache, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CachesClient) GetPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}", 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 CachesClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CachesClient) GetResponder(resp *http.Response) (result Cache, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List returns all Caches the user has access to under a subscription. +func (client CachesClient) List(ctx context.Context) (result CachesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.List") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", resp, "Failure sending request") + return + } + + result.clr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client CachesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches", 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 CachesClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CachesClient) ListResponder(resp *http.Response) (result CachesListResult, 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 CachesClient) listNextResults(ctx context.Context, lastResults CachesListResult) (result CachesListResult, err error) { + req, err := lastResults.cachesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "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, "storagecache.CachesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client CachesClient) ListComplete(ctx context.Context) (result CachesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup returns all Caches the user has access to under a resource group and subscription. +// Parameters: +// resourceGroupName - target resource group. +func (client CachesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result CachesListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.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, "storagecache.CachesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client CachesClient) 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 = "2019-08-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.StorageCache/caches", 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 CachesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client CachesClient) ListByResourceGroupResponder(resp *http.Response) (result CachesListResult, 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 CachesClient) listByResourceGroupNextResults(ctx context.Context, lastResults CachesListResult) (result CachesListResult, err error) { + req, err := lastResults.cachesListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.CachesClient", "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, "storagecache.CachesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client CachesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result CachesListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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 +} + +// Start tells a Stopped state cache to transition to Active state. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Start(ctx context.Context, resourceGroupName string, cacheName string) (result CachesStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Start") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Start", err.Error()) + } + + req, err := client.StartPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Start", result.Response(), "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client CachesClient) StartPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) StartSender(req *http.Request) (future CachesStartFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client CachesClient) StartResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Stop tells an Active cache to transition to Stopped state. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) Stop(ctx context.Context, resourceGroupName string, cacheName string) (result CachesStopFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.Stop") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Stop", err.Error()) + } + + req, err := client.StopPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Stop", nil, "Failure preparing request") + return + } + + result, err = client.StopSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Stop", result.Response(), "Failure sending request") + return + } + + return +} + +// StopPreparer prepares the Stop request. +func (client CachesClient) StopPreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) StopSender(req *http.Request) (future CachesStopFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client CachesClient) StopResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update a Cache instance. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// cache - object containing the user selectable properties of the new cache. If read-only properties are +// included, they must match the existing values of those properties. +func (client CachesClient) Update(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (result Cache, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, cacheName, cache) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client CachesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + cache.ID = nil + cache.Name = nil + cache.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if cache != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(cache)) + } + 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 CachesClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client CachesClient) UpdateResponder(resp *http.Response) (result Cache, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpgradeFirmware tells a cache to upgrade its firmware. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client CachesClient) UpgradeFirmware(ctx context.Context, resourceGroupName string, cacheName string) (result CachesUpgradeFirmwareFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.UpgradeFirmware") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "UpgradeFirmware", err.Error()) + } + + req, err := client.UpgradeFirmwarePreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "UpgradeFirmware", nil, "Failure preparing request") + return + } + + result, err = client.UpgradeFirmwareSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "UpgradeFirmware", result.Response(), "Failure sending request") + return + } + + return +} + +// UpgradeFirmwarePreparer prepares the UpgradeFirmware request. +func (client CachesClient) UpgradeFirmwarePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpgradeFirmwareSender sends the UpgradeFirmware request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) UpgradeFirmwareSender(req *http.Request) (future CachesUpgradeFirmwareFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpgradeFirmwareResponder handles the response to the UpgradeFirmware request. The method always +// closes the http.Response Body. +func (client CachesClient) UpgradeFirmwareResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/storagecache/mgmt/2019-08/storagecache/client.go b/services/preview/storagecache/mgmt/2019-08/storagecache/client.go new file mode 100644 index 000000000000..1a9233396c35 --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/client.go @@ -0,0 +1,52 @@ +// Package storagecache implements the Azure ARM Storagecache service API version 2019-08-01-preview. +// +// A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest +// storage (referred to as "Storage Targets"). These operations allow you to manage caches. +package storagecache + +// 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 Storagecache + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Storagecache. +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/storagecache/mgmt/2019-08/storagecache/models.go b/services/preview/storagecache/mgmt/2019-08/storagecache/models.go new file mode 100644 index 000000000000..8796488d304c --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/models.go @@ -0,0 +1,1480 @@ +package storagecache + +// 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/storagecache/mgmt/2019-08/storagecache" + +// FirmwareStatusType enumerates the values for firmware status type. +type FirmwareStatusType string + +const ( + // Available ... + Available FirmwareStatusType = "available" + // Unavailable ... + Unavailable FirmwareStatusType = "unavailable" +) + +// PossibleFirmwareStatusTypeValues returns an array of possible values for the FirmwareStatusType const type. +func PossibleFirmwareStatusTypeValues() []FirmwareStatusType { + return []FirmwareStatusType{Available, Unavailable} +} + +// HealthStateType enumerates the values for health state type. +type HealthStateType string + +const ( + // Degraded ... + Degraded HealthStateType = "Degraded" + // Down ... + Down HealthStateType = "Down" + // Flushing ... + Flushing HealthStateType = "Flushing" + // Healthy ... + Healthy HealthStateType = "Healthy" + // Stopped ... + Stopped HealthStateType = "Stopped" + // Stopping ... + Stopping HealthStateType = "Stopping" + // Transitioning ... + Transitioning HealthStateType = "Transitioning" + // Unknown ... + Unknown HealthStateType = "Unknown" + // Upgrading ... + Upgrading HealthStateType = "Upgrading" +) + +// PossibleHealthStateTypeValues returns an array of possible values for the HealthStateType const type. +func PossibleHealthStateTypeValues() []HealthStateType { + return []HealthStateType{Degraded, Down, Flushing, Healthy, Stopped, Stopping, Transitioning, Unknown, Upgrading} +} + +// ProvisioningStateType enumerates the values for provisioning state type. +type ProvisioningStateType string + +const ( + // Cancelled ... + Cancelled ProvisioningStateType = "Cancelled" + // Creating ... + Creating ProvisioningStateType = "Creating" + // Deleting ... + Deleting ProvisioningStateType = "Deleting" + // Failed ... + Failed ProvisioningStateType = "Failed" + // Succeeded ... + Succeeded ProvisioningStateType = "Succeeded" + // Updating ... + Updating ProvisioningStateType = "Updating" +) + +// PossibleProvisioningStateTypeValues returns an array of possible values for the ProvisioningStateType const type. +func PossibleProvisioningStateTypeValues() []ProvisioningStateType { + return []ProvisioningStateType{Cancelled, Creating, Deleting, Failed, Succeeded, Updating} +} + +// ReasonCode enumerates the values for reason code. +type ReasonCode string + +const ( + // NotAvailableForSubscription ... + NotAvailableForSubscription ReasonCode = "NotAvailableForSubscription" + // QuotaID ... + QuotaID ReasonCode = "QuotaId" +) + +// PossibleReasonCodeValues returns an array of possible values for the ReasonCode const type. +func PossibleReasonCodeValues() []ReasonCode { + return []ReasonCode{NotAvailableForSubscription, QuotaID} +} + +// StorageTargetType enumerates the values for storage target type. +type StorageTargetType string + +const ( + // StorageTargetTypeClfs ... + StorageTargetTypeClfs StorageTargetType = "clfs" + // StorageTargetTypeNfs3 ... + StorageTargetTypeNfs3 StorageTargetType = "nfs3" + // StorageTargetTypeUnknown ... + StorageTargetTypeUnknown StorageTargetType = "unknown" +) + +// PossibleStorageTargetTypeValues returns an array of possible values for the StorageTargetType const type. +func PossibleStorageTargetTypeValues() []StorageTargetType { + return []StorageTargetType{StorageTargetTypeClfs, StorageTargetTypeNfs3, StorageTargetTypeUnknown} +} + +// APIOperation REST API operation description: see +// https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/openapi-authoring-automated-guidelines.md#r3023-operationsapiimplementation +type APIOperation struct { + // Display - The object that represents the operation. + Display *APIOperationDisplay `json:"display,omitempty"` + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` +} + +// APIOperationDisplay the object that represents the operation. +type APIOperationDisplay struct { + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + // Provider - Service provider: Microsoft.StorageCache + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: cache, etc. + Resource *string `json:"resource,omitempty"` +} + +// APIOperationListResult result of the request to list Resource Provider operations. It contains a list of +// operations and a URL link to get the next set of results. +type APIOperationListResult struct { + autorest.Response `json:"-"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + // Value - List of Resource Provider operations supported by the Microsoft.StorageCache resource provider. + Value *[]APIOperation `json:"value,omitempty"` +} + +// APIOperationListResultIterator provides access to a complete listing of APIOperation values. +type APIOperationListResultIterator struct { + i int + page APIOperationListResultPage +} + +// 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 *APIOperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationListResultIterator.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 *APIOperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APIOperationListResultIterator) 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 APIOperationListResultIterator) Response() APIOperationListResult { + 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 APIOperationListResultIterator) Value() APIOperation { + if !iter.page.NotDone() { + return APIOperation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APIOperationListResultIterator type. +func NewAPIOperationListResultIterator(page APIOperationListResultPage) APIOperationListResultIterator { + return APIOperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aolr APIOperationListResult) IsEmpty() bool { + return aolr.Value == nil || len(*aolr.Value) == 0 +} + +// aPIOperationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aolr APIOperationListResult) aPIOperationListResultPreparer(ctx context.Context) (*http.Request, error) { + if aolr.NextLink == nil || len(to.String(aolr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aolr.NextLink))) +} + +// APIOperationListResultPage contains a page of APIOperation values. +type APIOperationListResultPage struct { + fn func(context.Context, APIOperationListResult) (APIOperationListResult, error) + aolr APIOperationListResult +} + +// 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 *APIOperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIOperationListResultPage.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.aolr) + if err != nil { + return err + } + page.aolr = 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 *APIOperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APIOperationListResultPage) NotDone() bool { + return !page.aolr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APIOperationListResultPage) Response() APIOperationListResult { + return page.aolr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APIOperationListResultPage) Values() []APIOperation { + if page.aolr.IsEmpty() { + return nil + } + return *page.aolr.Value +} + +// Creates a new instance of the APIOperationListResultPage type. +func NewAPIOperationListResultPage(getNextPage func(context.Context, APIOperationListResult) (APIOperationListResult, error)) APIOperationListResultPage { + return APIOperationListResultPage{fn: getNextPage} +} + +// Cache a cache instance. Follows Azure Resource Manager standards: +// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md +type Cache struct { + autorest.Response `json:"-"` + // Tags - ARM tags as name/value pairs. + Tags interface{} `json:"tags,omitempty"` + // ID - READ-ONLY; Fully qualified URL of the cache. + ID *string `json:"id,omitempty"` + // Location - Region name string. + Location *string `json:"location,omitempty"` + // Name - READ-ONLY; Name of cache. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Type for the cache; Microsoft.StorageCache/Cache + Type *string `json:"type,omitempty"` + // CacheProperties - Properties for the cache. + *CacheProperties `json:"properties,omitempty"` + // Sku - Sku for the cache. + Sku *CacheSku `json:"sku,omitempty"` +} + +// MarshalJSON is the custom marshaler for Cache. +func (c Cache) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.Tags != nil { + objectMap["tags"] = c.Tags + } + if c.Location != nil { + objectMap["location"] = c.Location + } + if c.CacheProperties != nil { + objectMap["properties"] = c.CacheProperties + } + if c.Sku != nil { + objectMap["sku"] = c.Sku + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Cache struct. +func (c *Cache) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags interface{} + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + c.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + c.Location = &location + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + case "properties": + if v != nil { + var cacheProperties CacheProperties + err = json.Unmarshal(*v, &cacheProperties) + if err != nil { + return err + } + c.CacheProperties = &cacheProperties + } + case "sku": + if v != nil { + var sku CacheSku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + c.Sku = &sku + } + } + } + + return nil +} + +// CacheHealth an indication of cache health. Gives more information about health than just that related +// to provisioning. +type CacheHealth struct { + // State - List of cache health states. Possible values include: 'Unknown', 'Healthy', 'Degraded', 'Down', 'Transitioning', 'Stopping', 'Stopped', 'Upgrading', 'Flushing' + State HealthStateType `json:"state,omitempty"` + // StatusDescription - Describes explanation of state. + StatusDescription *string `json:"statusDescription,omitempty"` +} + +// CacheProperties properties for the cache. +type CacheProperties struct { + // CacheSizeGB - The size of this cache's cache, in GB. + CacheSizeGB *int32 `json:"cacheSizeGB,omitempty"` + // Health - READ-ONLY; Health of the cache. + Health *CacheHealth `json:"health,omitempty"` + // MountAddresses - READ-ONLY; Array of IP addresses that can be used by clients mounting this Cache. + MountAddresses *[]string `json:"mountAddresses,omitempty"` + // ProvisioningState - ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Creating', 'Deleting', 'Updating' + ProvisioningState ProvisioningStateType `json:"provisioningState,omitempty"` + // Subnet - Subnet used for the cache. + Subnet *string `json:"subnet,omitempty"` + // UpgradeStatus - Upgrade status of the cache. + UpgradeStatus *CacheUpgradeStatus `json:"upgradeStatus,omitempty"` +} + +// CachesCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesCreateFuture) Result(client CachesClient) (c Cache, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesCreateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesDeleteFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.DeleteResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesDeleteFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesFlushFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesFlushFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesFlushFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesFlushFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesFlushFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.FlushResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesFlushFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CacheSku sku for the cache. +type CacheSku struct { + // Name - Sku name for this cache. + Name *string `json:"name,omitempty"` +} + +// CachesListResult result of the request to list caches. It contains a list of caches and a URL link to +// get the next set of results. +type CachesListResult struct { + autorest.Response `json:"-"` + // NextLink - URL to get the next set of cache list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + // Value - List of caches. + Value *[]Cache `json:"value,omitempty"` +} + +// CachesListResultIterator provides access to a complete listing of Cache values. +type CachesListResultIterator struct { + i int + page CachesListResultPage +} + +// 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 *CachesListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesListResultIterator.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 *CachesListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CachesListResultIterator) 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 CachesListResultIterator) Response() CachesListResult { + 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 CachesListResultIterator) Value() Cache { + if !iter.page.NotDone() { + return Cache{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CachesListResultIterator type. +func NewCachesListResultIterator(page CachesListResultPage) CachesListResultIterator { + return CachesListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CachesListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// cachesListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CachesListResult) cachesListResultPreparer(ctx context.Context) (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CachesListResultPage contains a page of Cache values. +type CachesListResultPage struct { + fn func(context.Context, CachesListResult) (CachesListResult, error) + clr CachesListResult +} + +// 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 *CachesListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesListResultPage.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.clr) + if err != nil { + return err + } + page.clr = 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 *CachesListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CachesListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CachesListResultPage) Response() CachesListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CachesListResultPage) Values() []Cache { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the CachesListResultPage type. +func NewCachesListResultPage(getNextPage func(context.Context, CachesListResult) (CachesListResult, error)) CachesListResultPage { + return CachesListResultPage{fn: getNextPage} +} + +// CachesStartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesStartFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesStartFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesStartFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.StartResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStartFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesStopFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesStopFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesStopFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStopFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesStopFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.StopResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesStopFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CachesUpgradeFirmwareFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CachesUpgradeFirmwareFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CachesUpgradeFirmwareFuture) Result(client CachesClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesUpgradeFirmwareFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesUpgradeFirmwareFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.UpgradeFirmwareResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesUpgradeFirmwareFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// CacheUpgradeStatus properties describing the software upgrade state of the cache +type CacheUpgradeStatus struct { + // CurrentFirmwareVersion - READ-ONLY; Version string of the firmware currently installed on this cache. + CurrentFirmwareVersion *string `json:"currentFirmwareVersion,omitempty"` + // FirmwareUpdateStatus - READ-ONLY; True if there is a firmware update ready to install on this cache. The firmware will automatically be installed after firmwareUpdateDeadline if not triggered earlier via the upgrade operation. Possible values include: 'Available', 'Unavailable' + FirmwareUpdateStatus FirmwareStatusType `json:"firmwareUpdateStatus,omitempty"` + // FirmwareUpdateDeadline - READ-ONLY; Time at which the pending firmware update will automatically be installed on the cache. + FirmwareUpdateDeadline *date.Time `json:"firmwareUpdateDeadline,omitempty"` + // LastFirmwareUpdate - READ-ONLY; Time of the last successful firmware update. + LastFirmwareUpdate *date.Time `json:"lastFirmwareUpdate,omitempty"` + // PendingFirmwareVersion - READ-ONLY; When firmwareUpdateAvailable is true, this field holds the version string for the update. + PendingFirmwareVersion *string `json:"pendingFirmwareVersion,omitempty"` +} + +// ClfsTarget storage container for use as a CLFS StorageTarget. +type ClfsTarget struct { + // Target - URL of storage container. + Target *string `json:"target,omitempty"` +} + +// CloudError an error response. +type CloudError struct { + // Error - The body of the error. + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody an error response. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Details - A list of additional details about the error. + Details *[]CloudErrorBody `json:"details,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// NamespaceJunction a namespace junction. +type NamespaceJunction struct { + // NamespacePath - Namespace path on a cache for a storage target. + NamespacePath *string `json:"namespacePath,omitempty"` + // TargetPath - Path in storage target to which namespacePath points. + TargetPath *string `json:"targetPath,omitempty"` + // NfsExport - NFS export where targetPath exists. + NfsExport *string `json:"nfsExport,omitempty"` +} + +// Nfs3Target an NFS mount point for use as a StorageTarget. +type Nfs3Target struct { + // Target - IP or name of an NFS Storage Target host, ie: 10.0.44.44 + Target *string `json:"target,omitempty"` + // UsageModel - Identifies the primary usage model to be used for this storage target. GET choices from .../usageModels + UsageModel *string `json:"usageModel,omitempty"` +} + +// ResourceSku a resource SKU +type ResourceSku struct { + // ResourceType - READ-ONLY; The type of resource the sku applies to. + ResourceType *string `json:"resourceType,omitempty"` + // Capabilities - A list of capabilities of this SKU, such as throughput or ops/sec + Capabilities *[]ResourceSkuCapabilities `json:"capabilities,omitempty"` + // Locations - READ-ONLY; The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). + Locations *[]string `json:"locations,omitempty"` + // LocationInfo - The set of locations that the SKU is available. + LocationInfo *[]ResourceSkuLocationInfo `json:"locationInfo,omitempty"` + // Name - The name of this sku. + Name *string `json:"name,omitempty"` + // Restrictions - The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. + Restrictions *[]Restriction `json:"restrictions,omitempty"` +} + +// ResourceSkuCapabilities a resource SKU capability. +type ResourceSkuCapabilities struct { + // Name - Name of a capability, such as ops/sec + Name *string `json:"name,omitempty"` + // Value - Quantity, if the capability is measured by quantity + Value *string `json:"value,omitempty"` +} + +// ResourceSkuLocationInfo resource SKU location information. +type ResourceSkuLocationInfo struct { + // Location - Location where this Sku is available + Location *string `json:"location,omitempty"` + // Zones - Zones if any. + Zones *[]string `json:"zones,omitempty"` +} + +// ResourceSkusResult the response from the List Cache SKUs operation. +type ResourceSkusResult struct { + autorest.Response `json:"-"` + // NextLink - The uri to fetch the next page of cache Skus. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; The list of skus available for the subscription. + Value *[]ResourceSku `json:"value,omitempty"` +} + +// ResourceSkusResultIterator provides access to a complete listing of ResourceSku values. +type ResourceSkusResultIterator struct { + i int + page ResourceSkusResultPage +} + +// 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 *ResourceSkusResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusResultIterator.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 *ResourceSkusResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceSkusResultIterator) 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 ResourceSkusResultIterator) Response() ResourceSkusResult { + 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 ResourceSkusResultIterator) Value() ResourceSku { + if !iter.page.NotDone() { + return ResourceSku{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceSkusResultIterator type. +func NewResourceSkusResultIterator(page ResourceSkusResultPage) ResourceSkusResultIterator { + return ResourceSkusResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rsr ResourceSkusResult) IsEmpty() bool { + return rsr.Value == nil || len(*rsr.Value) == 0 +} + +// resourceSkusResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rsr ResourceSkusResult) resourceSkusResultPreparer(ctx context.Context) (*http.Request, error) { + if rsr.NextLink == nil || len(to.String(rsr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rsr.NextLink))) +} + +// ResourceSkusResultPage contains a page of ResourceSku values. +type ResourceSkusResultPage struct { + fn func(context.Context, ResourceSkusResult) (ResourceSkusResult, error) + rsr ResourceSkusResult +} + +// 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 *ResourceSkusResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusResultPage.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.rsr) + if err != nil { + return err + } + page.rsr = 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 *ResourceSkusResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceSkusResultPage) NotDone() bool { + return !page.rsr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceSkusResultPage) Response() ResourceSkusResult { + return page.rsr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceSkusResultPage) Values() []ResourceSku { + if page.rsr.IsEmpty() { + return nil + } + return *page.rsr.Value +} + +// Creates a new instance of the ResourceSkusResultPage type. +func NewResourceSkusResultPage(getNextPage func(context.Context, ResourceSkusResult) (ResourceSkusResult, error)) ResourceSkusResultPage { + return ResourceSkusResultPage{fn: getNextPage} +} + +// Restriction the restriction because of which SKU cannot be used. +type Restriction struct { + // Type - READ-ONLY; The type of restrictions. As of now only possible value for this is location. + Type *string `json:"type,omitempty"` + // Values - READ-ONLY; The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. + Values *[]string `json:"values,omitempty"` + // ReasonCode - The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription' + ReasonCode ReasonCode `json:"reasonCode,omitempty"` +} + +// SetObject ... +type SetObject struct { + autorest.Response `json:"-"` + Value interface{} `json:"value,omitempty"` +} + +// StorageTarget a storage system being cached by a Cache. +type StorageTarget struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; A fully qualified URL. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; Resource Id + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Type for the storage target; Microsoft.StorageCache/Cache/StorageTarget + Type *string `json:"type,omitempty"` + // StorageTargetProperties - Properties of the storage target. + *StorageTargetProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for StorageTarget. +func (st StorageTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if st.StorageTargetProperties != nil { + objectMap["properties"] = st.StorageTargetProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for StorageTarget struct. +func (st *StorageTarget) 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 "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + st.Name = &name + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + st.ID = &ID + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + st.Type = &typeVar + } + case "properties": + if v != nil { + var storageTargetProperties StorageTargetProperties + err = json.Unmarshal(*v, &storageTargetProperties) + if err != nil { + return err + } + st.StorageTargetProperties = &storageTargetProperties + } + } + } + + return nil +} + +// StorageTargetProperties properties of the storage target. +type StorageTargetProperties struct { + // Junctions - List of cache namespace to target namespace associations. + Junctions *[]NamespaceJunction `json:"junctions,omitempty"` + // TargetType - Type for storage target. Possible values include: 'StorageTargetTypeNfs3', 'StorageTargetTypeClfs', 'StorageTargetTypeUnknown' + TargetType StorageTargetType `json:"targetType,omitempty"` + // ProvisioningState - ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: 'Succeeded', 'Failed', 'Cancelled', 'Creating', 'Deleting', 'Updating' + ProvisioningState ProvisioningStateType `json:"provisioningState,omitempty"` + // Nfs3 - Properties when nfs3 target. + Nfs3 *Nfs3Target `json:"nfs3,omitempty"` + // Clfs - Properties when clfs target. + Clfs *ClfsTarget `json:"clfs,omitempty"` + // Unknown - Properties when unknown target. + Unknown *UnknownTarget `json:"unknown,omitempty"` +} + +// StorageTargetsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type StorageTargetsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *StorageTargetsCreateFuture) Result(client StorageTargetsClient) (st StorageTarget, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.StorageTargetsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if st.Response.Response, err = future.GetResult(sender); err == nil && st.Response.Response.StatusCode != http.StatusNoContent { + st, err = client.CreateResponder(st.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsCreateFuture", "Result", st.Response.Response, "Failure responding to request") + } + } + return +} + +// StorageTargetsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type StorageTargetsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *StorageTargetsDeleteFuture) Result(client StorageTargetsClient) (so SetObject, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.StorageTargetsDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { + so, err = client.DeleteResponder(so.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsDeleteFuture", "Result", so.Response.Response, "Failure responding to request") + } + } + return +} + +// StorageTargetsResult a list of storage targets. +type StorageTargetsResult struct { + autorest.Response `json:"-"` + // NextLink - The uri to fetch the next page of storage targets. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of storage targets defined for the cache. + Value *[]StorageTarget `json:"value,omitempty"` +} + +// StorageTargetsResultIterator provides access to a complete listing of StorageTarget values. +type StorageTargetsResultIterator struct { + i int + page StorageTargetsResultPage +} + +// 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 *StorageTargetsResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsResultIterator.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 *StorageTargetsResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter StorageTargetsResultIterator) 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 StorageTargetsResultIterator) Response() StorageTargetsResult { + 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 StorageTargetsResultIterator) Value() StorageTarget { + if !iter.page.NotDone() { + return StorageTarget{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the StorageTargetsResultIterator type. +func NewStorageTargetsResultIterator(page StorageTargetsResultPage) StorageTargetsResultIterator { + return StorageTargetsResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (str StorageTargetsResult) IsEmpty() bool { + return str.Value == nil || len(*str.Value) == 0 +} + +// storageTargetsResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (str StorageTargetsResult) storageTargetsResultPreparer(ctx context.Context) (*http.Request, error) { + if str.NextLink == nil || len(to.String(str.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(str.NextLink))) +} + +// StorageTargetsResultPage contains a page of StorageTarget values. +type StorageTargetsResultPage struct { + fn func(context.Context, StorageTargetsResult) (StorageTargetsResult, error) + str StorageTargetsResult +} + +// 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 *StorageTargetsResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsResultPage.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.str) + if err != nil { + return err + } + page.str = 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 *StorageTargetsResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page StorageTargetsResultPage) NotDone() bool { + return !page.str.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page StorageTargetsResultPage) Response() StorageTargetsResult { + return page.str +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page StorageTargetsResultPage) Values() []StorageTarget { + if page.str.IsEmpty() { + return nil + } + return *page.str.Value +} + +// Creates a new instance of the StorageTargetsResultPage type. +func NewStorageTargetsResultPage(getNextPage func(context.Context, StorageTargetsResult) (StorageTargetsResult, error)) StorageTargetsResultPage { + return StorageTargetsResultPage{fn: getNextPage} +} + +// UnknownTarget storage container for use as a Unknown StorageTarget. +type UnknownTarget struct { + // UnknownMap - Dictionary of string->string pairs containing information about the StorageTarget. + UnknownMap map[string]*string `json:"unknownMap"` +} + +// MarshalJSON is the custom marshaler for UnknownTarget. +func (ut UnknownTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ut.UnknownMap != nil { + objectMap["unknownMap"] = ut.UnknownMap + } + return json.Marshal(objectMap) +} + +// UsageModel a usage model. +type UsageModel struct { + // Display - Localized information describing this usage model. + Display *UsageModelDisplay `json:"display,omitempty"` + // ModelName - Non localized keyword naming this usage model. + ModelName *string `json:"modelName,omitempty"` + // TargetType - The type of Storage Target to which this model is applicable (only nfs for now) + TargetType *string `json:"targetType,omitempty"` +} + +// UsageModelDisplay localized information describing this usage model. +type UsageModelDisplay struct { + // Description - String to display for this usage model. + Description *string `json:"description,omitempty"` +} + +// UsageModelsResult a list of cache usage models. +type UsageModelsResult struct { + autorest.Response `json:"-"` + // NextLink - The uri to fetch the next page of cache usage models. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of usage models available for the subscription. + Value *[]UsageModel `json:"value,omitempty"` +} + +// UsageModelsResultIterator provides access to a complete listing of UsageModel values. +type UsageModelsResultIterator struct { + i int + page UsageModelsResultPage +} + +// 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 *UsageModelsResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsResultIterator.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 *UsageModelsResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter UsageModelsResultIterator) 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 UsageModelsResultIterator) Response() UsageModelsResult { + 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 UsageModelsResultIterator) Value() UsageModel { + if !iter.page.NotDone() { + return UsageModel{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the UsageModelsResultIterator type. +func NewUsageModelsResultIterator(page UsageModelsResultPage) UsageModelsResultIterator { + return UsageModelsResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (umr UsageModelsResult) IsEmpty() bool { + return umr.Value == nil || len(*umr.Value) == 0 +} + +// usageModelsResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (umr UsageModelsResult) usageModelsResultPreparer(ctx context.Context) (*http.Request, error) { + if umr.NextLink == nil || len(to.String(umr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(umr.NextLink))) +} + +// UsageModelsResultPage contains a page of UsageModel values. +type UsageModelsResultPage struct { + fn func(context.Context, UsageModelsResult) (UsageModelsResult, error) + umr UsageModelsResult +} + +// 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 *UsageModelsResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsResultPage.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.umr) + if err != nil { + return err + } + page.umr = 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 *UsageModelsResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page UsageModelsResultPage) NotDone() bool { + return !page.umr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page UsageModelsResultPage) Response() UsageModelsResult { + return page.umr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page UsageModelsResultPage) Values() []UsageModel { + if page.umr.IsEmpty() { + return nil + } + return *page.umr.Value +} + +// Creates a new instance of the UsageModelsResultPage type. +func NewUsageModelsResultPage(getNextPage func(context.Context, UsageModelsResult) (UsageModelsResult, error)) UsageModelsResultPage { + return UsageModelsResultPage{fn: getNextPage} +} diff --git a/services/preview/storagecache/mgmt/2019-08/storagecache/operations.go b/services/preview/storagecache/mgmt/2019-08/storagecache/operations.go new file mode 100644 index 000000000000..56a2449617fb --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/operations.go @@ -0,0 +1,148 @@ +package storagecache + +// 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 a Storage Cache provides scalable caching service for NAS clients, serving data from either +// NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +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 lists all of the available RP operations. +func (client OperationsClient) List(ctx context.Context) (result APIOperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.aolr.Response.Response != nil { + sc = result.aolr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aolr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.aolr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.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 = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.StorageCache/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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result APIOperationListResult, 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 APIOperationListResult) (result APIOperationListResult, err error) { + req, err := lastResults.aPIOperationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.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, "storagecache.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.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 APIOperationListResultIterator, 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/storagecache/mgmt/2019-08/storagecache/skus.go b/services/preview/storagecache/mgmt/2019-08/storagecache/skus.go new file mode 100644 index 000000000000..4bc65998a2a0 --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/skus.go @@ -0,0 +1,152 @@ +package storagecache + +// 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" +) + +// SkusClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 +// or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +type SkusClient struct { + BaseClient +} + +// NewSkusClient creates an instance of the SkusClient client. +func NewSkusClient(subscriptionID string) SkusClient { + return NewSkusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSkusClientWithBaseURI creates an instance of the SkusClient client. +func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient { + return SkusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the list of StorageCache.Cache SKUs available to this subscription. +func (client SkusClient) List(ctx context.Context) (result ResourceSkusResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.List") + defer func() { + sc := -1 + if result.rsr.Response.Response != nil { + sc = result.rsr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rsr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "List", resp, "Failure sending request") + return + } + + result.rsr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/skus", 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 SkusClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SkusClient) ListResponder(resp *http.Response) (result ResourceSkusResult, 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 SkusClient) listNextResults(ctx context.Context, lastResults ResourceSkusResult) (result ResourceSkusResult, err error) { + req, err := lastResults.resourceSkusResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.SkusClient", "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, "storagecache.SkusClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.SkusClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SkusClient) ListComplete(ctx context.Context) (result ResourceSkusResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SkusClient.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/storagecache/mgmt/2019-08/storagecache/storagecacheapi/interfaces.go b/services/preview/storagecache/mgmt/2019-08/storagecache/storagecacheapi/interfaces.go new file mode 100644 index 000000000000..6e33b7f8e5fb --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/storagecacheapi/interfaces.go @@ -0,0 +1,71 @@ +package storagecacheapi + +// 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/storagecache/mgmt/2019-08/storagecache" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result storagecache.APIOperationListResultPage, err error) +} + +var _ OperationsClientAPI = (*storagecache.OperationsClient)(nil) + +// SkusClientAPI contains the set of methods on the SkusClient type. +type SkusClientAPI interface { + List(ctx context.Context) (result storagecache.ResourceSkusResultPage, err error) +} + +var _ SkusClientAPI = (*storagecache.SkusClient)(nil) + +// UsageModelsClientAPI contains the set of methods on the UsageModelsClient type. +type UsageModelsClientAPI interface { + List(ctx context.Context) (result storagecache.UsageModelsResultPage, err error) +} + +var _ UsageModelsClientAPI = (*storagecache.UsageModelsClient)(nil) + +// CachesClientAPI contains the set of methods on the CachesClient type. +type CachesClientAPI interface { + Create(ctx context.Context, resourceGroupName string, cacheName string, cache *storagecache.Cache) (result storagecache.CachesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesDeleteFuture, err error) + Flush(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesFlushFuture, err error) + Get(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.Cache, err error) + List(ctx context.Context) (result storagecache.CachesListResultPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result storagecache.CachesListResultPage, err error) + Start(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesStartFuture, err error) + Stop(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesStopFuture, err error) + Update(ctx context.Context, resourceGroupName string, cacheName string, cache *storagecache.Cache) (result storagecache.Cache, err error) + UpgradeFirmware(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesUpgradeFirmwareFuture, err error) +} + +var _ CachesClientAPI = (*storagecache.CachesClient)(nil) + +// StorageTargetsClientAPI contains the set of methods on the StorageTargetsClient type. +type StorageTargetsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *storagecache.StorageTarget) (result storagecache.StorageTargetsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result storagecache.StorageTargetsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result storagecache.StorageTarget, err error) + ListByCache(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.StorageTargetsResultPage, err error) + Update(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *storagecache.StorageTarget) (result storagecache.StorageTarget, err error) +} + +var _ StorageTargetsClientAPI = (*storagecache.StorageTargetsClient)(nil) diff --git a/services/preview/storagecache/mgmt/2019-08/storagecache/storagetargets.go b/services/preview/storagecache/mgmt/2019-08/storagecache/storagetargets.go new file mode 100644 index 000000000000..18ef27d16dd5 --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/storagetargets.go @@ -0,0 +1,543 @@ +package storagecache + +// 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" +) + +// StorageTargetsClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from +// either NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage +// caches. +type StorageTargetsClient struct { + BaseClient +} + +// NewStorageTargetsClient creates an instance of the StorageTargetsClient client. +func NewStorageTargetsClient(subscriptionID string) StorageTargetsClient { + return NewStorageTargetsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStorageTargetsClientWithBaseURI creates an instance of the StorageTargetsClient client. +func NewStorageTargetsClientWithBaseURI(baseURI string, subscriptionID string) StorageTargetsClient { + return StorageTargetsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create create/update a storage target. This operation is allowed at any time, but if the cache is down or +// unhealthy, the actual creation/modification of the storage target may be delayed until the cache is healthy again. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +// storagetarget - object containing the definition of a storage target. +func (client StorageTargetsClient) Create(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (result StorageTargetsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storagetarget, + Constraints: []validation.Constraint{{Target: "storagetarget", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties.Nfs3", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties.Nfs3.Target", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "storagetarget.StorageTargetProperties.Nfs3.Target", Name: validation.Pattern, Rule: `^[-.0-9a-zA-Z]+$`, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, cacheName, storageTargetName, storagetarget) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client StorageTargetsClient) CreatePreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + storagetarget.Name = nil + storagetarget.ID = nil + storagetarget.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.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if storagetarget != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(storagetarget)) + } + 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 StorageTargetsClient) CreateSender(req *http.Request) (future StorageTargetsCreateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 StorageTargetsClient) CreateResponder(resp *http.Response) (result StorageTarget, 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 removes a storage target from a cache. This operation is allowed at any time, but if the cache is down or +// unhealthy, the actual removal of the storage target may be delayed until the cache is healthy again. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +func (client StorageTargetsClient) Delete(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result StorageTargetsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, cacheName, storageTargetName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client StorageTargetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", 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 StorageTargetsClient) DeleteSender(req *http.Request) (future StorageTargetsDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + 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 StorageTargetsClient) DeleteResponder(resp *http.Response) (result SetObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get returns a storage target from a cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +func (client StorageTargetsClient) Get(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result StorageTarget, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, cacheName, storageTargetName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client StorageTargetsClient) GetPreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", 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 StorageTargetsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) GetResponder(resp *http.Response) (result StorageTarget, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByCache returns the StorageTargets for this cache in the subscription and resource group. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +func (client StorageTargetsClient) ListByCache(ctx context.Context, resourceGroupName string, cacheName string) (result StorageTargetsResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.ListByCache") + defer func() { + sc := -1 + if result.str.Response.Response != nil { + sc = result.str.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "ListByCache", err.Error()) + } + + result.fn = client.listByCacheNextResults + req, err := client.ListByCachePreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "ListByCache", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCacheSender(req) + if err != nil { + result.str.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "ListByCache", resp, "Failure sending request") + return + } + + result.str, err = client.ListByCacheResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "ListByCache", resp, "Failure responding to request") + } + + return +} + +// ListByCachePreparer prepares the ListByCache request. +func (client StorageTargetsClient) ListByCachePreparer(ctx context.Context, resourceGroupName string, cacheName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-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.StorageCache/caches/{cacheName}/storageTargets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByCacheSender sends the ListByCache request. The method will close the +// http.Response Body if it receives an error. +func (client StorageTargetsClient) ListByCacheSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByCacheResponder handles the response to the ListByCache request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) ListByCacheResponder(resp *http.Response) (result StorageTargetsResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByCacheNextResults retrieves the next set of results, if any. +func (client StorageTargetsClient) listByCacheNextResults(ctx context.Context, lastResults StorageTargetsResult) (result StorageTargetsResult, err error) { + req, err := lastResults.storageTargetsResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "listByCacheNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCacheSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "listByCacheNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCacheResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "listByCacheNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCacheComplete enumerates all values, automatically crossing page boundaries as required. +func (client StorageTargetsClient) ListByCacheComplete(ctx context.Context, resourceGroupName string, cacheName string) (result StorageTargetsResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.ListByCache") + 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.ListByCache(ctx, resourceGroupName, cacheName) + return +} + +// Update update a storage target. This operation is allowed at any time, but if the cache is down or unhealthy, the +// actual creation/modification of the storage target may be delayed until the cache is healthy again. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of cache. +// storageTargetName - name of storage target. +// storagetarget - object containing the definition of a storage target. +func (client StorageTargetsClient) Update(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (result StorageTarget, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.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: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,31}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, cacheName, storageTargetName, storagetarget) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client StorageTargetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "cacheName": autorest.Encode("path", cacheName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "storageTargetName": autorest.Encode("path", storageTargetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + storagetarget.Name = nil + storagetarget.ID = nil + storagetarget.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if storagetarget != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(storagetarget)) + } + 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 StorageTargetsClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) UpdateResponder(resp *http.Response) (result StorageTarget, 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/storagecache/mgmt/2019-08/storagecache/usagemodels.go b/services/preview/storagecache/mgmt/2019-08/storagecache/usagemodels.go new file mode 100644 index 000000000000..7a6eb3ab86f8 --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/usagemodels.go @@ -0,0 +1,152 @@ +package storagecache + +// 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" +) + +// UsageModelsClient is the a Storage Cache provides scalable caching service for NAS clients, serving data from either +// NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage caches. +type UsageModelsClient struct { + BaseClient +} + +// NewUsageModelsClient creates an instance of the UsageModelsClient client. +func NewUsageModelsClient(subscriptionID string) UsageModelsClient { + return NewUsageModelsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewUsageModelsClientWithBaseURI creates an instance of the UsageModelsClient client. +func NewUsageModelsClientWithBaseURI(baseURI string, subscriptionID string) UsageModelsClient { + return UsageModelsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the list of cache Usage Models available to this subscription. +func (client UsageModelsClient) List(ctx context.Context) (result UsageModelsResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsClient.List") + defer func() { + sc := -1 + if result.umr.Response.Response != nil { + sc = result.umr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.umr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "List", resp, "Failure sending request") + return + } + + result.umr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client UsageModelsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-08-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/usageModels", 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 UsageModelsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UsageModelsClient) ListResponder(resp *http.Response) (result UsageModelsResult, 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 UsageModelsClient) listNextResults(ctx context.Context, lastResults UsageModelsResult) (result UsageModelsResult, err error) { + req, err := lastResults.usageModelsResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "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, "storagecache.UsageModelsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.UsageModelsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client UsageModelsClient) ListComplete(ctx context.Context) (result UsageModelsResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/UsageModelsClient.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/storagecache/mgmt/2019-08/storagecache/version.go b/services/preview/storagecache/mgmt/2019-08/storagecache/version.go new file mode 100644 index 000000000000..2d84fa9642e6 --- /dev/null +++ b/services/preview/storagecache/mgmt/2019-08/storagecache/version.go @@ -0,0 +1,30 @@ +package storagecache + +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 + " storagecache/2019-08-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}