diff --git a/sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md b/sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md index d376a40ec167..30eeab178668 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md +++ b/sdk/resourcemanager/storagecache/armstoragecache/CHANGELOG.md @@ -1,5 +1,20 @@ # Release History +## 3.1.0 (2023-03-23) +### Features Added + +- New function `NewClientFactory(string, azcore.TokenCredential, *arm.ClientOptions) (*ClientFactory, error)` +- New function `*ClientFactory.NewAscOperationsClient() *AscOperationsClient` +- New function `*ClientFactory.NewAscUsagesClient() *AscUsagesClient` +- New function `*ClientFactory.NewCachesClient() *CachesClient` +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `*ClientFactory.NewSKUsClient() *SKUsClient` +- New function `*ClientFactory.NewStorageTargetClient() *StorageTargetClient` +- New function `*ClientFactory.NewStorageTargetsClient() *StorageTargetsClient` +- New function `*ClientFactory.NewUsageModelsClient() *UsageModelsClient` +- New struct `ClientFactory` + + ## 3.0.0 (2023-02-24) ### Breaking Changes diff --git a/sdk/resourcemanager/storagecache/armstoragecache/ascoperations_client.go b/sdk/resourcemanager/storagecache/armstoragecache/ascoperations_client.go index 87a83c53b4bd..486b3dac90d3 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/ascoperations_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/ascoperations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // AscOperationsClient contains the methods for the AscOperations group. // Don't use this type directly, use NewAscOperationsClient() instead. type AscOperationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAscOperationsClient creates a new instance of AscOperationsClient with the specified values. @@ -37,21 +34,13 @@ type AscOperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAscOperationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AscOperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AscOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AscOperationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -68,7 +57,7 @@ func (client *AscOperationsClient) Get(ctx context.Context, location string, ope if err != nil { return AscOperationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AscOperationsClientGetResponse{}, err } @@ -93,7 +82,7 @@ func (client *AscOperationsClient) getCreateRequest(ctx context.Context, locatio return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/ascoperations_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/ascoperations_client_example_test.go deleted file mode 100644 index d42b077cbd98..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/ascoperations_client_example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/AscOperations_Get.json -func ExampleAscOperationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewAscOperationsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "westus", "testoperationid", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AscOperation = armstoragecache.AscOperation{ - // Name: to.Ptr("testoperationid"), - // EndTime: to.Ptr("2023-01-01T16:13:13.933Z"), - // ID: to.Ptr("/subscriptions/id/locations/westus/ascOperations/testoperationid"), - // StartTime: to.Ptr("2023-01-01T13:13:13.933Z"), - // Status: to.Ptr("Succeeded"), - // } -} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/ascusages_client.go b/sdk/resourcemanager/storagecache/armstoragecache/ascusages_client.go index 4c7f996fb36e..b4bd48cbf8a3 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/ascusages_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/ascusages_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // AscUsagesClient contains the methods for the AscUsages group. // Don't use this type directly, use NewAscUsagesClient() instead. type AscUsagesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAscUsagesClient creates a new instance of AscUsagesClient with the specified values. @@ -37,21 +34,13 @@ type AscUsagesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAscUsagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AscUsagesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AscUsagesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AscUsagesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -77,7 +66,7 @@ func (client *AscUsagesClient) NewListPager(location string, options *AscUsagesC if err != nil { return AscUsagesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AscUsagesClientListResponse{}, err } @@ -100,7 +89,7 @@ func (client *AscUsagesClient) listCreateRequest(ctx context.Context, location s return nil, errors.New("parameter location cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/ascusages_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/ascusages_client_example_test.go deleted file mode 100644 index 78dd3a362cd1..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/ascusages_client_example_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/AscResourceUsages_Get.json -func ExampleAscUsagesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewAscUsagesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("eastus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourceUsagesListResult = armstoragecache.ResourceUsagesListResult{ - // Value: []*armstoragecache.ResourceUsage{ - // { - // Name: &armstoragecache.ResourceUsageName{ - // LocalizedValue: to.Ptr("Cache"), - // Value: to.Ptr("Cache"), - // }, - // CurrentValue: to.Ptr[int32](1), - // Limit: to.Ptr[int32](4), - // Unit: to.Ptr("Count"), - // }, - // { - // Name: &armstoragecache.ResourceUsageName{ - // LocalizedValue: to.Ptr("AmlFilesystem"), - // Value: to.Ptr("AmlFilesystem"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](4), - // Unit: to.Ptr("Count"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/autorest.md b/sdk/resourcemanager/storagecache/armstoragecache/autorest.md index 22c984147126..9c9c35094eb6 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/autorest.md +++ b/sdk/resourcemanager/storagecache/armstoragecache/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/storagecache/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/storagecache/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 3.0.0 +module-version: 3.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/storagecache/armstoragecache/caches_client.go b/sdk/resourcemanager/storagecache/armstoragecache/caches_client.go index 2c4e19f06af7..fa30ad2d7220 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/caches_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/caches_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // CachesClient contains the methods for the Caches group. // Don't use this type directly, use NewCachesClient() instead. type CachesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCachesClient creates a new instance of CachesClient with the specified values. @@ -37,21 +34,13 @@ type CachesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCachesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CachesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CachesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CachesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,9 +61,9 @@ func (client *CachesClient) BeginCreateOrUpdate(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller[CachesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[CachesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CachesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *CachesClient) createOrUpdate(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +101,7 @@ func (client *CachesClient) createOrUpdateCreateRequest(ctx context.Context, res return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -136,11 +125,11 @@ func (client *CachesClient) BeginDebugInfo(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientDebugInfoResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientDebugInfoResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientDebugInfoResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientDebugInfoResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -153,7 +142,7 @@ func (client *CachesClient) debugInfo(ctx context.Context, resourceGroupName str if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -178,7 +167,7 @@ func (client *CachesClient) debugInfoCreateRequest(ctx context.Context, resource return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -202,9 +191,9 @@ func (client *CachesClient) BeginDelete(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - return runtime.NewPoller[CachesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[CachesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CachesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -217,7 +206,7 @@ func (client *CachesClient) deleteOperation(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -242,7 +231,7 @@ func (client *CachesClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -267,11 +256,11 @@ func (client *CachesClient) BeginFlush(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientFlushResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientFlushResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientFlushResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientFlushResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -285,7 +274,7 @@ func (client *CachesClient) flush(ctx context.Context, resourceGroupName string, if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -310,7 +299,7 @@ func (client *CachesClient) flushCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -333,7 +322,7 @@ func (client *CachesClient) Get(ctx context.Context, resourceGroupName string, c if err != nil { return CachesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CachesClientGetResponse{}, err } @@ -358,7 +347,7 @@ func (client *CachesClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -398,7 +387,7 @@ func (client *CachesClient) NewListPager(options *CachesClientListOptions) *runt if err != nil { return CachesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CachesClientListResponse{}, err } @@ -417,7 +406,7 @@ func (client *CachesClient) listCreateRequest(ctx context.Context, options *Cach return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -459,7 +448,7 @@ func (client *CachesClient) NewListByResourceGroupPager(resourceGroupName string if err != nil { return CachesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CachesClientListByResourceGroupResponse{}, err } @@ -482,7 +471,7 @@ func (client *CachesClient) listByResourceGroupCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -516,11 +505,11 @@ func (client *CachesClient) BeginPausePrimingJob(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientPausePrimingJobResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientPausePrimingJobResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientPausePrimingJobResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientPausePrimingJobResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -533,7 +522,7 @@ func (client *CachesClient) pausePrimingJob(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -558,7 +547,7 @@ func (client *CachesClient) pausePrimingJobCreateRequest(ctx context.Context, re return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -586,11 +575,11 @@ func (client *CachesClient) BeginResumePrimingJob(ctx context.Context, resourceG if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientResumePrimingJobResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientResumePrimingJobResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientResumePrimingJobResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientResumePrimingJobResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -603,7 +592,7 @@ func (client *CachesClient) resumePrimingJob(ctx context.Context, resourceGroupN if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -628,7 +617,7 @@ func (client *CachesClient) resumePrimingJobCreateRequest(ctx context.Context, r return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -656,11 +645,11 @@ func (client *CachesClient) BeginSpaceAllocation(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientSpaceAllocationResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientSpaceAllocationResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientSpaceAllocationResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientSpaceAllocationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -673,7 +662,7 @@ func (client *CachesClient) spaceAllocation(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -698,7 +687,7 @@ func (client *CachesClient) spaceAllocationCreateRequest(ctx context.Context, re return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -725,11 +714,11 @@ func (client *CachesClient) BeginStart(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientStartResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientStartResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -742,7 +731,7 @@ func (client *CachesClient) start(ctx context.Context, resourceGroupName string, if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -767,7 +756,7 @@ func (client *CachesClient) startCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -792,11 +781,11 @@ func (client *CachesClient) BeginStartPrimingJob(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientStartPrimingJobResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientStartPrimingJobResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientStartPrimingJobResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientStartPrimingJobResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -809,7 +798,7 @@ func (client *CachesClient) startPrimingJob(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -834,7 +823,7 @@ func (client *CachesClient) startPrimingJobCreateRequest(ctx context.Context, re return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -861,11 +850,11 @@ func (client *CachesClient) BeginStop(ctx context.Context, resourceGroupName str if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientStopResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientStopResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -878,7 +867,7 @@ func (client *CachesClient) stop(ctx context.Context, resourceGroupName string, if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -903,7 +892,7 @@ func (client *CachesClient) stopCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -928,11 +917,11 @@ func (client *CachesClient) BeginStopPrimingJob(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientStopPrimingJobResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientStopPrimingJobResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientStopPrimingJobResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientStopPrimingJobResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -945,7 +934,7 @@ func (client *CachesClient) stopPrimingJob(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -970,7 +959,7 @@ func (client *CachesClient) stopPrimingJobCreateRequest(ctx context.Context, res return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -999,11 +988,11 @@ func (client *CachesClient) BeginUpdate(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -1016,7 +1005,7 @@ func (client *CachesClient) update(ctx context.Context, resourceGroupName string if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -1041,7 +1030,7 @@ func (client *CachesClient) updateCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -1066,11 +1055,11 @@ func (client *CachesClient) BeginUpgradeFirmware(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CachesClientUpgradeFirmwareResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CachesClientUpgradeFirmwareResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CachesClientUpgradeFirmwareResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CachesClientUpgradeFirmwareResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -1083,7 +1072,7 @@ func (client *CachesClient) upgradeFirmware(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -1108,7 +1097,7 @@ func (client *CachesClient) upgradeFirmwareCreateRequest(ctx context.Context, re return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/caches_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/caches_client_example_test.go deleted file mode 100644 index c24d2251ba3d..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/caches_client_example_test.go +++ /dev/null @@ -1,1858 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_List.json -func ExampleCachesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.CachesListResult = armstoragecache.CachesListResult{ - // Value: []*armstoragecache.Cache{ - // { - // Name: to.Ptr("sc1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - // CacheNetBiosName: to.Ptr("contosoSmb"), - // DomainJoined: to.Ptr(armstoragecache.DomainJoinedTypeYes), - // DomainName: to.Ptr("contosoAd.contoso.local"), - // DomainNetBiosName: to.Ptr("contosoAd"), - // PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - // SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - // }, - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - // LdapServer: to.Ptr("192.0.2.12"), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - // }, - // }, - // EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - // KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - // KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - // SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - // }, - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // }, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // { - // Name: to.Ptr("st1"), - // AllocationPercentage: to.Ptr[int32](25), - // }, - // { - // Name: to.Ptr("st2"), - // AllocationPercentage: to.Ptr[int32](50), - // }, - // { - // Name: to.Ptr("st3"), - // AllocationPercentage: to.Ptr[int32](25), - // }}, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // }, - // { - // Name: to.Ptr("sc2"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc2"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - // CacheNetBiosName: to.Ptr("contosoSmb"), - // DomainJoined: to.Ptr(armstoragecache.DomainJoinedTypeYes), - // DomainName: to.Ptr("contosoAd.contoso.local"), - // DomainNetBiosName: to.Ptr("contosoAd"), - // PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - // SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - // }, - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr(""), - // LdapServer: to.Ptr(""), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceAD), - // }, - // }, - // EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - // KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - // KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - // SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - // }, - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // { - // PrimingJobDetails: to.Ptr("Files: Cached=635, Failed=0, Excluded=80, Data=346030 bytes, Directories: Cached=1003, Failed=0, Excluded=0"), - // PrimingJobID: to.Ptr("00000000000_0000000000"), - // PrimingJobName: to.Ptr("contosoJob1"), - // PrimingJobPercentComplete: to.Ptr[float64](100), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateComplete), - // PrimingJobStatus: to.Ptr("success"), - // }, - // { - // PrimingJobDetails: to.Ptr(""), - // PrimingJobID: to.Ptr("11111111111_1111111111"), - // PrimingJobName: to.Ptr("contosoJob2"), - // PrimingJobPercentComplete: to.Ptr[float64](0), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateQueued), - // PrimingJobStatus: to.Ptr(""), - // }}, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // }, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub2"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // Zones: []*string{ - // to.Ptr("1")}, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_ListByResourceGroup.json -func ExampleCachesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("scgroup", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.CachesListResult = armstoragecache.CachesListResult{ - // Value: []*armstoragecache.Cache{ - // { - // Name: to.Ptr("sc1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - // CacheNetBiosName: to.Ptr("contosoSmb"), - // DomainJoined: to.Ptr(armstoragecache.DomainJoinedTypeYes), - // DomainName: to.Ptr("contosoAd.contoso.local"), - // DomainNetBiosName: to.Ptr("contosoAd"), - // PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - // SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - // }, - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - // LdapServer: to.Ptr("192.0.2.12"), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - // }, - // }, - // EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - // KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - // KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - // SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - // }, - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // }, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // { - // Name: to.Ptr("st1"), - // AllocationPercentage: to.Ptr[int32](25), - // }, - // { - // Name: to.Ptr("st2"), - // AllocationPercentage: to.Ptr[int32](50), - // }, - // { - // Name: to.Ptr("st3"), - // AllocationPercentage: to.Ptr[int32](25), - // }}, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // Zones: []*string{ - // to.Ptr("1")}, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // }, - // { - // Name: to.Ptr("sc2"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc2"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - // CacheNetBiosName: to.Ptr("contosoSmb"), - // DomainJoined: to.Ptr(armstoragecache.DomainJoinedTypeYes), - // DomainName: to.Ptr("contosoAd.contoso.local"), - // DomainNetBiosName: to.Ptr("contosoAd"), - // PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - // SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - // }, - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr(""), - // LdapServer: to.Ptr(""), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceAD), - // }, - // }, - // EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - // KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - // KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - // SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - // }, - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // { - // PrimingJobDetails: to.Ptr("Files: Cached=635, Failed=0, Excluded=80, Data=346030 bytes, Directories: Cached=1003, Failed=0, Excluded=0"), - // PrimingJobID: to.Ptr("00000000000_0000000000"), - // PrimingJobName: to.Ptr("contosoJob1"), - // PrimingJobPercentComplete: to.Ptr[float64](100), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateComplete), - // PrimingJobStatus: to.Ptr("success"), - // }, - // { - // PrimingJobDetails: to.Ptr(""), - // PrimingJobID: to.Ptr("11111111111_1111111111"), - // PrimingJobName: to.Ptr("contosoJob2"), - // PrimingJobPercentComplete: to.Ptr[float64](0), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateQueued), - // PrimingJobStatus: to.Ptr(""), - // }}, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // }, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub2"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // Zones: []*string{ - // to.Ptr("2")}, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_Delete.json -func ExampleCachesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, "scgroup", "sc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_Get.json -func ExampleCachesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "scgroup", "sc1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cache = armstoragecache.Cache{ - // Name: to.Ptr("sc1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - // CacheNetBiosName: to.Ptr("contosoSmb"), - // DomainJoined: to.Ptr(armstoragecache.DomainJoinedTypeYes), - // DomainName: to.Ptr("contosoAd.contoso.local"), - // DomainNetBiosName: to.Ptr("contosoAd"), - // PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - // SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - // }, - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - // LdapServer: to.Ptr("192.0.2.12"), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - // }, - // }, - // EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - // KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - // KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - // SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - // }, - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // { - // PrimingJobDetails: to.Ptr("Files: Cached=635, Failed=0, Excluded=80, Data=346030 bytes, Directories: Cached=1003, Failed=0, Excluded=0"), - // PrimingJobID: to.Ptr("00000000000_0000000000"), - // PrimingJobName: to.Ptr("contosoJob1"), - // PrimingJobPercentComplete: to.Ptr[float64](100), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateComplete), - // PrimingJobStatus: to.Ptr("success"), - // }, - // { - // PrimingJobDetails: to.Ptr(""), - // PrimingJobID: to.Ptr("11111111111_1111111111"), - // PrimingJobName: to.Ptr("contosoJob2"), - // PrimingJobPercentComplete: to.Ptr[float64](0), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateQueued), - // PrimingJobStatus: to.Ptr(""), - // }}, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // { - // Name: to.Ptr("st1"), - // AllocationPercentage: to.Ptr[int32](25), - // }, - // { - // Name: to.Ptr("st2"), - // AllocationPercentage: to.Ptr[int32](50), - // }, - // { - // Name: to.Ptr("st3"), - // AllocationPercentage: to.Ptr[int32](25), - // }}, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // Zones: []*string{ - // to.Ptr("1")}, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_CreateOrUpdate.json -func ExampleCachesClient_BeginCreateOrUpdate_cachesCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, "scgroup", "sc1", armstoragecache.Cache{ - Identity: &armstoragecache.CacheIdentity{ - Type: to.Ptr(armstoragecache.CacheIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armstoragecache.UserAssignedIdentitiesValue{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1": {}, - }, - }, - Location: to.Ptr("westus"), - Properties: &armstoragecache.CacheProperties{ - CacheSizeGB: to.Ptr[int32](3072), - DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - CacheNetBiosName: to.Ptr("contosoSmb"), - Credentials: &armstoragecache.CacheActiveDirectorySettingsCredentials{ - Password: to.Ptr(""), - Username: to.Ptr("consotoAdmin"), - }, - DomainName: to.Ptr("contosoAd.contoso.local"), - DomainNetBiosName: to.Ptr("contosoAd"), - PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - }, - UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - Credentials: &armstoragecache.CacheUsernameDownloadSettingsCredentials{ - BindDn: to.Ptr("cn=ldapadmin,dc=contosoad,dc=contoso,dc=local"), - BindPassword: to.Ptr(""), - }, - ExtendedGroups: to.Ptr(true), - LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - LdapServer: to.Ptr("192.0.2.12"), - UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - }, - }, - EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2047/test"), - SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - }, - }, - }, - SecuritySettings: &armstoragecache.CacheSecuritySettings{ - AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - { - Name: to.Ptr("default"), - AccessRules: []*armstoragecache.NfsAccessRule{ - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(false), - }}, - }}, - }, - Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t }()), - UpgradeScheduleEnabled: to.Ptr(true), - }, - }, - SKU: &armstoragecache.CacheSKU{ - Name: to.Ptr("Standard_2G"), - }, - Tags: map[string]*string{ - "Dept": to.Ptr("Contoso"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cache = armstoragecache.Cache{ - // Name: to.Ptr("sc1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - // CacheNetBiosName: to.Ptr("contosoSmb"), - // DomainJoined: to.Ptr(armstoragecache.DomainJoinedTypeYes), - // DomainName: to.Ptr("contosoAd.contoso.local"), - // DomainNetBiosName: to.Ptr("contosoAd"), - // PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - // SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - // }, - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - // LdapServer: to.Ptr("192.0.2.12"), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - // }, - // }, - // EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - // KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - // KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - // SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - // }, - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // { - // PrimingJobDetails: to.Ptr("Files: Cached=635, Failed=0, Excluded=80, Data=346030 bytes, Directories: Cached=1003, Failed=0, Excluded=0"), - // PrimingJobID: to.Ptr("00000000000_0000000000"), - // PrimingJobName: to.Ptr("contosoJob1"), - // PrimingJobPercentComplete: to.Ptr[float64](100), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateComplete), - // PrimingJobStatus: to.Ptr("success"), - // }, - // { - // PrimingJobDetails: to.Ptr(""), - // PrimingJobID: to.Ptr("11111111111_1111111111"), - // PrimingJobName: to.Ptr("contosoJob2"), - // PrimingJobPercentComplete: to.Ptr[float64](0), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateQueued), - // PrimingJobStatus: to.Ptr(""), - // }}, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // }, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // Zones: []*string{ - // to.Ptr("1")}, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_CreateOrUpdate_ldap_only.json -func ExampleCachesClient_BeginCreateOrUpdate_cachesCreateOrUpdateLdapOnly() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, "scgroup", "sc1", armstoragecache.Cache{ - Location: to.Ptr("westus"), - Properties: &armstoragecache.CacheProperties{ - CacheSizeGB: to.Ptr[int32](3072), - DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - Credentials: &armstoragecache.CacheUsernameDownloadSettingsCredentials{ - BindDn: to.Ptr("cn=ldapadmin,dc=contosoad,dc=contoso,dc=local"), - BindPassword: to.Ptr(""), - }, - ExtendedGroups: to.Ptr(true), - LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - LdapServer: to.Ptr("192.0.2.12"), - UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - }, - }, - EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - }, - }, - }, - SecuritySettings: &armstoragecache.CacheSecuritySettings{ - AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - { - Name: to.Ptr("default"), - AccessRules: []*armstoragecache.NfsAccessRule{ - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(false), - }}, - }}, - }, - Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t }()), - UpgradeScheduleEnabled: to.Ptr(true), - }, - }, - SKU: &armstoragecache.CacheSKU{ - Name: to.Ptr("Standard_2G"), - }, - Tags: map[string]*string{ - "Dept": to.Ptr("Contoso"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cache = armstoragecache.Cache{ - // Name: to.Ptr("sc1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - // LdapServer: to.Ptr("192.0.2.12"), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - // }, - // }, - // EncryptionSettings: &armstoragecache.CacheEncryptionSettings{ - // KeyEncryptionKey: &armstoragecache.KeyVaultKeyReference{ - // KeyURL: to.Ptr("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), - // SourceVault: &armstoragecache.KeyVaultKeyReferenceSourceVault{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - // }, - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // { - // PrimingJobDetails: to.Ptr("Files: Cached=635, Failed=0, Excluded=80, Data=346030 bytes, Directories: Cached=1003, Failed=0, Excluded=0"), - // PrimingJobID: to.Ptr("00000000000_0000000000"), - // PrimingJobName: to.Ptr("contosoJob1"), - // PrimingJobPercentComplete: to.Ptr[float64](100), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateComplete), - // PrimingJobStatus: to.Ptr("success"), - // }, - // { - // PrimingJobDetails: to.Ptr(""), - // PrimingJobID: to.Ptr("11111111111_1111111111"), - // PrimingJobName: to.Ptr("contosoJob2"), - // PrimingJobPercentComplete: to.Ptr[float64](0), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateQueued), - // PrimingJobStatus: to.Ptr(""), - // }}, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // }, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // Zones: []*string{ - // to.Ptr("1")}, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_Update.json -func ExampleCachesClient_BeginUpdate_cachesUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "scgroup", "sc1", armstoragecache.Cache{ - Location: to.Ptr("westus"), - Properties: &armstoragecache.CacheProperties{ - CacheSizeGB: to.Ptr[int32](3072), - DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - CacheNetBiosName: to.Ptr("contosoSmb"), - DomainName: to.Ptr("contosoAd.contoso.local"), - DomainNetBiosName: to.Ptr("contosoAd"), - PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - }, - UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - ExtendedGroups: to.Ptr(true), - UsernameSource: to.Ptr(armstoragecache.UsernameSourceAD), - }, - }, - NetworkSettings: &armstoragecache.CacheNetworkSettings{ - DNSSearchDomain: to.Ptr("contoso.com"), - DNSServers: []*string{ - to.Ptr("10.1.22.33"), - to.Ptr("10.1.12.33")}, - Mtu: to.Ptr[int32](1500), - NtpServer: to.Ptr("time.contoso.com"), - }, - SecuritySettings: &armstoragecache.CacheSecuritySettings{ - AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - { - Name: to.Ptr("default"), - AccessRules: []*armstoragecache.NfsAccessRule{ - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(false), - }}, - }, - { - Name: to.Ptr("restrictive"), - AccessRules: []*armstoragecache.NfsAccessRule{ - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - Filter: to.Ptr("10.99.3.145"), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeHost), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(true), - }, - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - Filter: to.Ptr("10.99.1.0/24"), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeNetwork), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(true), - }, - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessNo), - AnonymousGID: to.Ptr("65534"), - AnonymousUID: to.Ptr("65534"), - RootSquash: to.Ptr(true), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(false), - }}, - }}, - }, - Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t }()), - UpgradeScheduleEnabled: to.Ptr(true), - }, - }, - SKU: &armstoragecache.CacheSKU{ - Name: to.Ptr("Standard_2G"), - }, - Tags: map[string]*string{ - "Dept": to.Ptr("Contoso"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cache = armstoragecache.Cache{ - // Name: to.Ptr("sc1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // ActiveDirectory: &armstoragecache.CacheActiveDirectorySettings{ - // CacheNetBiosName: to.Ptr("contosoSmb"), - // DomainJoined: to.Ptr(armstoragecache.DomainJoinedTypeYes), - // DomainName: to.Ptr("contosoAd.contoso.local"), - // DomainNetBiosName: to.Ptr("contosoAd"), - // PrimaryDNSIPAddress: to.Ptr("192.0.2.10"), - // SecondaryDNSIPAddress: to.Ptr("192.0.2.11"), - // }, - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr(""), - // LdapServer: to.Ptr(""), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeYes), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceAD), - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // { - // PrimingJobDetails: to.Ptr("Files: Cached=635, Failed=0, Excluded=80, Data=346030 bytes, Directories: Cached=1003, Failed=0, Excluded=0"), - // PrimingJobID: to.Ptr("00000000000_0000000000"), - // PrimingJobName: to.Ptr("contosoJob1"), - // PrimingJobPercentComplete: to.Ptr[float64](100), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateComplete), - // PrimingJobStatus: to.Ptr("success"), - // }, - // { - // PrimingJobDetails: to.Ptr(""), - // PrimingJobID: to.Ptr("11111111111_1111111111"), - // PrimingJobName: to.Ptr("contosoJob2"), - // PrimingJobPercentComplete: to.Ptr[float64](0), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateQueued), - // PrimingJobStatus: to.Ptr(""), - // }}, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }, - // { - // Name: to.Ptr("restrictive"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // Filter: to.Ptr("10.99.3.145"), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeHost), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(true), - // }, - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // Filter: to.Ptr("10.99.1.0/24"), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeNetwork), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(true), - // }, - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessNo), - // AnonymousGID: to.Ptr("65534"), - // AnonymousUID: to.Ptr("65534"), - // RootSquash: to.Ptr(true), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // { - // Name: to.Ptr("st1"), - // AllocationPercentage: to.Ptr[int32](25), - // }, - // { - // Name: to.Ptr("st2"), - // AllocationPercentage: to.Ptr[int32](50), - // }, - // { - // Name: to.Ptr("st3"), - // AllocationPercentage: to.Ptr[int32](25), - // }}, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_Update_ldap_only.json -func ExampleCachesClient_BeginUpdate_cachesUpdateLdapOnly() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "scgroup", "sc1", armstoragecache.Cache{ - Location: to.Ptr("westus"), - Properties: &armstoragecache.CacheProperties{ - CacheSizeGB: to.Ptr[int32](3072), - DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - Credentials: &armstoragecache.CacheUsernameDownloadSettingsCredentials{ - BindDn: to.Ptr("cn=ldapadmin,dc=contosoad,dc=contoso,dc=local"), - BindPassword: to.Ptr(""), - }, - ExtendedGroups: to.Ptr(true), - LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - LdapServer: to.Ptr("192.0.2.12"), - UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - }, - }, - NetworkSettings: &armstoragecache.CacheNetworkSettings{ - DNSSearchDomain: to.Ptr("contoso.com"), - DNSServers: []*string{ - to.Ptr("10.1.22.33"), - to.Ptr("10.1.12.33")}, - Mtu: to.Ptr[int32](1500), - NtpServer: to.Ptr("time.contoso.com"), - }, - SecuritySettings: &armstoragecache.CacheSecuritySettings{ - AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - { - Name: to.Ptr("default"), - AccessRules: []*armstoragecache.NfsAccessRule{ - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(false), - }}, - }, - { - Name: to.Ptr("restrictive"), - AccessRules: []*armstoragecache.NfsAccessRule{ - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - Filter: to.Ptr("10.99.3.145"), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeHost), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(true), - }, - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - Filter: to.Ptr("10.99.1.0/24"), - RootSquash: to.Ptr(false), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeNetwork), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(true), - }, - { - Access: to.Ptr(armstoragecache.NfsAccessRuleAccessNo), - AnonymousGID: to.Ptr("65534"), - AnonymousUID: to.Ptr("65534"), - RootSquash: to.Ptr(true), - Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - SubmountAccess: to.Ptr(true), - Suid: to.Ptr(false), - }}, - }}, - }, - Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t }()), - UpgradeScheduleEnabled: to.Ptr(true), - }, - }, - SKU: &armstoragecache.CacheSKU{ - Name: to.Ptr("Standard_2G"), - }, - Tags: map[string]*string{ - "Dept": to.Ptr("Contoso"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cache = armstoragecache.Cache{ - // Name: to.Ptr("sc1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1"), - // Location: to.Ptr("westus"), - // Properties: &armstoragecache.CacheProperties{ - // CacheSizeGB: to.Ptr[int32](3072), - // DirectoryServicesSettings: &armstoragecache.CacheDirectorySettings{ - // UsernameDownload: &armstoragecache.CacheUsernameDownloadSettings{ - // AutoDownloadCertificate: to.Ptr(false), - // CaCertificateURI: to.Ptr(""), - // EncryptLdapConnection: to.Ptr(false), - // ExtendedGroups: to.Ptr(true), - // GroupFileURI: to.Ptr(""), - // LdapBaseDN: to.Ptr("dc=contosoad,dc=contoso,dc=local"), - // LdapServer: to.Ptr("192.0.2.12"), - // RequireValidCertificate: to.Ptr(false), - // UserFileURI: to.Ptr(""), - // UsernameDownloaded: to.Ptr(armstoragecache.UsernameDownloadedTypeNo), - // UsernameSource: to.Ptr(armstoragecache.UsernameSourceLDAP), - // }, - // }, - // Health: &armstoragecache.CacheHealth{ - // Conditions: []*armstoragecache.Condition{ - // { - // Message: to.Ptr("Cannot contact DNS server"), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-21T18:25:43.511Z"); return t}()), - // }}, - // State: to.Ptr(armstoragecache.HealthStateTypeTransitioning), - // StatusDescription: to.Ptr("Cache is being created."), - // }, - // MountAddresses: []*string{ - // to.Ptr("192.168.1.1"), - // to.Ptr("192.168.1.2")}, - // NetworkSettings: &armstoragecache.CacheNetworkSettings{ - // DNSSearchDomain: to.Ptr("contoso.com"), - // DNSServers: []*string{ - // to.Ptr("10.1.22.33"), - // to.Ptr("10.1.12.33")}, - // Mtu: to.Ptr[int32](1500), - // NtpServer: to.Ptr("time.contoso.com"), - // }, - // PrimingJobs: []*armstoragecache.PrimingJob{ - // { - // PrimingJobDetails: to.Ptr("Files: Cached=635, Failed=0, Excluded=80, Data=346030 bytes, Directories: Cached=1003, Failed=0, Excluded=0"), - // PrimingJobID: to.Ptr("00000000000_0000000000"), - // PrimingJobName: to.Ptr("contosoJob1"), - // PrimingJobPercentComplete: to.Ptr[float64](100), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateComplete), - // PrimingJobStatus: to.Ptr("success"), - // }, - // { - // PrimingJobDetails: to.Ptr(""), - // PrimingJobID: to.Ptr("11111111111_1111111111"), - // PrimingJobName: to.Ptr("contosoJob2"), - // PrimingJobPercentComplete: to.Ptr[float64](0), - // PrimingJobState: to.Ptr(armstoragecache.PrimingJobStateQueued), - // PrimingJobStatus: to.Ptr(""), - // }}, - // ProvisioningState: to.Ptr(armstoragecache.ProvisioningStateTypeSucceeded), - // SecuritySettings: &armstoragecache.CacheSecuritySettings{ - // AccessPolicies: []*armstoragecache.NfsAccessPolicy{ - // { - // Name: to.Ptr("default"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }, - // { - // Name: to.Ptr("restrictive"), - // AccessRules: []*armstoragecache.NfsAccessRule{ - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // Filter: to.Ptr("10.99.3.145"), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeHost), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(true), - // }, - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessRw), - // Filter: to.Ptr("10.99.1.0/24"), - // RootSquash: to.Ptr(false), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeNetwork), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(true), - // }, - // { - // Access: to.Ptr(armstoragecache.NfsAccessRuleAccessNo), - // AnonymousGID: to.Ptr("65534"), - // AnonymousUID: to.Ptr("65534"), - // RootSquash: to.Ptr(true), - // Scope: to.Ptr(armstoragecache.NfsAccessRuleScopeDefault), - // SubmountAccess: to.Ptr(true), - // Suid: to.Ptr(false), - // }}, - // }}, - // }, - // SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - // }, - // Subnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - // UpgradeSettings: &armstoragecache.CacheUpgradeSettings{ - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-26T18:25:43.511Z"); return t}()), - // UpgradeScheduleEnabled: to.Ptr(true), - // }, - // UpgradeStatus: &armstoragecache.CacheUpgradeStatus{ - // CurrentFirmwareVersion: to.Ptr("V5.1.12"), - // FirmwareUpdateDeadline: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-21T18:25:43.511Z"); return t}()), - // FirmwareUpdateStatus: to.Ptr(armstoragecache.FirmwareStatusTypeAvailable), - // LastFirmwareUpdate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-01-21T18:25:43.511Z"); return t}()), - // PendingFirmwareVersion: to.Ptr("V5.1.15"), - // }, - // }, - // SKU: &armstoragecache.CacheSKU{ - // Name: to.Ptr("Standard_2G"), - // }, - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Tags: map[string]*string{ - // "Dept": to.Ptr("Contoso"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_DebugInfo.json -func ExampleCachesClient_BeginDebugInfo() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDebugInfo(ctx, "scgroup", "sc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_Flush.json -func ExampleCachesClient_BeginFlush() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginFlush(ctx, "scgroup", "sc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_Start.json -func ExampleCachesClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStart(ctx, "scgroup", "sc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_Stop.json -func ExampleCachesClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStop(ctx, "scgroup", "sc", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StartPrimingJob.json -func ExampleCachesClient_BeginStartPrimingJob() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStartPrimingJob(ctx, "scgroup", "sc1", &armstoragecache.CachesClientBeginStartPrimingJobOptions{Primingjob: &armstoragecache.PrimingJob{ - PrimingJobName: to.Ptr("contosoJob"), - PrimingManifestURL: to.Ptr("https://contosostorage.blob.core.windows.net/contosoblob/00000000_00000000000000000000000000000000.00000000000.FFFFFFFF.00000000?sp=r&st=2021-08-11T19:33:35Z&se=2021-08-12T03:33:35Z&spr=https&sv=2020-08-04&sr=b&sig="), - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StopPrimingJob.json -func ExampleCachesClient_BeginStopPrimingJob() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStopPrimingJob(ctx, "scgroup", "sc1", &armstoragecache.CachesClientBeginStopPrimingJobOptions{PrimingJobID: &armstoragecache.PrimingJobIDParameter{ - PrimingJobID: to.Ptr("00000000000_0000000000"), - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/PausePrimingJob.json -func ExampleCachesClient_BeginPausePrimingJob() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginPausePrimingJob(ctx, "scgroup", "sc1", &armstoragecache.CachesClientBeginPausePrimingJobOptions{PrimingJobID: &armstoragecache.PrimingJobIDParameter{ - PrimingJobID: to.Ptr("00000000000_0000000000"), - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/ResumePrimingJob.json -func ExampleCachesClient_BeginResumePrimingJob() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginResumePrimingJob(ctx, "scgroup", "sc1", &armstoragecache.CachesClientBeginResumePrimingJobOptions{PrimingJobID: &armstoragecache.PrimingJobIDParameter{ - PrimingJobID: to.Ptr("00000000000_0000000000"), - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Caches_UpgradeFirmware.json -func ExampleCachesClient_BeginUpgradeFirmware() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpgradeFirmware(ctx, "scgroup", "sc1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/SpaceAllocation_Post.json -func ExampleCachesClient_BeginSpaceAllocation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewCachesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginSpaceAllocation(ctx, "scgroup", "sc1", &armstoragecache.CachesClientBeginSpaceAllocationOptions{SpaceAllocation: []*armstoragecache.StorageTargetSpaceAllocation{ - { - Name: to.Ptr("st1"), - AllocationPercentage: to.Ptr[int32](25), - }, - { - Name: to.Ptr("st2"), - AllocationPercentage: to.Ptr[int32](50), - }, - { - Name: to.Ptr("st3"), - AllocationPercentage: to.Ptr[int32](25), - }}, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/client_factory.go b/sdk/resourcemanager/storagecache/armstoragecache/client_factory.go new file mode 100644 index 000000000000..79548a0c0276 --- /dev/null +++ b/sdk/resourcemanager/storagecache/armstoragecache/client_factory.go @@ -0,0 +1,80 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armstoragecache + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms +// part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSKUsClient() *SKUsClient { + subClient, _ := NewSKUsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewUsageModelsClient() *UsageModelsClient { + subClient, _ := NewUsageModelsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAscOperationsClient() *AscOperationsClient { + subClient, _ := NewAscOperationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAscUsagesClient() *AscUsagesClient { + subClient, _ := NewAscUsagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCachesClient() *CachesClient { + subClient, _ := NewCachesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStorageTargetsClient() *StorageTargetsClient { + subClient, _ := NewStorageTargetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStorageTargetClient() *StorageTargetClient { + subClient, _ := NewStorageTargetClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/constants.go b/sdk/resourcemanager/storagecache/armstoragecache/constants.go index 93f392a218bc..ffeb533187ac 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/constants.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/constants.go @@ -11,7 +11,7 @@ package armstoragecache const ( moduleName = "armstoragecache" - moduleVersion = "v3.0.0" + moduleVersion = "v3.1.0" ) // CacheIdentityType - The type of identity used for the cache diff --git a/sdk/resourcemanager/storagecache/armstoragecache/go.mod b/sdk/resourcemanager/storagecache/armstoragecache/go.mod index 66912cc248cf..3848f670befe 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/go.mod +++ b/sdk/resourcemanager/storagecache/armstoragecache/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armsto go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/storagecache/armstoragecache/go.sum b/sdk/resourcemanager/storagecache/armstoragecache/go.sum index 67cfef6bdf6e..f54c298864a1 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/go.sum +++ b/sdk/resourcemanager/storagecache/armstoragecache/go.sum @@ -1,30 +1,15 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/storagecache/armstoragecache/operations_client.go b/sdk/resourcemanager/storagecache/armstoragecache/operations_client.go index 80ec3a631226..b4d5f49059be 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/operations_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,28 +21,19 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -84,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.StorageCache/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/operations_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/operations_client_example_test.go deleted file mode 100644 index b4238322d296..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/operations_client_example_test.go +++ /dev/null @@ -1,102 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.APIOperationListResult = armstoragecache.APIOperationListResult{ - // Value: []*armstoragecache.APIOperation{ - // { - // Name: to.Ptr("Microsoft.StorageCache/caches/write"), - // Display: &armstoragecache.APIOperationDisplay{ - // Operation: to.Ptr("Create or Update Cache"), - // Provider: to.Ptr("Azure Storage Cache"), - // Resource: to.Ptr("Caches"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.StorageCache/caches/delete"), - // Display: &armstoragecache.APIOperationDisplay{ - // Operation: to.Ptr("Delete Cache"), - // Provider: to.Ptr("Azure Storage Cache"), - // Resource: to.Ptr("Caches"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.StorageCache/caches/providers/Microsoft.Insights/metricDefinitions/read"), - // Display: &armstoragecache.APIOperationDisplay{ - // Description: to.Ptr("Reads Cache Metric Definitions."), - // Operation: to.Ptr("Get Cache Metric Definitions"), - // Provider: to.Ptr("Microsoft Azure HPC Cache"), - // Resource: to.Ptr("StorageCache Metric Definitions"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("system"), - // Properties: &armstoragecache.APIOperationProperties{ - // ServiceSpecification: &armstoragecache.APIOperationPropertiesServiceSpecification{ - // MetricSpecifications: []*armstoragecache.MetricSpecification{ - // { - // Name: to.Ptr("ClientIOPS"), - // AggregationType: to.Ptr("Average"), - // DisplayDescription: to.Ptr("The rate of client file operations processed by the Cache."), - // DisplayName: to.Ptr("Total Client IOPS"), - // MetricClass: to.Ptr("Transactions"), - // SupportedAggregationTypes: []*armstoragecache.MetricAggregationType{ - // to.Ptr(armstoragecache.MetricAggregationTypeMinimum), - // to.Ptr(armstoragecache.MetricAggregationTypeMaximum), - // to.Ptr(armstoragecache.MetricAggregationTypeAverage)}, - // Unit: to.Ptr("Count"), - // }, - // { - // Name: to.Ptr("ClientLatency"), - // AggregationType: to.Ptr("Average"), - // DisplayDescription: to.Ptr("Average latency of client file operations to the Cache."), - // DisplayName: to.Ptr("Average Client Latency"), - // MetricClass: to.Ptr("Latency"), - // SupportedAggregationTypes: []*armstoragecache.MetricAggregationType{ - // to.Ptr(armstoragecache.MetricAggregationTypeMinimum), - // to.Ptr(armstoragecache.MetricAggregationTypeMaximum), - // to.Ptr(armstoragecache.MetricAggregationTypeAverage)}, - // Unit: to.Ptr("Milliseconds"), - // }}, - // }, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/skus_client.go b/sdk/resourcemanager/storagecache/armstoragecache/skus_client.go index c5696adecce4..d74e6d30547e 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/skus_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/skus_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SKUsClient contains the methods for the SKUs group. // Don't use this type directly, use NewSKUsClient() instead. type SKUsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSKUsClient creates a new instance of SKUsClient with the specified values. @@ -37,21 +34,13 @@ type SKUsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SKUsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SKUsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -76,7 +65,7 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. if err != nil { return SKUsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SKUsClientListResponse{}, err } @@ -95,7 +84,7 @@ func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsCl return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/skus_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/skus_client_example_test.go deleted file mode 100644 index 08020555bf2c..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/skus_client_example_test.go +++ /dev/null @@ -1,115 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/Skus_List.json -func ExampleSKUsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewSKUsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourceSKUsResult = armstoragecache.ResourceSKUsResult{ - // Value: []*armstoragecache.ResourceSKU{ - // { - // Name: to.Ptr("Standard_2G"), - // Capabilities: []*armstoragecache.ResourceSKUCapabilities{ - // { - // Name: to.Ptr("throughput GB/s"), - // Value: to.Ptr("2"), - // }, - // { - // Name: to.Ptr("cache sizes(GB)"), - // Value: to.Ptr("3072,6144,12288"), - // }}, - // LocationInfo: []*armstoragecache.ResourceSKULocationInfo{ - // { - // Location: to.Ptr("eastus"), - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("caches"), - // Restrictions: []*armstoragecache.Restriction{ - // }, - // }, - // { - // Name: to.Ptr("Standard_4G"), - // Capabilities: []*armstoragecache.ResourceSKUCapabilities{ - // { - // Name: to.Ptr("throughput GB/s"), - // Value: to.Ptr("4"), - // }, - // { - // Name: to.Ptr("cache sizes(GB)"), - // Value: to.Ptr("6144,12288,24576"), - // }}, - // LocationInfo: []*armstoragecache.ResourceSKULocationInfo{ - // { - // Location: to.Ptr("eastus"), - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("caches"), - // Restrictions: []*armstoragecache.Restriction{ - // }, - // }, - // { - // Name: to.Ptr("Standard_8G"), - // Capabilities: []*armstoragecache.ResourceSKUCapabilities{ - // { - // Name: to.Ptr("throughput GB/s"), - // Value: to.Ptr("8"), - // }, - // { - // Name: to.Ptr("cache sizes(GB)"), - // Value: to.Ptr("12288,24576,49152"), - // }}, - // LocationInfo: []*armstoragecache.ResourceSKULocationInfo{ - // { - // Location: to.Ptr("eastus"), - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("caches"), - // Restrictions: []*armstoragecache.Restriction{ - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/storagetarget_client.go b/sdk/resourcemanager/storagecache/armstoragecache/storagetarget_client.go index 6e52db175789..b8990df08bf3 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/storagetarget_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/storagetarget_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // StorageTargetClient contains the methods for the StorageTarget group. // Don't use this type directly, use NewStorageTargetClient() instead. type StorageTargetClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewStorageTargetClient creates a new instance of StorageTargetClient with the specified values. @@ -37,21 +34,13 @@ type StorageTargetClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewStorageTargetClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StorageTargetClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".StorageTargetClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &StorageTargetClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,11 +61,11 @@ func (client *StorageTargetClient) BeginFlush(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageTargetClientFlushResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageTargetClientFlushResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[StorageTargetClientFlushResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetClientFlushResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -90,7 +79,7 @@ func (client *StorageTargetClient) flush(ctx context.Context, resourceGroupName if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -119,7 +108,7 @@ func (client *StorageTargetClient) flushCreateRequest(ctx context.Context, resou return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -146,11 +135,11 @@ func (client *StorageTargetClient) BeginInvalidate(ctx context.Context, resource if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageTargetClientInvalidateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageTargetClientInvalidateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[StorageTargetClientInvalidateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetClientInvalidateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -164,7 +153,7 @@ func (client *StorageTargetClient) invalidate(ctx context.Context, resourceGroup if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -193,7 +182,7 @@ func (client *StorageTargetClient) invalidateCreateRequest(ctx context.Context, return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -219,11 +208,11 @@ func (client *StorageTargetClient) BeginResume(ctx context.Context, resourceGrou if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageTargetClientResumeResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageTargetClientResumeResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[StorageTargetClientResumeResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetClientResumeResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -236,7 +225,7 @@ func (client *StorageTargetClient) resume(ctx context.Context, resourceGroupName if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -265,7 +254,7 @@ func (client *StorageTargetClient) resumeCreateRequest(ctx context.Context, reso return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -291,11 +280,11 @@ func (client *StorageTargetClient) BeginSuspend(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageTargetClientSuspendResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageTargetClientSuspendResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[StorageTargetClientSuspendResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetClientSuspendResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -308,7 +297,7 @@ func (client *StorageTargetClient) suspend(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -337,7 +326,7 @@ func (client *StorageTargetClient) suspendCreateRequest(ctx context.Context, res return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/storagetarget_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/storagetarget_client_example_test.go deleted file mode 100644 index e5ca75fe5de2..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/storagetarget_client_example_test.go +++ /dev/null @@ -1,102 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_Flush.json -func ExampleStorageTargetClient_BeginFlush() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginFlush(ctx, "scgroup", "sc", "st1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_Suspend.json -func ExampleStorageTargetClient_BeginSuspend() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginSuspend(ctx, "scgroup", "sc", "st1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_Resume.json -func ExampleStorageTargetClient_BeginResume() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginResume(ctx, "scgroup", "sc", "st1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_Invalidate.json -func ExampleStorageTargetClient_BeginInvalidate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginInvalidate(ctx, "scgroup", "sc", "st1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/storagetargets_client.go b/sdk/resourcemanager/storagecache/armstoragecache/storagetargets_client.go index 963bc9039b8b..70bcea04e460 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/storagetargets_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/storagetargets_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // StorageTargetsClient contains the methods for the StorageTargets group. // Don't use this type directly, use NewStorageTargetsClient() instead. type StorageTargetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewStorageTargetsClient creates a new instance of StorageTargetsClient with the specified values. @@ -37,21 +34,13 @@ type StorageTargetsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewStorageTargetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StorageTargetsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".StorageTargetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &StorageTargetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -74,9 +63,9 @@ func (client *StorageTargetsClient) BeginCreateOrUpdate(ctx context.Context, res if err != nil { return nil, err } - return runtime.NewPoller[StorageTargetsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[StorageTargetsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StorageTargetsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -91,7 +80,7 @@ func (client *StorageTargetsClient) createOrUpdate(ctx context.Context, resource if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -120,7 +109,7 @@ func (client *StorageTargetsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -146,11 +135,11 @@ func (client *StorageTargetsClient) BeginDNSRefresh(ctx context.Context, resourc if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageTargetsClientDNSRefreshResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageTargetsClientDNSRefreshResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[StorageTargetsClientDNSRefreshResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetsClientDNSRefreshResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -163,7 +152,7 @@ func (client *StorageTargetsClient) dNSRefresh(ctx context.Context, resourceGrou if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -192,7 +181,7 @@ func (client *StorageTargetsClient) dnsRefreshCreateRequest(ctx context.Context, return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -221,9 +210,9 @@ func (client *StorageTargetsClient) BeginDelete(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller[StorageTargetsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[StorageTargetsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[StorageTargetsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -239,7 +228,7 @@ func (client *StorageTargetsClient) deleteOperation(ctx context.Context, resourc if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -268,7 +257,7 @@ func (client *StorageTargetsClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -295,7 +284,7 @@ func (client *StorageTargetsClient) Get(ctx context.Context, resourceGroupName s if err != nil { return StorageTargetsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StorageTargetsClientGetResponse{}, err } @@ -324,7 +313,7 @@ func (client *StorageTargetsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -367,7 +356,7 @@ func (client *StorageTargetsClient) NewListByCachePager(resourceGroupName string if err != nil { return StorageTargetsClientListByCacheResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StorageTargetsClientListByCacheResponse{}, err } @@ -394,7 +383,7 @@ func (client *StorageTargetsClient) listByCacheCreateRequest(ctx context.Context return nil, errors.New("parameter cacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{cacheName}", url.PathEscape(cacheName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -429,11 +418,11 @@ func (client *StorageTargetsClient) BeginRestoreDefaults(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageTargetsClientRestoreDefaultsResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StorageTargetsClientRestoreDefaultsResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[StorageTargetsClientRestoreDefaultsResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[StorageTargetsClientRestoreDefaultsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -446,7 +435,7 @@ func (client *StorageTargetsClient) restoreDefaults(ctx context.Context, resourc if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -475,7 +464,7 @@ func (client *StorageTargetsClient) restoreDefaultsCreateRequest(ctx context.Con return nil, errors.New("parameter storageTargetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{storageTargetName}", url.PathEscape(storageTargetName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/storagetargets_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/storagetargets_client_example_test.go deleted file mode 100644 index 7205edfc36b3..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/storagetargets_client_example_test.go +++ /dev/null @@ -1,459 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_DnsRefresh.json -func ExampleStorageTargetsClient_BeginDNSRefresh() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDNSRefresh(ctx, "scgroup", "sc", "st1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_ListByCache.json -func ExampleStorageTargetsClient_NewListByCachePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByCachePager("scgroup", "sc1", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.StorageTargetsResult = armstoragecache.StorageTargetsResult{ - // Value: []*armstoragecache.StorageTarget{ - // { - // Name: to.Ptr("st1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache/StorageTarget"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1/storagetargets/st1"), - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Properties: &armstoragecache.StorageTargetProperties{ - // AllocationPercentage: to.Ptr[int32](25), - // Junctions: []*armstoragecache.NamespaceJunction{ - // { - // NamespacePath: to.Ptr("/path/on/cache"), - // NfsAccessPolicy: to.Ptr("default"), - // NfsExport: to.Ptr("exp1"), - // TargetPath: to.Ptr("/path/on/exp1"), - // }, - // { - // NamespacePath: to.Ptr("/path2/on/cache"), - // NfsAccessPolicy: to.Ptr("default"), - // NfsExport: to.Ptr("exp2"), - // TargetPath: to.Ptr("/path2/on/exp2"), - // }}, - // Nfs3: &armstoragecache.Nfs3Target{ - // Target: to.Ptr("10.0.44.44"), - // UsageModel: to.Ptr("READ_ONLY"), - // }, - // State: to.Ptr(armstoragecache.OperationalStateTypeReady), - // TargetType: to.Ptr(armstoragecache.StorageTargetTypeNfs3), - // }, - // }, - // { - // Name: to.Ptr("st2"), - // Type: to.Ptr("Microsoft.StorageCache/Cache/StorageTarget"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1/storagetargets/st2"), - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Properties: &armstoragecache.StorageTargetProperties{ - // AllocationPercentage: to.Ptr[int32](50), - // Clfs: &armstoragecache.ClfsTarget{ - // Target: to.Ptr("https://contoso123.blob.core.windows.net/contoso123"), - // }, - // Junctions: []*armstoragecache.NamespaceJunction{ - // { - // NamespacePath: to.Ptr("/some/arbitrary/place/on/cache"), - // NfsAccessPolicy: to.Ptr("default"), - // TargetPath: to.Ptr("/"), - // }}, - // State: to.Ptr(armstoragecache.OperationalStateTypeReady), - // TargetType: to.Ptr(armstoragecache.StorageTargetTypeClfs), - // }, - // }, - // { - // Name: to.Ptr("st3"), - // Type: to.Ptr("Microsoft.StorageCache/Cache/StorageTarget"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1/storagetargets/st3"), - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Properties: &armstoragecache.StorageTargetProperties{ - // AllocationPercentage: to.Ptr[int32](25), - // Junctions: []*armstoragecache.NamespaceJunction{ - // { - // NamespacePath: to.Ptr("/some/crazier/place/on/cache"), - // NfsAccessPolicy: to.Ptr("default"), - // NfsExport: to.Ptr(""), - // TargetPath: to.Ptr("/"), - // }}, - // State: to.Ptr(armstoragecache.OperationalStateTypeReady), - // TargetType: to.Ptr(armstoragecache.StorageTargetTypeUnknown), - // Unknown: &armstoragecache.UnknownTarget{ - // Attributes: map[string]*string{ - // "foo": to.Ptr("bar"), - // "foo2": to.Ptr("test"), - // }, - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_Delete.json -func ExampleStorageTargetsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, "scgroup", "sc1", "st1", &armstoragecache.StorageTargetsClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_Get.json -func ExampleStorageTargetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "scgroup", "sc1", "st1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.StorageTarget = armstoragecache.StorageTarget{ - // Name: to.Ptr("st1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache/StorageTarget"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1/storagetargets/st1"), - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Properties: &armstoragecache.StorageTargetProperties{ - // AllocationPercentage: to.Ptr[int32](25), - // Junctions: []*armstoragecache.NamespaceJunction{ - // { - // NamespacePath: to.Ptr("/path/on/cache"), - // NfsAccessPolicy: to.Ptr("default"), - // NfsExport: to.Ptr("exp1"), - // TargetPath: to.Ptr("/path/on/exp1"), - // }, - // { - // NamespacePath: to.Ptr("/path2/on/cache"), - // NfsAccessPolicy: to.Ptr("default"), - // NfsExport: to.Ptr("exp2"), - // TargetPath: to.Ptr("/path2/on/exp2"), - // }}, - // Nfs3: &armstoragecache.Nfs3Target{ - // Target: to.Ptr("10.0.44.44"), - // UsageModel: to.Ptr("READ_HEAVY_FREQ"), - // }, - // State: to.Ptr(armstoragecache.OperationalStateTypeReady), - // TargetType: to.Ptr(armstoragecache.StorageTargetTypeNfs3), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_CreateOrUpdate.json -func ExampleStorageTargetsClient_BeginCreateOrUpdate_storageTargetsCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, "scgroup", "sc1", "st1", armstoragecache.StorageTarget{ - Properties: &armstoragecache.StorageTargetProperties{ - Junctions: []*armstoragecache.NamespaceJunction{ - { - NamespacePath: to.Ptr("/path/on/cache"), - NfsAccessPolicy: to.Ptr("default"), - NfsExport: to.Ptr("exp1"), - TargetPath: to.Ptr("/path/on/exp1"), - }, - { - NamespacePath: to.Ptr("/path2/on/cache"), - NfsAccessPolicy: to.Ptr("rootSquash"), - NfsExport: to.Ptr("exp2"), - TargetPath: to.Ptr("/path2/on/exp2"), - }}, - Nfs3: &armstoragecache.Nfs3Target{ - Target: to.Ptr("10.0.44.44"), - UsageModel: to.Ptr("READ_ONLY"), - VerificationTimer: to.Ptr[int32](30), - }, - TargetType: to.Ptr(armstoragecache.StorageTargetTypeNfs3), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.StorageTarget = armstoragecache.StorageTarget{ - // Name: to.Ptr("st1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache/StorageTarget"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1/storagetargets/st1"), - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Properties: &armstoragecache.StorageTargetProperties{ - // Junctions: []*armstoragecache.NamespaceJunction{ - // { - // NamespacePath: to.Ptr("/path/on/cache"), - // NfsAccessPolicy: to.Ptr("default"), - // NfsExport: to.Ptr("exp1"), - // TargetPath: to.Ptr("/path/on/exp1"), - // }, - // { - // NamespacePath: to.Ptr("/path2/on/cache"), - // NfsAccessPolicy: to.Ptr("rootSquash"), - // NfsExport: to.Ptr("exp2"), - // TargetPath: to.Ptr("/path2/on/exp2"), - // }}, - // Nfs3: &armstoragecache.Nfs3Target{ - // Target: to.Ptr("10.0.44.44"), - // UsageModel: to.Ptr("READ_ONLY"), - // VerificationTimer: to.Ptr[int32](30), - // }, - // State: to.Ptr(armstoragecache.OperationalStateTypeReady), - // TargetType: to.Ptr(armstoragecache.StorageTargetTypeNfs3), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_CreateOrUpdate_BlobNfs.json -func ExampleStorageTargetsClient_BeginCreateOrUpdate_storageTargetsCreateOrUpdateBlobNfs() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, "scgroup", "sc1", "st1", armstoragecache.StorageTarget{ - Properties: &armstoragecache.StorageTargetProperties{ - BlobNfs: &armstoragecache.BlobNfsTarget{ - Target: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/blofnfs/blobServices/default/containers/blobnfs"), - UsageModel: to.Ptr("READ_WRITE"), - VerificationTimer: to.Ptr[int32](28800), - WriteBackTimer: to.Ptr[int32](3600), - }, - Junctions: []*armstoragecache.NamespaceJunction{ - { - NamespacePath: to.Ptr("/blobnfs"), - }}, - TargetType: to.Ptr(armstoragecache.StorageTargetTypeBlobNfs), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.StorageTarget = armstoragecache.StorageTarget{ - // Name: to.Ptr("st1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache/StorageTarget"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1/storagetargets/st1"), - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Properties: &armstoragecache.StorageTargetProperties{ - // BlobNfs: &armstoragecache.BlobNfsTarget{ - // Target: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/blofnfs/blobServices/default/containers/blobnfs"), - // UsageModel: to.Ptr("READ_WRITE"), - // VerificationTimer: to.Ptr[int32](28800), - // WriteBackTimer: to.Ptr[int32](3600), - // }, - // Junctions: []*armstoragecache.NamespaceJunction{ - // { - // NamespacePath: to.Ptr("/blobnfs"), - // }}, - // State: to.Ptr(armstoragecache.OperationalStateTypeReady), - // TargetType: to.Ptr(armstoragecache.StorageTargetTypeBlobNfs), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_CreateOrUpdate_NoJunctions.json -func ExampleStorageTargetsClient_BeginCreateOrUpdate_storageTargetsCreateOrUpdateNoJunctions() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, "scgroup", "sc1", "st1", armstoragecache.StorageTarget{ - Properties: &armstoragecache.StorageTargetProperties{ - Nfs3: &armstoragecache.Nfs3Target{ - Target: to.Ptr("10.0.44.44"), - UsageModel: to.Ptr("READ_ONLY"), - VerificationTimer: to.Ptr[int32](30), - }, - TargetType: to.Ptr(armstoragecache.StorageTargetTypeNfs3), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.StorageTarget = armstoragecache.StorageTarget{ - // Name: to.Ptr("st1"), - // Type: to.Ptr("Microsoft.StorageCache/Cache/StorageTarget"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.StorageCache/caches/sc1/storagetargets/st1"), - // SystemData: &armstoragecache.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T17:18:19.1234567Z"); return t}()), - // CreatedBy: to.Ptr("user1"), - // CreatedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-02T17:18:19.1234567Z"); return t}()), - // LastModifiedBy: to.Ptr("user2"), - // LastModifiedByType: to.Ptr(armstoragecache.CreatedByTypeUser), - // }, - // Properties: &armstoragecache.StorageTargetProperties{ - // Nfs3: &armstoragecache.Nfs3Target{ - // Target: to.Ptr("10.0.44.44"), - // UsageModel: to.Ptr("READ_ONLY"), - // VerificationTimer: to.Ptr[int32](30), - // }, - // State: to.Ptr(armstoragecache.OperationalStateTypeReady), - // TargetType: to.Ptr(armstoragecache.StorageTargetTypeNfs3), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/StorageTargets_RestoreDefaults.json -func ExampleStorageTargetsClient_BeginRestoreDefaults() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewStorageTargetsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRestoreDefaults(ctx, "scgroup", "sc", "st1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/storagecache/armstoragecache/usagemodels_client.go b/sdk/resourcemanager/storagecache/armstoragecache/usagemodels_client.go index db36d4f553ac..6a2a6d7a3d65 100644 --- a/sdk/resourcemanager/storagecache/armstoragecache/usagemodels_client.go +++ b/sdk/resourcemanager/storagecache/armstoragecache/usagemodels_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // UsageModelsClient contains the methods for the UsageModels group. // Don't use this type directly, use NewUsageModelsClient() instead. type UsageModelsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUsageModelsClient creates a new instance of UsageModelsClient with the specified values. @@ -37,21 +34,13 @@ type UsageModelsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewUsageModelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsageModelsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".UsageModelsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UsageModelsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -76,7 +65,7 @@ func (client *UsageModelsClient) NewListPager(options *UsageModelsClientListOpti if err != nil { return UsageModelsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UsageModelsClientListResponse{}, err } @@ -95,7 +84,7 @@ func (client *UsageModelsClient) listCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/storagecache/armstoragecache/usagemodels_client_example_test.go b/sdk/resourcemanager/storagecache/armstoragecache/usagemodels_client_example_test.go deleted file mode 100644 index eee79d0b1885..000000000000 --- a/sdk/resourcemanager/storagecache/armstoragecache/usagemodels_client_example_test.go +++ /dev/null @@ -1,60 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armstoragecache_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagecache/armstoragecache/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/402006d2796cdd3894d013d83e77b46a5c844005/specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2023-01-01/examples/UsageModels_List.json -func ExampleUsageModelsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armstoragecache.NewUsageModelsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageModelsResult = armstoragecache.UsageModelsResult{ - // Value: []*armstoragecache.UsageModel{ - // { - // Display: &armstoragecache.UsageModelDisplay{ - // Description: to.Ptr("Read only, with a default verification timer of 30 seconds. Verification timer has a minimum value of 1 and maximum value of 31536000. Write-back timer must have value of 0 or be null."), - // }, - // ModelName: to.Ptr("READ_ONLY"), - // TargetType: to.Ptr("nfs3"), - // }, - // { - // Display: &armstoragecache.UsageModelDisplay{ - // Description: to.Ptr("Read-write, with a default verification timer of 8 hours and default write-back timer of 1 hour. Verification timer and write-back timer have a minimum value of 1 and maximum value of 31536000."), - // }, - // ModelName: to.Ptr("READ_WRITE"), - // TargetType: to.Ptr("nfs3"), - // }}, - // } - } -}