From 63a0385b6b9b5ca822271a96504800bda6e1bd9d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 11 Mar 2021 07:40:12 +0000 Subject: [PATCH] CodeGen from PR 13383 in Azure/azure-rest-api-specs add go sdk config for network and storagecache (#13383) --- .../mgmt/2021-03-01/storagecache/CHANGELOG.md | 5 + .../2021-03-01/storagecache/ascoperations.go | 120 + .../mgmt/2021-03-01/storagecache/caches.go | 1182 ++++++++++ .../mgmt/2021-03-01/storagecache/client.go | 53 + .../mgmt/2021-03-01/storagecache/enums.go | 265 +++ .../mgmt/2021-03-01/storagecache/models.go | 2005 +++++++++++++++++ .../2021-03-01/storagecache/operations.go | 152 ++ .../mgmt/2021-03-01/storagecache/skus.go | 156 ++ .../storagecacheapi/interfaces.go | 85 + .../2021-03-01/storagecache/storagetargets.go | 590 +++++ .../2021-03-01/storagecache/usagemodels.go | 156 ++ .../mgmt/2021-03-01/storagecache/version.go | 30 + 12 files changed, 4799 insertions(+) create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/CHANGELOG.md create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/ascoperations.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/caches.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/client.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/enums.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/models.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/operations.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/skus.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/storagecacheapi/interfaces.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/storagetargets.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/usagemodels.go create mode 100644 services/storagecache/mgmt/2021-03-01/storagecache/version.go diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/CHANGELOG.md b/services/storagecache/mgmt/2021-03-01/storagecache/CHANGELOG.md new file mode 100644 index 000000000000..4b30c726d942 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/CHANGELOG.md @@ -0,0 +1,5 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/d9506558e6389e62926ae385f1d625a1376a0f9d/specification/storagecache/resource-manager/readme.md tag: `package-2021-03` + +Code generator + + diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/ascoperations.go b/services/storagecache/mgmt/2021-03-01/storagecache/ascoperations.go new file mode 100644 index 000000000000..d65283dec356 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/ascoperations.go @@ -0,0 +1,120 @@ +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" +) + +// AscOperationsClient 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 AscOperationsClient struct { + BaseClient +} + +// NewAscOperationsClient creates an instance of the AscOperationsClient client. +func NewAscOperationsClient(subscriptionID string) AscOperationsClient { + return NewAscOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAscOperationsClientWithBaseURI creates an instance of the AscOperationsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAscOperationsClientWithBaseURI(baseURI string, subscriptionID string) AscOperationsClient { + return AscOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets the status of an asynchronous operation for the Azure HPC Cache +// Parameters: +// location - the name of the region used to look up the operation. +// operationID - the operation id which uniquely identifies the asynchronous operation. +func (client AscOperationsClient) Get(ctx context.Context, location string, operationID string) (result AscOperation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AscOperationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, location, operationID) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.AscOperationsClient", "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.AscOperationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.AscOperationsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AscOperationsClient) GetPreparer(ctx context.Context, location string, operationID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "operationId": autorest.Encode("path", operationID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/ascOperations/{operationId}", 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 AscOperationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AscOperationsClient) GetResponder(resp *http.Response) (result AscOperation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/caches.go b/services/storagecache/mgmt/2021-03-01/storagecache/caches.go new file mode 100644 index 000000000000..5beb90ecad37 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/caches.go @@ -0,0 +1,1182 @@ +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 using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCachesClientWithBaseURI(baseURI string, subscriptionID string) CachesClient { + return CachesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a Cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +// 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) CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, cache *Cache) (result CachesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}, + {TargetValue: cache, + Constraints: []validation.Constraint{{Target: "cache", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.NetworkSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.NetworkSettings.Mtu", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.NetworkSettings.Mtu", Name: validation.InclusiveMaximum, Rule: int64(1500), Chain: nil}, + {Target: "cache.CacheProperties.NetworkSettings.Mtu", Name: validation.InclusiveMinimum, Rule: int64(576), Chain: nil}, + }}, + }}, + {Target: "cache.CacheProperties.EncryptionSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "cache.CacheProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "cache.CacheProperties.DirectoryServicesSettings", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.PrimaryDNSIPAddress", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.DomainName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.DomainNetBiosName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.CacheNetBiosName", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.CacheNetBiosName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z]{1,15}$`, Chain: nil}}}, + {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.Credentials", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.Credentials.Username", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "cache.CacheProperties.DirectoryServicesSettings.ActiveDirectory.Credentials.Password", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, cacheName, cache) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client CachesClient) CreateOrUpdatePreparer(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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + cache.ID = nil + cache.Name = nil + cache.Type = nil + cache.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if cache != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(cache)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) CreateOrUpdateSender(req *http.Request) (future CachesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CachesClient) (c Cache, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + c.Response.Response, err = future.GetResult(sender) + if c.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesCreateOrUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.CreateOrUpdateResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesCreateOrUpdateFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client CachesClient) CreateOrUpdateResponder(resp *http.Response) (result Cache, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DebugInfo tells a Cache to write generate debug info for support to process. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +func (client CachesClient) DebugInfo(ctx context.Context, resourceGroupName string, cacheName string) (result CachesDebugInfoFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CachesClient.DebugInfo") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.CachesClient", "DebugInfo", err.Error()) + } + + req, err := client.DebugInfoPreparer(ctx, resourceGroupName, cacheName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "DebugInfo", nil, "Failure preparing request") + return + } + + result, err = client.DebugInfoSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesClient", "DebugInfo", nil, "Failure sending request") + return + } + + return +} + +// DebugInfoPreparer prepares the DebugInfo request. +func (client CachesClient) DebugInfoPreparer(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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/debugInfo", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DebugInfoSender sends the DebugInfo request. The method will close the +// http.Response Body if it receives an error. +func (client CachesClient) DebugInfoSender(req *http.Request) (future CachesDebugInfoFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CachesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.CachesDebugInfoFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.CachesDebugInfoFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DebugInfoResponder handles the response to the DebugInfo request. The method always +// closes the http.Response Body. +func (client CachesClient) DebugInfoResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete schedules a Cache for deletion. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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,80}$`, 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", nil, "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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CachesClient) (ar autorest.Response, 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 + } + ar.Response = future.Response() + return + } + 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 autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Flush tells a Cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors +// returned until the flush is complete. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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,80}$`, 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", nil, "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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CachesClient) (ar autorest.Response, 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 + } + ar.Response = future.Response() + return + } + 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 autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a Cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +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,80}$`, 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 + } + + 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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CachesClient) GetResponder(resp *http.Response) (result Cache, err error) { + err = autorest.Respond( + resp, + 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 + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-03-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client CachesClient) ListResponder(resp *http.Response) (result CachesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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. +// 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 + } + if result.clr.hasNextLink() && result.clr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client CachesClient) ListByResourceGroupResponder(resp *http.Response) (result CachesListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client 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. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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,80}$`, 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", nil, "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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CachesClient) (ar autorest.Response, 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 + } + ar.Response = future.Response() + return + } + 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 autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop tells an Active Cache to transition to Stopped state. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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,80}$`, 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", nil, "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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CachesClient) (ar autorest.Response, 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 + } + ar.Response = future.Response() + return + } + 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 autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update update a Cache instance. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +// cache - object containing the user-selectable properties of the 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,80}$`, 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 + } + + 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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + cache.ID = nil + cache.Name = nil + cache.Type = nil + cache.SystemData = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpgradeFirmware upgrade a Cache's firmware if a new version is available. Otherwise, this operation has no effect. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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,80}$`, 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", nil, "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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client CachesClient) (ar autorest.Response, 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 + } + ar.Response = future.Response() + return + } + 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 autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/client.go b/services/storagecache/mgmt/2021-03-01/storagecache/client.go new file mode 100644 index 000000000000..1fedda2ad555 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/client.go @@ -0,0 +1,53 @@ +// Package storagecache implements the Azure ARM Storagecache service API version 2021-03-01. +// +// 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 using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/enums.go b/services/storagecache/mgmt/2021-03-01/storagecache/enums.go new file mode 100644 index 000000000000..f67a8e0e28d2 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/enums.go @@ -0,0 +1,265 @@ +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. + +// CacheIdentityType enumerates the values for cache identity type. +type CacheIdentityType string + +const ( + // None ... + None CacheIdentityType = "None" + // SystemAssigned ... + SystemAssigned CacheIdentityType = "SystemAssigned" +) + +// PossibleCacheIdentityTypeValues returns an array of possible values for the CacheIdentityType const type. +func PossibleCacheIdentityTypeValues() []CacheIdentityType { + return []CacheIdentityType{None, SystemAssigned} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// DomainJoinedType enumerates the values for domain joined type. +type DomainJoinedType string + +const ( + // Error ... + Error DomainJoinedType = "Error" + // No ... + No DomainJoinedType = "No" + // Yes ... + Yes DomainJoinedType = "Yes" +) + +// PossibleDomainJoinedTypeValues returns an array of possible values for the DomainJoinedType const type. +func PossibleDomainJoinedTypeValues() []DomainJoinedType { + return []DomainJoinedType{Error, No, Yes} +} + +// 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} +} + +// MetricAggregationType enumerates the values for metric aggregation type. +type MetricAggregationType string + +const ( + // MetricAggregationTypeAverage ... + MetricAggregationTypeAverage MetricAggregationType = "Average" + // MetricAggregationTypeCount ... + MetricAggregationTypeCount MetricAggregationType = "Count" + // MetricAggregationTypeMaximum ... + MetricAggregationTypeMaximum MetricAggregationType = "Maximum" + // MetricAggregationTypeMinimum ... + MetricAggregationTypeMinimum MetricAggregationType = "Minimum" + // MetricAggregationTypeNone ... + MetricAggregationTypeNone MetricAggregationType = "None" + // MetricAggregationTypeNotSpecified ... + MetricAggregationTypeNotSpecified MetricAggregationType = "NotSpecified" + // MetricAggregationTypeTotal ... + MetricAggregationTypeTotal MetricAggregationType = "Total" +) + +// PossibleMetricAggregationTypeValues returns an array of possible values for the MetricAggregationType const type. +func PossibleMetricAggregationTypeValues() []MetricAggregationType { + return []MetricAggregationType{MetricAggregationTypeAverage, MetricAggregationTypeCount, MetricAggregationTypeMaximum, MetricAggregationTypeMinimum, MetricAggregationTypeNone, MetricAggregationTypeNotSpecified, MetricAggregationTypeTotal} +} + +// NfsAccessRuleAccess enumerates the values for nfs access rule access. +type NfsAccessRuleAccess string + +const ( + // NfsAccessRuleAccessNo ... + NfsAccessRuleAccessNo NfsAccessRuleAccess = "no" + // NfsAccessRuleAccessRo ... + NfsAccessRuleAccessRo NfsAccessRuleAccess = "ro" + // NfsAccessRuleAccessRw ... + NfsAccessRuleAccessRw NfsAccessRuleAccess = "rw" +) + +// PossibleNfsAccessRuleAccessValues returns an array of possible values for the NfsAccessRuleAccess const type. +func PossibleNfsAccessRuleAccessValues() []NfsAccessRuleAccess { + return []NfsAccessRuleAccess{NfsAccessRuleAccessNo, NfsAccessRuleAccessRo, NfsAccessRuleAccessRw} +} + +// NfsAccessRuleScope enumerates the values for nfs access rule scope. +type NfsAccessRuleScope string + +const ( + // Default ... + Default NfsAccessRuleScope = "default" + // Host ... + Host NfsAccessRuleScope = "host" + // Network ... + Network NfsAccessRuleScope = "network" +) + +// PossibleNfsAccessRuleScopeValues returns an array of possible values for the NfsAccessRuleScope const type. +func PossibleNfsAccessRuleScopeValues() []NfsAccessRuleScope { + return []NfsAccessRuleScope{Default, Host, Network} +} + +// 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 ( + // StorageTargetTypeBlobNfs ... + StorageTargetTypeBlobNfs StorageTargetType = "blobNfs" + // 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{StorageTargetTypeBlobNfs, StorageTargetTypeClfs, StorageTargetTypeNfs3, StorageTargetTypeUnknown} +} + +// UsernameDownloadedType enumerates the values for username downloaded type. +type UsernameDownloadedType string + +const ( + // UsernameDownloadedTypeError ... + UsernameDownloadedTypeError UsernameDownloadedType = "Error" + // UsernameDownloadedTypeNo ... + UsernameDownloadedTypeNo UsernameDownloadedType = "No" + // UsernameDownloadedTypeYes ... + UsernameDownloadedTypeYes UsernameDownloadedType = "Yes" +) + +// PossibleUsernameDownloadedTypeValues returns an array of possible values for the UsernameDownloadedType const type. +func PossibleUsernameDownloadedTypeValues() []UsernameDownloadedType { + return []UsernameDownloadedType{UsernameDownloadedTypeError, UsernameDownloadedTypeNo, UsernameDownloadedTypeYes} +} + +// UsernameSource enumerates the values for username source. +type UsernameSource string + +const ( + // UsernameSourceAD ... + UsernameSourceAD UsernameSource = "AD" + // UsernameSourceFile ... + UsernameSourceFile UsernameSource = "File" + // UsernameSourceLDAP ... + UsernameSourceLDAP UsernameSource = "LDAP" + // UsernameSourceNone ... + UsernameSourceNone UsernameSource = "None" +) + +// PossibleUsernameSourceValues returns an array of possible values for the UsernameSource const type. +func PossibleUsernameSourceValues() []UsernameSource { + return []UsernameSource{UsernameSourceAD, UsernameSourceFile, UsernameSourceLDAP, UsernameSourceNone} +} diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/models.go b/services/storagecache/mgmt/2021-03-01/storagecache/models.go new file mode 100644 index 000000000000..70f71320a590 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/models.go @@ -0,0 +1,2005 @@ +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/storagecache/mgmt/2021-03-01/storagecache" + +// 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"` + // Origin - Origin of the operation. + Origin *string `json:"origin,omitempty"` + // IsDataAction - The flag that indicates whether the operation applies to data plane. + IsDataAction *bool `json:"isDataAction,omitempty"` + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // APIOperationProperties - Additional details about an operation. + *APIOperationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for APIOperation. +func (ao APIOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ao.Display != nil { + objectMap["display"] = ao.Display + } + if ao.Origin != nil { + objectMap["origin"] = ao.Origin + } + if ao.IsDataAction != nil { + objectMap["isDataAction"] = ao.IsDataAction + } + if ao.Name != nil { + objectMap["name"] = ao.Name + } + if ao.APIOperationProperties != nil { + objectMap["properties"] = ao.APIOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for APIOperation struct. +func (ao *APIOperation) 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 "display": + if v != nil { + var display APIOperationDisplay + err = json.Unmarshal(*v, &display) + if err != nil { + return err + } + ao.Display = &display + } + case "origin": + if v != nil { + var origin string + err = json.Unmarshal(*v, &origin) + if err != nil { + return err + } + ao.Origin = &origin + } + case "isDataAction": + if v != nil { + var isDataAction bool + err = json.Unmarshal(*v, &isDataAction) + if err != nil { + return err + } + ao.IsDataAction = &isDataAction + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ao.Name = &name + } + case "properties": + if v != nil { + var APIOperationProperties APIOperationProperties + err = json.Unmarshal(*v, &APIOperationProperties) + if err != nil { + return err + } + ao.APIOperationProperties = &APIOperationProperties + } + } + } + + return nil +} + +// 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"` + // Description - The description of the operation + Description *string `json:"description,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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aolr APIOperationListResult) hasNextLink() bool { + return aolr.NextLink != nil && len(*aolr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.aolr) + if err != nil { + return err + } + page.aolr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur APIOperationListResult, getNextPage func(context.Context, APIOperationListResult) (APIOperationListResult, error)) APIOperationListResultPage { + return APIOperationListResultPage{ + fn: getNextPage, + aolr: cur, + } +} + +// APIOperationProperties additional details about an operation. +type APIOperationProperties struct { + // ServiceSpecification - Specification of the all the metrics provided for a resource type. + ServiceSpecification *APIOperationPropertiesServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// APIOperationPropertiesServiceSpecification specification of the all the metrics provided for a resource +// type. +type APIOperationPropertiesServiceSpecification struct { + // MetricSpecifications - Details about operations related to metrics. + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// AscOperation the status of operation. +type AscOperation struct { + autorest.Response `json:"-"` + // ID - The operation Id. + ID *string `json:"id,omitempty"` + // Name - The operation name. + Name *string `json:"name,omitempty"` + // StartTime - The start time of the operation. + StartTime *string `json:"startTime,omitempty"` + // EndTime - The end time of the operation. + EndTime *string `json:"endTime,omitempty"` + // Status - The status of the operation. + Status *string `json:"status,omitempty"` + // Error - The error detail of the operation if any. + Error *ErrorResponse `json:"error,omitempty"` + // AscOperationProperties - Additional operation-specific properties + *AscOperationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AscOperation. +func (ao AscOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ao.ID != nil { + objectMap["id"] = ao.ID + } + if ao.Name != nil { + objectMap["name"] = ao.Name + } + if ao.StartTime != nil { + objectMap["startTime"] = ao.StartTime + } + if ao.EndTime != nil { + objectMap["endTime"] = ao.EndTime + } + if ao.Status != nil { + objectMap["status"] = ao.Status + } + if ao.Error != nil { + objectMap["error"] = ao.Error + } + if ao.AscOperationProperties != nil { + objectMap["properties"] = ao.AscOperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AscOperation struct. +func (ao *AscOperation) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ao.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ao.Name = &name + } + case "startTime": + if v != nil { + var startTime string + err = json.Unmarshal(*v, &startTime) + if err != nil { + return err + } + ao.StartTime = &startTime + } + case "endTime": + if v != nil { + var endTime string + err = json.Unmarshal(*v, &endTime) + if err != nil { + return err + } + ao.EndTime = &endTime + } + case "status": + if v != nil { + var status string + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + ao.Status = &status + } + case "error": + if v != nil { + var errorVar ErrorResponse + err = json.Unmarshal(*v, &errorVar) + if err != nil { + return err + } + ao.Error = &errorVar + } + case "properties": + if v != nil { + var ascOperationProperties AscOperationProperties + err = json.Unmarshal(*v, &ascOperationProperties) + if err != nil { + return err + } + ao.AscOperationProperties = &ascOperationProperties + } + } + } + + return nil +} + +// AscOperationProperties additional operation-specific output. +type AscOperationProperties struct { + // Output - Additional operation-specific output. + Output map[string]interface{} `json:"output"` +} + +// MarshalJSON is the custom marshaler for AscOperationProperties. +func (aop AscOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aop.Output != nil { + objectMap["output"] = aop.Output + } + return json.Marshal(objectMap) +} + +// BlobNfsTarget properties pertaining to the BlobNfsTarget. +type BlobNfsTarget struct { + // Target - Resource ID of the storage container. + Target *string `json:"target,omitempty"` + // UsageModel - Identifies the StorageCache usage model to be used for this storage target. + UsageModel *string `json:"usageModel,omitempty"` +} + +// 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 - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID 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 of the Cache; Microsoft.StorageCache/Cache + Type *string `json:"type,omitempty"` + // Identity - The identity of the cache, if configured. + Identity *CacheIdentity `json:"identity,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` + // CacheProperties - Properties of 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.Identity != nil { + objectMap["identity"] = c.Identity + } + 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 map[string]*string + 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 "identity": + if v != nil { + var identity CacheIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + c.Identity = &identity + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + c.SystemData = &systemData + } + 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 +} + +// CacheActiveDirectorySettings active Directory settings used to join a cache to a domain. +type CacheActiveDirectorySettings struct { + // PrimaryDNSIPAddress - Primary DNS IP address used to resolve the Active Directory domain controller's fully qualified domain name. + PrimaryDNSIPAddress *string `json:"primaryDnsIpAddress,omitempty"` + // SecondaryDNSIPAddress - Secondary DNS IP address used to resolve the Active Directory domain controller's fully qualified domain name. + SecondaryDNSIPAddress *string `json:"secondaryDnsIpAddress,omitempty"` + // DomainName - The fully qualified domain name of the Active Directory domain controller. + DomainName *string `json:"domainName,omitempty"` + // DomainNetBiosName - The Active Directory domain's NetBIOS name. + DomainNetBiosName *string `json:"domainNetBiosName,omitempty"` + // CacheNetBiosName - The NetBIOS name to assign to the HPC Cache when it joins the Active Directory domain as a server. Length must 1-15 characters from the class [-0-9a-zA-Z]. + CacheNetBiosName *string `json:"cacheNetBiosName,omitempty"` + // DomainJoined - READ-ONLY; True if the HPC Cache is joined to the Active Directory domain. Possible values include: 'Yes', 'No', 'Error' + DomainJoined DomainJoinedType `json:"domainJoined,omitempty"` + // Credentials - Active Directory admin credentials used to join the HPC Cache to a domain. + Credentials *CacheActiveDirectorySettingsCredentials `json:"credentials,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheActiveDirectorySettings. +func (cads CacheActiveDirectorySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cads.PrimaryDNSIPAddress != nil { + objectMap["primaryDnsIpAddress"] = cads.PrimaryDNSIPAddress + } + if cads.SecondaryDNSIPAddress != nil { + objectMap["secondaryDnsIpAddress"] = cads.SecondaryDNSIPAddress + } + if cads.DomainName != nil { + objectMap["domainName"] = cads.DomainName + } + if cads.DomainNetBiosName != nil { + objectMap["domainNetBiosName"] = cads.DomainNetBiosName + } + if cads.CacheNetBiosName != nil { + objectMap["cacheNetBiosName"] = cads.CacheNetBiosName + } + if cads.Credentials != nil { + objectMap["credentials"] = cads.Credentials + } + return json.Marshal(objectMap) +} + +// CacheActiveDirectorySettingsCredentials active Directory admin credentials used to join the HPC Cache to +// a domain. +type CacheActiveDirectorySettingsCredentials struct { + // Username - Username of the Active Directory domain administrator. This value is stored encrypted and not returned on response. + Username *string `json:"username,omitempty"` + // Password - Plain text password of the Active Directory domain administrator. This value is stored encrypted and not returned on response. + Password *string `json:"password,omitempty"` +} + +// CacheDirectorySettings cache Directory Services settings. +type CacheDirectorySettings struct { + // ActiveDirectory - Specifies settings for joining the HPC Cache to an Active Directory domain. + ActiveDirectory *CacheActiveDirectorySettings `json:"activeDirectory,omitempty"` + // UsernameDownload - Specifies settings for Extended Groups. Extended Groups allows users to be members of more than 16 groups. + UsernameDownload *CacheUsernameDownloadSettings `json:"usernameDownload,omitempty"` +} + +// CacheEncryptionSettings cache encryption settings. +type CacheEncryptionSettings struct { + // KeyEncryptionKey - Specifies the location of the key encryption key in Key Vault. + KeyEncryptionKey *KeyVaultKeyReference `json:"keyEncryptionKey,omitempty"` +} + +// 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"` + // Conditions - READ-ONLY; Outstanding conditions that need to be investigated and resolved. + Conditions *[]Condition `json:"conditions,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheHealth. +func (ch CacheHealth) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ch.State != "" { + objectMap["state"] = ch.State + } + if ch.StatusDescription != nil { + objectMap["statusDescription"] = ch.StatusDescription + } + return json.Marshal(objectMap) +} + +// CacheIdentity cache identity properties. +type CacheIdentity struct { + // PrincipalID - READ-ONLY; The principal id of the cache. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant id associated with the cache. + TenantID *string `json:"tenantId,omitempty"` + // Type - The type of identity used for the cache. Possible values include: 'SystemAssigned', 'None' + Type CacheIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheIdentity. +func (ci CacheIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ci.Type != "" { + objectMap["type"] = ci.Type + } + return json.Marshal(objectMap) +} + +// CacheNetworkSettings cache network settings. +type CacheNetworkSettings struct { + // Mtu - The IPv4 maximum transmission unit configured for the subnet. + Mtu *int32 `json:"mtu,omitempty"` + // UtilityAddresses - READ-ONLY; Array of additional IP addresses used by this Cache. + UtilityAddresses *[]string `json:"utilityAddresses,omitempty"` + // DNSServers - DNS servers for the cache to use. It will be set from the network configuration if no value is provided. + DNSServers *[]string `json:"dnsServers,omitempty"` + // DNSSearchDomain - DNS search domain + DNSSearchDomain *string `json:"dnsSearchDomain,omitempty"` + // NtpServer - NTP server IP Address or FQDN for the cache to use. The default is time.windows.com. + NtpServer *string `json:"ntpServer,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheNetworkSettings. +func (cns CacheNetworkSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cns.Mtu != nil { + objectMap["mtu"] = cns.Mtu + } + if cns.DNSServers != nil { + objectMap["dnsServers"] = cns.DNSServers + } + if cns.DNSSearchDomain != nil { + objectMap["dnsSearchDomain"] = cns.DNSSearchDomain + } + if cns.NtpServer != nil { + objectMap["ntpServer"] = cns.NtpServer + } + return json.Marshal(objectMap) +} + +// CacheProperties properties of the Cache. +type CacheProperties struct { + // CacheSizeGB - The size of this 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"` + // NetworkSettings - Specifies network settings of the cache. + NetworkSettings *CacheNetworkSettings `json:"networkSettings,omitempty"` + // EncryptionSettings - Specifies encryption settings of the cache. + EncryptionSettings *CacheEncryptionSettings `json:"encryptionSettings,omitempty"` + // SecuritySettings - Specifies security settings of the cache. + SecuritySettings *CacheSecuritySettings `json:"securitySettings,omitempty"` + // DirectoryServicesSettings - Specifies Directory Services settings of the cache. + DirectoryServicesSettings *CacheDirectorySettings `json:"directoryServicesSettings,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheProperties. +func (c CacheProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.CacheSizeGB != nil { + objectMap["cacheSizeGB"] = c.CacheSizeGB + } + if c.ProvisioningState != "" { + objectMap["provisioningState"] = c.ProvisioningState + } + if c.Subnet != nil { + objectMap["subnet"] = c.Subnet + } + if c.UpgradeStatus != nil { + objectMap["upgradeStatus"] = c.UpgradeStatus + } + if c.NetworkSettings != nil { + objectMap["networkSettings"] = c.NetworkSettings + } + if c.EncryptionSettings != nil { + objectMap["encryptionSettings"] = c.EncryptionSettings + } + if c.SecuritySettings != nil { + objectMap["securitySettings"] = c.SecuritySettings + } + if c.DirectoryServicesSettings != nil { + objectMap["directoryServicesSettings"] = c.DirectoryServicesSettings + } + return json.Marshal(objectMap) +} + +// CachesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CachesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CachesClient) (Cache, error) +} + +// CachesDebugInfoFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CachesDebugInfoFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CachesClient) (autorest.Response, error) +} + +// CachesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CachesClient) (autorest.Response, error) +} + +// CacheSecuritySettings cache security settings. +type CacheSecuritySettings struct { + // AccessPolicies - NFS access policies defined for this cache. + AccessPolicies *[]NfsAccessPolicy `json:"accessPolicies,omitempty"` +} + +// CachesFlushFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesFlushFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CachesClient) (autorest.Response, error) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (clr CachesListResult) hasNextLink() bool { + return clr.NextLink != nil && len(*clr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.clr) + if err != nil { + return err + } + page.clr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur CachesListResult, getNextPage func(context.Context, CachesListResult) (CachesListResult, error)) CachesListResultPage { + return CachesListResultPage{ + fn: getNextPage, + clr: cur, + } +} + +// CachesStartFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesStartFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CachesClient) (autorest.Response, error) +} + +// CachesStopFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type CachesStopFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CachesClient) (autorest.Response, error) +} + +// CachesUpgradeFirmwareFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CachesUpgradeFirmwareFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(CachesClient) (autorest.Response, error) +} + +// 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"` +} + +// CacheUsernameDownloadSettings settings for Extended Groups username and group download. +type CacheUsernameDownloadSettings struct { + // ExtendedGroups - Whether or not Extended Groups is enabled. + ExtendedGroups *bool `json:"extendedGroups,omitempty"` + // UsernameSource - This setting determines how the cache gets username and group names for clients. Possible values include: 'UsernameSourceAD', 'UsernameSourceLDAP', 'UsernameSourceFile', 'UsernameSourceNone' + UsernameSource UsernameSource `json:"usernameSource,omitempty"` + // GroupFileURI - The URI of the file containing group information (in /etc/group file format). This field must be populated when 'usernameSource' is set to 'File'. + GroupFileURI *string `json:"groupFileURI,omitempty"` + // UserFileURI - The URI of the file containing user information (in /etc/passwd file format). This field must be populated when 'usernameSource' is set to 'File'. + UserFileURI *string `json:"userFileURI,omitempty"` + // LdapServer - The fully qualified domain name or IP address of the LDAP server to use. + LdapServer *string `json:"ldapServer,omitempty"` + // LdapBaseDN - The base distinguished name for the LDAP domain. + LdapBaseDN *string `json:"ldapBaseDN,omitempty"` + // EncryptLdapConnection - Whether or not the LDAP connection should be encrypted. + EncryptLdapConnection *bool `json:"encryptLdapConnection,omitempty"` + // RequireValidCertificate - Determines if the certificates must be validated by a certificate authority. When true, caCertificateURI must be provided. + RequireValidCertificate *bool `json:"requireValidCertificate,omitempty"` + // AutoDownloadCertificate - Determines if the certificate should be automatically downloaded. This applies to 'caCertificateURI' only if 'requireValidCertificate' is true. + AutoDownloadCertificate *bool `json:"autoDownloadCertificate,omitempty"` + // CaCertificateURI - The URI of the CA certificate to validate the LDAP secure connection. This field must be populated when 'requireValidCertificate' is set to true. + CaCertificateURI *string `json:"caCertificateURI,omitempty"` + // UsernameDownloaded - READ-ONLY; Indicates whether or not the HPC Cache has performed the username download successfully. Possible values include: 'UsernameDownloadedTypeYes', 'UsernameDownloadedTypeNo', 'UsernameDownloadedTypeError' + UsernameDownloaded UsernameDownloadedType `json:"usernameDownloaded,omitempty"` + // Credentials - When present, these are the credentials for the secure LDAP connection. + Credentials *CacheUsernameDownloadSettingsCredentials `json:"credentials,omitempty"` +} + +// MarshalJSON is the custom marshaler for CacheUsernameDownloadSettings. +func (cuds CacheUsernameDownloadSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cuds.ExtendedGroups != nil { + objectMap["extendedGroups"] = cuds.ExtendedGroups + } + if cuds.UsernameSource != "" { + objectMap["usernameSource"] = cuds.UsernameSource + } + if cuds.GroupFileURI != nil { + objectMap["groupFileURI"] = cuds.GroupFileURI + } + if cuds.UserFileURI != nil { + objectMap["userFileURI"] = cuds.UserFileURI + } + if cuds.LdapServer != nil { + objectMap["ldapServer"] = cuds.LdapServer + } + if cuds.LdapBaseDN != nil { + objectMap["ldapBaseDN"] = cuds.LdapBaseDN + } + if cuds.EncryptLdapConnection != nil { + objectMap["encryptLdapConnection"] = cuds.EncryptLdapConnection + } + if cuds.RequireValidCertificate != nil { + objectMap["requireValidCertificate"] = cuds.RequireValidCertificate + } + if cuds.AutoDownloadCertificate != nil { + objectMap["autoDownloadCertificate"] = cuds.AutoDownloadCertificate + } + if cuds.CaCertificateURI != nil { + objectMap["caCertificateURI"] = cuds.CaCertificateURI + } + if cuds.Credentials != nil { + objectMap["credentials"] = cuds.Credentials + } + return json.Marshal(objectMap) +} + +// CacheUsernameDownloadSettingsCredentials when present, these are the credentials for the secure LDAP +// connection. +type CacheUsernameDownloadSettingsCredentials struct { + // BindDn - The Bind Distinguished Name identity to be used in the secure LDAP connection. This value is stored encrypted and not returned on response. + BindDn *string `json:"bindDn,omitempty"` + // BindPassword - The Bind password to be used in the secure LDAP connection. This value is stored encrypted and not returned on response. + BindPassword *string `json:"bindPassword,omitempty"` +} + +// ClfsTarget properties pertaining to the ClfsTarget +type ClfsTarget struct { + // Target - Resource ID 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"` +} + +// Condition outstanding conditions that will need to be resolved. +type Condition struct { + // Timestamp - READ-ONLY; The time when the condition was raised. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Message - READ-ONLY; The issue requiring attention. + Message *string `json:"message,omitempty"` +} + +// ErrorResponse describes the format of Error response. +type ErrorResponse struct { + // Code - Error code + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// KeyVaultKeyReference describes a reference to Key Vault Key. +type KeyVaultKeyReference struct { + // KeyURL - The URL referencing a key encryption key in Key Vault. + KeyURL *string `json:"keyUrl,omitempty"` + // SourceVault - Describes a resource Id to source Key Vault. + SourceVault *KeyVaultKeyReferenceSourceVault `json:"sourceVault,omitempty"` +} + +// KeyVaultKeyReferenceSourceVault describes a resource Id to source Key Vault. +type KeyVaultKeyReferenceSourceVault struct { + // ID - Resource Id. + ID *string `json:"id,omitempty"` +} + +// MetricDimension specifications of the Dimension of metrics. +type MetricDimension struct { + // Name - Name of the dimension + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the dimension + DisplayName *string `json:"displayName,omitempty"` + // InternalName - Internal name of the dimension. + InternalName *string `json:"internalName,omitempty"` + // ToBeExportedForShoebox - To be exported to shoe box. + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// MetricSpecification details about operation related to metrics. +type MetricSpecification struct { + // Name - The name of the metric. + Name *string `json:"name,omitempty"` + // DisplayName - Localized display name of the metric. + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - The description of the metric. + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - The unit that the metric is measured in. + Unit *string `json:"unit,omitempty"` + // AggregationType - The type of metric aggregation. + AggregationType *string `json:"aggregationType,omitempty"` + // SupportedAggregationTypes - Support metric aggregation type. + SupportedAggregationTypes *[]MetricAggregationType `json:"supportedAggregationTypes,omitempty"` + // MetricClass - Type of metrics. + MetricClass *string `json:"metricClass,omitempty"` + // Dimensions - Dimensions of the metric + Dimensions *[]MetricDimension `json:"dimensions,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"` + // NfsAccessPolicy - Name of the access policy applied to this junction. + NfsAccessPolicy *string `json:"nfsAccessPolicy,omitempty"` +} + +// Nfs3Target properties pertaining to the Nfs3Target +type Nfs3Target struct { + // Target - IP address or host name of an NFSv3 host (e.g., 10.0.44.44). + Target *string `json:"target,omitempty"` + // UsageModel - Identifies the StorageCache usage model to be used for this storage target. + UsageModel *string `json:"usageModel,omitempty"` +} + +// NfsAccessPolicy a set of rules describing access policies applied to NFSv3 clients of the cache. +type NfsAccessPolicy struct { + // Name - Name identifying this policy. Access Policy names are not case sensitive. + Name *string `json:"name,omitempty"` + // AccessRules - The set of rules describing client accesses allowed under this policy. + AccessRules *[]NfsAccessRule `json:"accessRules,omitempty"` +} + +// NfsAccessRule rule to place restrictions on portions of the cache namespace being presented to clients. +type NfsAccessRule struct { + // Scope - Scope for this rule. The scope and filter determine which clients match the rule. Possible values include: 'Default', 'Network', 'Host' + Scope NfsAccessRuleScope `json:"scope,omitempty"` + // Filter - Filter applied to the scope for this rule. The filter's format depends on its scope. 'default' scope matches all clients and has no filter value. 'network' scope takes a filter in CIDR format (for example, 10.99.1.0/24). 'host' takes an IP address or fully qualified domain name as filter. If a client does not match any filter rule and there is no default rule, access is denied. + Filter *string `json:"filter,omitempty"` + // Access - Access allowed by this rule. Possible values include: 'NfsAccessRuleAccessNo', 'NfsAccessRuleAccessRo', 'NfsAccessRuleAccessRw' + Access NfsAccessRuleAccess `json:"access,omitempty"` + // Suid - Allow SUID semantics. + Suid *bool `json:"suid,omitempty"` + // SubmountAccess - For the default policy, allow access to subdirectories under the root export. If this is set to no, clients can only mount the path '/'. If set to yes, clients can mount a deeper path, like '/a/b'. + SubmountAccess *bool `json:"submountAccess,omitempty"` + // RootSquash - Map root accesses to anonymousUID and anonymousGID. + RootSquash *bool `json:"rootSquash,omitempty"` + // AnonymousUID - UID value that replaces 0 when rootSquash is true. 65534 will be used if not provided. + AnonymousUID *string `json:"anonymousUID,omitempty"` + // AnonymousGID - GID value that replaces 0 when rootSquash is true. This will use the value of anonymousUID if not provided. + AnonymousGID *string `json:"anonymousGID,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 where the SKU is available. This is the 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 where the SKU is available. + LocationInfo *[]ResourceSkuLocationInfo `json:"locationInfo,omitempty"` + // Name - The name of this SKU. + Name *string `json:"name,omitempty"` + // Restrictions - The restrictions preventing this SKU from being used. This is empty if there are no restrictions. + Restrictions *[]Restriction `json:"restrictions,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceSku. +func (rs ResourceSku) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rs.Capabilities != nil { + objectMap["capabilities"] = rs.Capabilities + } + if rs.LocationInfo != nil { + objectMap["locationInfo"] = rs.LocationInfo + } + if rs.Name != nil { + objectMap["name"] = rs.Name + } + if rs.Restrictions != nil { + objectMap["restrictions"] = rs.Restrictions + } + return json.Marshal(objectMap) +} + +// 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"` +} + +// MarshalJSON is the custom marshaler for ResourceSkusResult. +func (rsr ResourceSkusResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rsr.NextLink != nil { + objectMap["nextLink"] = rsr.NextLink + } + return json.Marshal(objectMap) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (rsr ResourceSkusResult) hasNextLink() bool { + return rsr.NextLink != nil && len(*rsr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.rsr) + if err != nil { + return err + } + page.rsr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur ResourceSkusResult, getNextPage func(context.Context, ResourceSkusResult) (ResourceSkusResult, error)) ResourceSkusResultPage { + return ResourceSkusResultPage{ + fn: getNextPage, + rsr: cur, + } +} + +// Restriction the restrictions preventing this SKU from being used. +type Restriction struct { + // Type - READ-ONLY; The type of restrictions. In this version, the 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, then this would be the 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". "QuotaId" is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. "NotAvailableForSubscription" is related to capacity at the datacenter. Possible values include: 'QuotaID', 'NotAvailableForSubscription' + ReasonCode ReasonCode `json:"reasonCode,omitempty"` +} + +// MarshalJSON is the custom marshaler for Restriction. +func (r Restriction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.ReasonCode != "" { + objectMap["reasonCode"] = r.ReasonCode + } + return json.Marshal(objectMap) +} + +// StorageTarget type of the Storage Target. +type StorageTarget struct { + autorest.Response `json:"-"` + // StorageTargetProperties - StorageTarget properties + *StorageTargetProperties `json:"properties,omitempty"` + // Name - READ-ONLY; Name of the Storage Target. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; Resource ID of the Storage Target. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Region name string. + Location *string `json:"location,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,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 "properties": + if v != nil { + var storageTargetProperties StorageTargetProperties + err = json.Unmarshal(*v, &storageTargetProperties) + if err != nil { + return err + } + st.StorageTargetProperties = &storageTargetProperties + } + 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 "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + st.Location = &location + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + st.SystemData = &systemData + } + } + } + + return nil +} + +// StorageTargetProperties properties of the Storage Target. +type StorageTargetProperties struct { + // Junctions - List of Cache namespace junctions to target for namespace associations. + Junctions *[]NamespaceJunction `json:"junctions,omitempty"` + // TargetType - Type of the Storage Target. Possible values include: 'StorageTargetTypeNfs3', 'StorageTargetTypeClfs', 'StorageTargetTypeUnknown', 'StorageTargetTypeBlobNfs' + 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 targetType is nfs3. + Nfs3 *Nfs3Target `json:"nfs3,omitempty"` + // Clfs - Properties when targetType is clfs. + Clfs *ClfsTarget `json:"clfs,omitempty"` + // Unknown - Properties when targetType is unknown. + Unknown *UnknownTarget `json:"unknown,omitempty"` + // BlobNfs - Properties when targetType is blobNfs. + BlobNfs *BlobNfsTarget `json:"blobNfs,omitempty"` +} + +// StorageTargetResource resource used by a Cache. +type StorageTargetResource struct { + // Name - READ-ONLY; Name of the Storage Target. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; Resource ID of the Storage Target. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Region name string. + Location *string `json:"location,omitempty"` + // SystemData - READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// StorageTargetsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type StorageTargetsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(StorageTargetsClient) (StorageTarget, error) +} + +// StorageTargetsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type StorageTargetsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(StorageTargetsClient) (autorest.Response, error) +} + +// StorageTargetsDNSRefreshFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type StorageTargetsDNSRefreshFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(StorageTargetsClient) (autorest.Response, error) +} + +// 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (str StorageTargetsResult) hasNextLink() bool { + return str.NextLink != nil && len(*str.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.str) + if err != nil { + return err + } + page.str = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur StorageTargetsResult, getNextPage func(context.Context, StorageTargetsResult) (StorageTargetsResult, error)) StorageTargetsResultPage { + return StorageTargetsResultPage{ + fn: getNextPage, + str: cur, + } +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// UnknownTarget properties pertaining to the UnknownTarget +type UnknownTarget struct { + // Attributes - Dictionary of string->string pairs containing information about the Storage Target. + Attributes map[string]*string `json:"attributes"` +} + +// MarshalJSON is the custom marshaler for UnknownTarget. +func (ut UnknownTarget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ut.Attributes != nil { + objectMap["attributes"] = ut.Attributes + } + 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 name for this usage model. + ModelName *string `json:"modelName,omitempty"` + // TargetType - The type of Storage Target to which this model is applicable (only nfs3 as of this version). + 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 +} + +// hasNextLink returns true if the NextLink is not empty. +func (umr UsageModelsResult) hasNextLink() bool { + return umr.NextLink != nil && len(*umr.NextLink) != 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.hasNextLink() { + 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) + }() + } + for { + next, err := page.fn(ctx, page.umr) + if err != nil { + return err + } + page.umr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *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(cur UsageModelsResult, getNextPage func(context.Context, UsageModelsResult) (UsageModelsResult, error)) UsageModelsResultPage { + return UsageModelsResultPage{ + fn: getNextPage, + umr: cur, + } +} diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/operations.go b/services/storagecache/mgmt/2021-03-01/storagecache/operations.go new file mode 100644 index 000000000000..bf04372a5abb --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/operations.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" +) + +// 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 using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Resource Provider 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 + } + if result.aolr.hasNextLink() && result.aolr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-03-01" + 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) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result APIOperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults 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/storagecache/mgmt/2021-03-01/storagecache/skus.go b/services/storagecache/mgmt/2021-03-01/storagecache/skus.go new file mode 100644 index 000000000000..0dab589583f0 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/skus.go @@ -0,0 +1,156 @@ +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 using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + if result.rsr.hasNextLink() && result.rsr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-03-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SkusClient) ListResponder(resp *http.Response) (result ResourceSkusResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/storagecache/mgmt/2021-03-01/storagecache/storagecacheapi/interfaces.go b/services/storagecache/mgmt/2021-03-01/storagecache/storagecacheapi/interfaces.go new file mode 100644 index 000000000000..6f46acc6b0d0 --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/storagecacheapi/interfaces.go @@ -0,0 +1,85 @@ +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/storagecache/mgmt/2021-03-01/storagecache" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result storagecache.APIOperationListResultPage, err error) + ListComplete(ctx context.Context) (result storagecache.APIOperationListResultIterator, 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) + ListComplete(ctx context.Context) (result storagecache.ResourceSkusResultIterator, 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) + ListComplete(ctx context.Context) (result storagecache.UsageModelsResultIterator, err error) +} + +var _ UsageModelsClientAPI = (*storagecache.UsageModelsClient)(nil) + +// AscOperationsClientAPI contains the set of methods on the AscOperationsClient type. +type AscOperationsClientAPI interface { + Get(ctx context.Context, location string, operationID string) (result storagecache.AscOperation, err error) +} + +var _ AscOperationsClientAPI = (*storagecache.AscOperationsClient)(nil) + +// CachesClientAPI contains the set of methods on the CachesClient type. +type CachesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, cache *storagecache.Cache) (result storagecache.CachesCreateOrUpdateFuture, err error) + DebugInfo(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.CachesDebugInfoFuture, 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) + ListComplete(ctx context.Context) (result storagecache.CachesListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result storagecache.CachesListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result storagecache.CachesListResultIterator, 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 { + CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *storagecache.StorageTarget) (result storagecache.StorageTargetsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result storagecache.StorageTargetsDeleteFuture, err error) + DNSRefresh(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result storagecache.StorageTargetsDNSRefreshFuture, 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) + ListByCacheComplete(ctx context.Context, resourceGroupName string, cacheName string) (result storagecache.StorageTargetsResultIterator, err error) +} + +var _ StorageTargetsClientAPI = (*storagecache.StorageTargetsClient)(nil) diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/storagetargets.go b/services/storagecache/mgmt/2021-03-01/storagecache/storagetargets.go new file mode 100644 index 000000000000..78dca1ce629e --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/storagetargets.go @@ -0,0 +1,590 @@ +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 using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewStorageTargetsClientWithBaseURI(baseURI string, subscriptionID string) StorageTargetsClient { + return StorageTargetsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or 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. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +// storageTargetName - name of Storage Target. +// storagetarget - object containing the definition of a Storage Target. +func (client StorageTargetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget *StorageTarget) (result StorageTargetsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, 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", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, cacheName, storageTargetName, storagetarget) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client StorageTargetsClient) CreateOrUpdatePreparer(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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client StorageTargetsClient) CreateOrUpdateSender(req *http.Request) (future StorageTargetsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client StorageTargetsClient) (st StorageTarget, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.StorageTargetsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + st.Response.Response, err = future.GetResult(sender) + if st.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsCreateOrUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && st.Response.Response.StatusCode != http.StatusNoContent { + st, err = client.CreateOrUpdateResponder(st.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsCreateOrUpdateFuture", "Result", st.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) CreateOrUpdateResponder(resp *http.Response) (result StorageTarget, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + 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. Note that if +// the Cache has data to flush to the Storage Target, the data will be flushed before the Storage Target will be +// deleted. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +// 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.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.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,80}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, 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", nil, "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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client StorageTargetsClient) (ar autorest.Response, 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 + } + ar.Response = future.Response() + return + } + 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 autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DNSRefresh tells a storage target to refresh its DNS information. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +// storageTargetName - name of Storage Target. +func (client StorageTargetsClient) DNSRefresh(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string) (result StorageTargetsDNSRefreshFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/StorageTargetsClient.DNSRefresh") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: cacheName, + Constraints: []validation.Constraint{{Target: "cacheName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("storagecache.StorageTargetsClient", "DNSRefresh", err.Error()) + } + + req, err := client.DNSRefreshPreparer(ctx, resourceGroupName, cacheName, storageTargetName) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "DNSRefresh", nil, "Failure preparing request") + return + } + + result, err = client.DNSRefreshSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsClient", "DNSRefresh", nil, "Failure sending request") + return + } + + return +} + +// DNSRefreshPreparer prepares the DNSRefresh request. +func (client StorageTargetsClient) DNSRefreshPreparer(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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}/dnsRefresh", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DNSRefreshSender sends the DNSRefresh request. The method will close the +// http.Response Body if it receives an error. +func (client StorageTargetsClient) DNSRefreshSender(req *http.Request) (future StorageTargetsDNSRefreshFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client StorageTargetsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "storagecache.StorageTargetsDNSRefreshFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("storagecache.StorageTargetsDNSRefreshFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DNSRefreshResponder handles the response to the DNSRefresh request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) DNSRefreshResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a Storage Target from a Cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +// 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,80}$`, Chain: nil}}}, + {TargetValue: storageTargetName, + Constraints: []validation.Constraint{{Target: "storageTargetName", Name: validation.Pattern, Rule: `^[-0-9a-zA-Z_]{1,80}$`, 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 + } + + 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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client StorageTargetsClient) GetResponder(resp *http.Response) (result StorageTarget, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByCache returns a list of Storage Targets for the specified Cache. +// Parameters: +// resourceGroupName - target resource group. +// cacheName - name of Cache. Length of name must not be greater than 80 and chars must be from the +// [-0-9a-zA-Z_] char class. +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,80}$`, 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 + } + if result.str.hasNextLink() && result.str.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// 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, + 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 +} diff --git a/services/storagecache/mgmt/2021-03-01/storagecache/usagemodels.go b/services/storagecache/mgmt/2021-03-01/storagecache/usagemodels.go new file mode 100644 index 000000000000..cb024c945bcf --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/storagecache/usagemodels.go @@ -0,0 +1,156 @@ +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 using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +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 + } + if result.umr.hasNextLink() && result.umr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + 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 = "2021-03-01" + 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) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client UsageModelsClient) ListResponder(resp *http.Response) (result UsageModelsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client 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/storagecache/mgmt/2021-03-01/storagecache/version.go b/services/storagecache/mgmt/2021-03-01/storagecache/version.go new file mode 100644 index 000000000000..11e21f89d81a --- /dev/null +++ b/services/storagecache/mgmt/2021-03-01/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() + " storagecache/2021-03-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}