diff --git a/sdk/resourcemanager/saas/armsaas/CHANGELOG.md b/sdk/resourcemanager/saas/armsaas/CHANGELOG.md index 50a013d0226f..2cf5d4a08efb 100644 --- a/sdk/resourcemanager/saas/armsaas/CHANGELOG.md +++ b/sdk/resourcemanager/saas/armsaas/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.5.0, which contains breaking changes. diff --git a/sdk/resourcemanager/saas/armsaas/README.md b/sdk/resourcemanager/saas/armsaas/README.md index 1ceeb633f604..e6f74dea0ddc 100644 --- a/sdk/resourcemanager/saas/armsaas/README.md +++ b/sdk/resourcemanager/saas/armsaas/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure SaaS modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure SaaS module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armsaas.NewApplicationsClient(, cred, nil) +clientFactory, err := armsaas.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armsaas.NewApplicationsClient(, cred, &options) +clientFactory, err := armsaas.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_applications_client.go b/sdk/resourcemanager/saas/armsaas/applications_client.go similarity index 77% rename from sdk/resourcemanager/saas/armsaas/zz_generated_applications_client.go rename to sdk/resourcemanager/saas/armsaas/applications_client.go index 9cfa4ae9bf58..40ff0702feac 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_applications_client.go +++ b/sdk/resourcemanager/saas/armsaas/applications_client.go @@ -5,6 +5,7 @@ // 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 armsaas @@ -13,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" @@ -25,40 +24,31 @@ import ( // ApplicationsClient contains the methods for the Applications group. // Don't use this type directly, use NewApplicationsClient() instead. type ApplicationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewApplicationsClient creates a new instance of ApplicationsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewApplicationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApplicationsClient, 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+".ApplicationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ApplicationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Gets all SaaS resources by subscription id and resource group name. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// options - ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.List method. +// - resourceGroupName - The name of the resource group. +// - options - ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.NewListPager method. func (client *ApplicationsClient) NewListPager(resourceGroupName string, options *ApplicationsClientListOptions) *runtime.Pager[ApplicationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ApplicationsClientListResponse]{ More: func(page ApplicationsClientListResponse) bool { @@ -75,7 +65,7 @@ func (client *ApplicationsClient) NewListPager(resourceGroupName string, options if err != nil { return ApplicationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ApplicationsClientListResponse{}, err } @@ -98,7 +88,7 @@ func (client *ApplicationsClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - 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/saas/armsaas/applications_client_example_test.go b/sdk/resourcemanager/saas/armsaas/applications_client_example_test.go new file mode 100644 index 000000000000..b7b55f435109 --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/applications_client_example_test.go @@ -0,0 +1,78 @@ +//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 armsaas_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV1/SaaSGetApplications.json +func ExampleApplicationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewApplicationsClient().NewListPager("myResourceGroup", 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.AppResponseWithContinuation = armsaas.AppResponseWithContinuation{ + // Value: []*armsaas.App{ + // { + // Name: to.Ptr("myapp"), + // Type: to.Ptr("Microsoft.SaaS/applications"), + // ID: to.Ptr("/subscriptions/bc6c2f82-a39d-41b8-a648-71527498a23e/resourceGroups/myResourceGroup/providers/Microsoft.SaaS/applications/myapp"), + // Location: to.Ptr("location"), + // Properties: &armsaas.AppProperties{ + // SaasAppPlan: &armsaas.AppPlan{ + // Name: to.Ptr("myPlan1"), + // Product: to.Ptr("myOffer"), + // Publisher: to.Ptr("contoso"), + // }, + // Status: to.Ptr(armsaas.SaasAppStatusSubscribed), + // }, + // Tags: map[string]*string{ + // }, + // }, + // { + // Name: to.Ptr("myapp"), + // Type: to.Ptr("Microsoft.SaaS/applications"), + // ID: to.Ptr("/subscriptions/bc6c2f82-a39d-41b8-a648-71527498a23e/resourceGroups/myResourceGroup/providers/Microsoft.SaaS/applications/myapp"), + // Location: to.Ptr("location"), + // Properties: &armsaas.AppProperties{ + // SaasAppPlan: &armsaas.AppPlan{ + // Name: to.Ptr("myPlan2"), + // Product: to.Ptr("myOffer"), + // Publisher: to.Ptr("contoso"), + // }, + // Status: to.Ptr(armsaas.SaasAppStatusSubscribed), + // }, + // Tags: map[string]*string{ + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/saas/armsaas/autorest.md b/sdk/resourcemanager/saas/armsaas/autorest.md index 0caf54fdd470..5c26c5d9f6b9 100644 --- a/sdk/resourcemanager/saas/armsaas/autorest.md +++ b/sdk/resourcemanager/saas/armsaas/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_client.go b/sdk/resourcemanager/saas/armsaas/client.go similarity index 79% rename from sdk/resourcemanager/saas/armsaas/zz_generated_client.go rename to sdk/resourcemanager/saas/armsaas/client.go index 4f8b47b7ee31..9dde2bf458f7 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_client.go +++ b/sdk/resourcemanager/saas/armsaas/client.go @@ -5,6 +5,7 @@ // 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 armsaas @@ -13,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" @@ -25,60 +24,53 @@ import ( // Client contains the methods for the SaaS group. // Don't use this type directly, use NewClient() instead. type Client struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewClient creates a new instance of Client with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, 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+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateResource - Creates a SaaS resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// parameters - Parameters supplied to the create saas operation. -// options - ClientBeginCreateResourceOptions contains the optional parameters for the Client.BeginCreateResource method. +// - parameters - Parameters supplied to the create saas operation. +// - options - ClientBeginCreateResourceOptions contains the optional parameters for the Client.BeginCreateResource method. func (client *Client) BeginCreateResource(ctx context.Context, parameters ResourceCreation, options *ClientBeginCreateResourceOptions) (*runtime.Poller[ClientCreateResourceResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createResource(ctx, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ClientCreateResourceResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateResourceResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ClientCreateResourceResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClientCreateResourceResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateResource - Creates a SaaS resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *Client) createResource(ctx context.Context, parameters ResourceCreation, options *ClientBeginCreateResourceOptions) (*http.Response, error) { req, err := client.createResourceCreateRequest(ctx, parameters, options) 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 } @@ -91,7 +83,7 @@ func (client *Client) createResource(ctx context.Context, parameters ResourceCre // createResourceCreateRequest creates the CreateResource request. func (client *Client) createResourceCreateRequest(ctx context.Context, parameters ResourceCreation, options *ClientBeginCreateResourceOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.SaaS/saasresources" - 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 } @@ -104,33 +96,35 @@ func (client *Client) createResourceCreateRequest(ctx context.Context, parameter // BeginDelete - Deletes the specified SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// parameters - Parameters supplied to delete saas operation. -// options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +// - resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - parameters - Parameters supplied to delete saas operation. +// - options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. func (client *Client) BeginDelete(ctx context.Context, resourceID string, parameters DeleteOptions, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceID, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *Client) deleteOperation(ctx context.Context, resourceID string, parameters DeleteOptions, options *ClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceID, parameters, options) 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 } @@ -147,7 +141,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceID string return nil, errors.New("parameter resourceID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceId}", url.PathEscape(resourceID)) - 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 } @@ -160,15 +154,16 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceID string // GetResource - Gets information about the specified SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// options - ClientGetResourceOptions contains the optional parameters for the Client.GetResource method. +// - resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - options - ClientGetResourceOptions contains the optional parameters for the Client.GetResource method. func (client *Client) GetResource(ctx context.Context, resourceID string, options *ClientGetResourceOptions) (ClientGetResourceResponse, error) { req, err := client.getResourceCreateRequest(ctx, resourceID, options) if err != nil { return ClientGetResourceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetResourceResponse{}, err } @@ -185,7 +180,7 @@ func (client *Client) getResourceCreateRequest(ctx context.Context, resourceID s return nil, errors.New("parameter resourceID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceId}", url.PathEscape(resourceID)) - 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 } @@ -207,33 +202,35 @@ func (client *Client) getResourceHandleResponse(resp *http.Response) (ClientGetR // BeginUpdateResource - Updates a SaaS resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// parameters - Parameters supplied to the update saas operation. -// options - ClientBeginUpdateResourceOptions contains the optional parameters for the Client.BeginUpdateResource method. +// - resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - parameters - Parameters supplied to the update saas operation. +// - options - ClientBeginUpdateResourceOptions contains the optional parameters for the Client.BeginUpdateResource method. func (client *Client) BeginUpdateResource(ctx context.Context, resourceID string, parameters ResourceCreation, options *ClientBeginUpdateResourceOptions) (*runtime.Poller[ClientUpdateResourceResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.updateResource(ctx, resourceID, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ClientUpdateResourceResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientUpdateResourceResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ClientUpdateResourceResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ClientUpdateResourceResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // UpdateResource - Updates a SaaS resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *Client) updateResource(ctx context.Context, resourceID string, parameters ResourceCreation, options *ClientBeginUpdateResourceOptions) (*http.Response, error) { req, err := client.updateResourceCreateRequest(ctx, resourceID, parameters, options) 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 } @@ -250,7 +247,7 @@ func (client *Client) updateResourceCreateRequest(ctx context.Context, resourceI return nil, errors.New("parameter resourceID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceId}", url.PathEscape(resourceID)) - 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 } diff --git a/sdk/resourcemanager/saas/armsaas/client_example_test.go b/sdk/resourcemanager/saas/armsaas/client_example_test.go new file mode 100644 index 000000000000..05f7730c5518 --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/client_example_test.go @@ -0,0 +1,208 @@ +//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 armsaas_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/saas/armsaas" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasDelete.json +func ExampleClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginDelete(ctx, "115c3523-1fae-757f-af86-7b27cfd29805", armsaas.DeleteOptions{ + ReasonCode: to.Ptr[float32](0), + UnsubscribeOnly: to.Ptr(true), + }, 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/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasGet.json +func ExampleClient_GetResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().GetResource(ctx, "115c3523-1fae-757f-af86-7b27cfd29805", 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.Resource = armsaas.Resource{ + // Name: to.Ptr("diyakobo-transfer"), + // Type: to.Ptr("Microsoft.SaaS/saasresources"), + // ID: to.Ptr("/providers/Microsoft.SaaS/saasresources/115c3523-1fae-757f-af86-7b27cfd29805"), + // Properties: &armsaas.ResourceProperties{ + // OfferID: to.Ptr("microsofthealthcarebot"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), + // "resourceId": to.Ptr("b25dba9a-1bd7-4600-9447-3d27d11a6477"), + // }, + // PublisherID: to.Ptr("microsoft-hcb"), + // SaasResourceName: to.Ptr("diyakobo-transfer"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2020-10-12T05:08:40.9235607Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-11-12T21:25:40.2736665Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2020-12-11T00:00:00Z"), + // StartDate: to.Ptr("2020-11-12T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasPatch.json +func ExampleClient_BeginUpdateResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginUpdateResource(ctx, "115c3523-1fae-757f-af86-7b27cfd29805", armsaas.ResourceCreation{ + Properties: &armsaas.CreationProperties{ + SKUID: to.Ptr("premium"), + }, + Tags: map[string]*string{}, + }, 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.Resource = armsaas.Resource{ + // Name: to.Ptr("MyContosoSubscription"), + // Type: to.Ptr("Microsoft.SaaS/saasresources"), + // ID: to.Ptr("/providers/Microsoft.SaaS/saasresources/115c3523-1fae-757f-af86-7b27cfd29805"), + // Properties: &armsaas.ResourceProperties{ + // AutoRenew: to.Ptr(true), + // OfferID: to.Ptr("contosoOffer"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("c825645b-e31b-9cf4-1cee-2aba9e58bc7c"), + // "resourceId": to.Ptr("263ebe8c-3621-4ac0-a6ba-f1419bfb9166"), + // }, + // PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + // PublisherID: to.Ptr("microsoft-contoso"), + // SaasResourceName: to.Ptr("MyContosoSubscription"), + // SKUID: to.Ptr("premium"), + // Created: to.Ptr("2021-01-01T08:30:10.1234567Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-01-01T08:35:05.7654321Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2021-02-31T00:00:00Z"), + // StartDate: to.Ptr("2021-01-01T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasPut.json +func ExampleClient_BeginCreateResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginCreateResource(ctx, armsaas.ResourceCreation{ + Properties: &armsaas.CreationProperties{ + OfferID: to.Ptr("microsofthealthcarebot"), + PaymentChannelMetadata: map[string]*string{ + "AzureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), + }, + PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + PublisherID: to.Ptr("microsoft-hcb"), + SaasResourceName: to.Ptr("testRunnerFromArm"), + SKUID: to.Ptr("free"), + TermID: to.Ptr("hjdtn7tfnxcy"), + }, + }, 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.Resource = armsaas.Resource{ + // Name: to.Ptr("diyakobo-transfer"), + // Type: to.Ptr("Microsoft.SaaS/saasresources"), + // ID: to.Ptr("/providers/Microsoft.SaaS/saasresources/115c3523-1fae-757f-af86-7b27cfd29805"), + // Properties: &armsaas.ResourceProperties{ + // OfferID: to.Ptr("microsofthealthcarebot"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), + // "resourceId": to.Ptr("b25dba9a-1bd7-4600-9447-3d27d11a6477"), + // }, + // PublisherID: to.Ptr("microsoft-hcb"), + // SaasResourceName: to.Ptr("diyakobo-transfer"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2020-10-12T05:08:40.9235607Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-11-12T21:25:40.2736665Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2020-12-11T00:00:00Z"), + // StartDate: to.Ptr("2020-11-12T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // } +} diff --git a/sdk/resourcemanager/saas/armsaas/client_factory.go b/sdk/resourcemanager/saas/armsaas/client_factory.go new file mode 100644 index 000000000000..8f3920da653a --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/client_factory.go @@ -0,0 +1,69 @@ +//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 armsaas + +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 - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - 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) NewApplicationsClient() *ApplicationsClient { + subClient, _ := NewApplicationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourcesClient() *ResourcesClient { + subClient, _ := NewResourcesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSubscriptionLevelClient() *SubscriptionLevelClient { + subClient, _ := NewSubscriptionLevelClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationClient() *OperationClient { + subClient, _ := NewOperationClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_constants.go b/sdk/resourcemanager/saas/armsaas/constants.go similarity index 98% rename from sdk/resourcemanager/saas/armsaas/zz_generated_constants.go rename to sdk/resourcemanager/saas/armsaas/constants.go index 6be7edf5e02f..0b40d6ba5e75 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_constants.go +++ b/sdk/resourcemanager/saas/armsaas/constants.go @@ -5,12 +5,13 @@ // 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 armsaas const ( moduleName = "armsaas" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // PaymentChannelType - The Payment channel for the SaasSubscription. diff --git a/sdk/resourcemanager/saas/armsaas/go.mod b/sdk/resourcemanager/saas/armsaas/go.mod index 8a364012ddf3..a1e6d1b5a91a 100644 --- a/sdk/resourcemanager/saas/armsaas/go.mod +++ b/sdk/resourcemanager/saas/armsaas/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas 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.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // 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/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/saas/armsaas/go.sum b/sdk/resourcemanager/saas/armsaas/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/saas/armsaas/go.sum +++ b/sdk/resourcemanager/saas/armsaas/go.sum @@ -1,33 +1,31 @@ -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.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -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.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +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/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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 v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +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/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_models.go b/sdk/resourcemanager/saas/armsaas/models.go similarity index 97% rename from sdk/resourcemanager/saas/armsaas/zz_generated_models.go rename to sdk/resourcemanager/saas/armsaas/models.go index 9b97d53b961c..b879fed7ae25 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_models.go +++ b/sdk/resourcemanager/saas/armsaas/models.go @@ -5,6 +5,7 @@ // 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 armsaas @@ -107,7 +108,7 @@ type AppResponseWithContinuation struct { Value []*App `json:"value,omitempty"` } -// ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.List method. +// ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.NewListPager method. type ApplicationsClientListOptions struct { // placeholder for future optional parameters } @@ -189,7 +190,7 @@ type DeleteOptions struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -235,7 +236,7 @@ type OperationClientBeginGetOptions struct { ResumeToken string } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -377,7 +378,7 @@ type ResourcesClientListAccessTokenOptions struct { // placeholder for future optional parameters } -// ResourcesClientListOptions contains the optional parameters for the ResourcesClient.List method. +// ResourcesClientListOptions contains the optional parameters for the ResourcesClient.NewListPager method. type ResourcesClientListOptions struct { // placeholder for future optional parameters } @@ -434,13 +435,13 @@ type SubscriptionLevelClientListAccessTokenOptions struct { // placeholder for future optional parameters } -// SubscriptionLevelClientListByAzureSubscriptionOptions contains the optional parameters for the SubscriptionLevelClient.ListByAzureSubscription +// SubscriptionLevelClientListByAzureSubscriptionOptions contains the optional parameters for the SubscriptionLevelClient.NewListByAzureSubscriptionPager // method. type SubscriptionLevelClientListByAzureSubscriptionOptions struct { // placeholder for future optional parameters } -// SubscriptionLevelClientListByResourceGroupOptions contains the optional parameters for the SubscriptionLevelClient.ListByResourceGroup +// SubscriptionLevelClientListByResourceGroupOptions contains the optional parameters for the SubscriptionLevelClient.NewListByResourceGroupPager // method. type SubscriptionLevelClientListByResourceGroupOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/saas/armsaas/models_serde.go b/sdk/resourcemanager/saas/armsaas/models_serde.go new file mode 100644 index 000000000000..dc3754baa6c2 --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/models_serde.go @@ -0,0 +1,876 @@ +//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 armsaas + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccessTokenResult. +func (a AccessTokenResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "publisherOfferBaseUri", a.PublisherOfferBaseURI) + populate(objectMap, "token", a.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessTokenResult. +func (a *AccessTokenResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "publisherOfferBaseUri": + err = unpopulate(val, "PublisherOfferBaseURI", &a.PublisherOfferBaseURI) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &a.Token) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type App. +func (a App) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type App. +func (a *App) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppOperation. +func (a AppOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", a.Display) + populate(objectMap, "isDataAction", a.IsDataAction) + populate(objectMap, "name", a.Name) + populate(objectMap, "origin", a.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppOperation. +func (a *AppOperation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &a.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &a.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &a.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppOperationDisplay. +func (a AppOperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "operation", a.Operation) + populate(objectMap, "provider", a.Provider) + populate(objectMap, "resource", a.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppOperationDisplay. +func (a *AppOperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &a.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &a.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &a.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppOperationsResponseWithContinuation. +func (a AppOperationsResponseWithContinuation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppOperationsResponseWithContinuation. +func (a *AppOperationsResponseWithContinuation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppPlan. +func (a AppPlan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + populate(objectMap, "product", a.Product) + populate(objectMap, "publisher", a.Publisher) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppPlan. +func (a *AppPlan) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &a.Product) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &a.Publisher) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppProperties. +func (a AppProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "saasAppPlan", a.SaasAppPlan) + populate(objectMap, "status", a.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppProperties. +func (a *AppProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "saasAppPlan": + err = unpopulate(val, "SaasAppPlan", &a.SaasAppPlan) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AppResponseWithContinuation. +func (a AppResponseWithContinuation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppResponseWithContinuation. +func (a *AppResponseWithContinuation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CreationProperties. +func (c CreationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoRenew", c.AutoRenew) + populate(objectMap, "offerId", c.OfferID) + populate(objectMap, "paymentChannelMetadata", c.PaymentChannelMetadata) + populate(objectMap, "paymentChannelType", c.PaymentChannelType) + populate(objectMap, "publisherId", c.PublisherID) + populate(objectMap, "publisherTestEnvironment", c.PublisherTestEnvironment) + populate(objectMap, "quantity", c.Quantity) + populate(objectMap, "skuId", c.SKUID) + populate(objectMap, "saasResourceName", c.SaasResourceName) + populate(objectMap, "saasSessionId", c.SaasSessionID) + populate(objectMap, "saasSubscriptionId", c.SaasSubscriptionID) + populate(objectMap, "termId", c.TermID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CreationProperties. +func (c *CreationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoRenew": + err = unpopulate(val, "AutoRenew", &c.AutoRenew) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &c.OfferID) + delete(rawMsg, key) + case "paymentChannelMetadata": + err = unpopulate(val, "PaymentChannelMetadata", &c.PaymentChannelMetadata) + delete(rawMsg, key) + case "paymentChannelType": + err = unpopulate(val, "PaymentChannelType", &c.PaymentChannelType) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &c.PublisherID) + delete(rawMsg, key) + case "publisherTestEnvironment": + err = unpopulate(val, "PublisherTestEnvironment", &c.PublisherTestEnvironment) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &c.Quantity) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &c.SKUID) + delete(rawMsg, key) + case "saasResourceName": + err = unpopulate(val, "SaasResourceName", &c.SaasResourceName) + delete(rawMsg, key) + case "saasSessionId": + err = unpopulate(val, "SaasSessionID", &c.SaasSessionID) + delete(rawMsg, key) + case "saasSubscriptionId": + err = unpopulate(val, "SaasSubscriptionID", &c.SaasSubscriptionID) + delete(rawMsg, key) + case "termId": + err = unpopulate(val, "TermID", &c.TermID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeleteOptions. +func (d DeleteOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "feedback", d.Feedback) + populate(objectMap, "reasonCode", d.ReasonCode) + populate(objectMap, "unsubscribeOnly", d.UnsubscribeOnly) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeleteOptions. +func (d *DeleteOptions) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "feedback": + err = unpopulate(val, "Feedback", &d.Feedback) + delete(rawMsg, key) + case "reasonCode": + err = unpopulate(val, "ReasonCode", &d.ReasonCode) + delete(rawMsg, key) + case "unsubscribeOnly": + err = unpopulate(val, "UnsubscribeOnly", &d.UnsubscribeOnly) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MoveResource. +func (m MoveResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resources", m.Resources) + populate(objectMap, "targetResourceGroup", m.TargetResourceGroup) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MoveResource. +func (m *MoveResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resources": + err = unpopulate(val, "Resources", &m.Resources) + delete(rawMsg, key) + case "targetResourceGroup": + err = unpopulate(val, "TargetResourceGroup", &m.TargetResourceGroup) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "created", p.Created) + populate(objectMap, "isFreeTrial", p.IsFreeTrial) + populate(objectMap, "lastModified", p.LastModified) + populate(objectMap, "status", p.Status) + populate(objectMap, "term", p.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Properties. +func (p *Properties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "created": + err = unpopulate(val, "Created", &p.Created) + delete(rawMsg, key) + case "isFreeTrial": + err = unpopulate(val, "IsFreeTrial", &p.IsFreeTrial) + delete(rawMsg, key) + case "lastModified": + err = unpopulate(val, "LastModified", &p.LastModified) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &p.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PropertiesTerm. +func (p PropertiesTerm) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endDate", p.EndDate) + populate(objectMap, "startDate", p.StartDate) + populate(objectMap, "termUnit", p.TermUnit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PropertiesTerm. +func (p *PropertiesTerm) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endDate": + err = unpopulate(val, "EndDate", &p.EndDate) + delete(rawMsg, key) + case "startDate": + err = unpopulate(val, "StartDate", &p.StartDate) + delete(rawMsg, key) + case "termUnit": + err = unpopulate(val, "TermUnit", &p.TermUnit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceCreation. +func (r ResourceCreation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceCreation. +func (r *ResourceCreation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProperties. +func (r ResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "autoRenew", r.AutoRenew) + populate(objectMap, "created", r.Created) + populate(objectMap, "isFreeTrial", r.IsFreeTrial) + populate(objectMap, "lastModified", r.LastModified) + populate(objectMap, "offerId", r.OfferID) + populate(objectMap, "paymentChannelMetadata", r.PaymentChannelMetadata) + populate(objectMap, "paymentChannelType", r.PaymentChannelType) + populate(objectMap, "publisherId", r.PublisherID) + populate(objectMap, "publisherTestEnvironment", r.PublisherTestEnvironment) + populate(objectMap, "quantity", r.Quantity) + populate(objectMap, "skuId", r.SKUID) + populate(objectMap, "saasResourceName", r.SaasResourceName) + populate(objectMap, "saasSessionId", r.SaasSessionID) + populate(objectMap, "saasSubscriptionId", r.SaasSubscriptionID) + populate(objectMap, "status", r.Status) + populate(objectMap, "term", r.Term) + populate(objectMap, "termId", r.TermID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProperties. +func (r *ResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "autoRenew": + err = unpopulate(val, "AutoRenew", &r.AutoRenew) + delete(rawMsg, key) + case "created": + err = unpopulate(val, "Created", &r.Created) + delete(rawMsg, key) + case "isFreeTrial": + err = unpopulate(val, "IsFreeTrial", &r.IsFreeTrial) + delete(rawMsg, key) + case "lastModified": + err = unpopulate(val, "LastModified", &r.LastModified) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &r.OfferID) + delete(rawMsg, key) + case "paymentChannelMetadata": + err = unpopulate(val, "PaymentChannelMetadata", &r.PaymentChannelMetadata) + delete(rawMsg, key) + case "paymentChannelType": + err = unpopulate(val, "PaymentChannelType", &r.PaymentChannelType) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &r.PublisherID) + delete(rawMsg, key) + case "publisherTestEnvironment": + err = unpopulate(val, "PublisherTestEnvironment", &r.PublisherTestEnvironment) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &r.Quantity) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &r.SKUID) + delete(rawMsg, key) + case "saasResourceName": + err = unpopulate(val, "SaasResourceName", &r.SaasResourceName) + delete(rawMsg, key) + case "saasSessionId": + err = unpopulate(val, "SaasSessionID", &r.SaasSessionID) + delete(rawMsg, key) + case "saasSubscriptionId": + err = unpopulate(val, "SaasSubscriptionID", &r.SaasSubscriptionID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &r.Term) + delete(rawMsg, key) + case "termId": + err = unpopulate(val, "TermID", &r.TermID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceResponseWithContinuation. +func (r ResourceResponseWithContinuation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceResponseWithContinuation. +func (r *ResourceResponseWithContinuation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Result. +func (r Result) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sampleProperty", r.SampleProperty) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Result. +func (r *Result) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "sampleProperty": + err = unpopulate(val, "SampleProperty", &r.SampleProperty) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_operation_client.go b/sdk/resourcemanager/saas/armsaas/operation_client.go similarity index 75% rename from sdk/resourcemanager/saas/armsaas/zz_generated_operation_client.go rename to sdk/resourcemanager/saas/armsaas/operation_client.go index 1f5fb2b641cf..dbec6b56c72c 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_operation_client.go +++ b/sdk/resourcemanager/saas/armsaas/operation_client.go @@ -5,6 +5,7 @@ // 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 armsaas @@ -13,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" @@ -25,60 +24,53 @@ import ( // OperationClient contains the methods for the SaaSOperation group. // Don't use this type directly, use NewOperationClient() instead. type OperationClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationClient creates a new instance of OperationClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationClient, 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+".OperationClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginGet - Gets information about the specified operation progress. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// operationID - the operation Id parameter. -// options - OperationClientBeginGetOptions contains the optional parameters for the OperationClient.BeginGet method. +// - operationID - the operation Id parameter. +// - options - OperationClientBeginGetOptions contains the optional parameters for the OperationClient.BeginGet method. func (client *OperationClient) BeginGet(ctx context.Context, operationID string, options *OperationClientBeginGetOptions) (*runtime.Poller[OperationClientGetResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.get(ctx, operationID, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[OperationClientGetResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OperationClientGetResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[OperationClientGetResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[OperationClientGetResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Get - Gets information about the specified operation progress. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *OperationClient) get(ctx context.Context, operationID string, options *OperationClientBeginGetOptions) (*http.Response, error) { req, err := client.getCreateRequest(ctx, operationID, options) 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 } @@ -95,7 +87,7 @@ func (client *OperationClient) getCreateRequest(ctx context.Context, operationID 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/saas/armsaas/operation_client_example_test.go b/sdk/resourcemanager/saas/armsaas/operation_client_example_test.go new file mode 100644 index 000000000000..1ce9acb1ab32 --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/operation_client_example_test.go @@ -0,0 +1,68 @@ +//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 armsaas_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/OperationResults/Get.json +func ExampleOperationClient_BeginGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOperationClient().BeginGet(ctx, "5f35cb4c-8065-45b3-9116-5ba335462e95", 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.Resource = armsaas.Resource{ + // Name: to.Ptr("diyakobo-transfer"), + // Type: to.Ptr("Microsoft.SaaS/saasresources"), + // ID: to.Ptr("/providers/Microsoft.SaaS/saasresources/115c3523-1fae-757f-af86-7b27cfd29805"), + // Properties: &armsaas.ResourceProperties{ + // OfferID: to.Ptr("microsofthealthcarebot"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), + // "resourceId": to.Ptr("b25dba9a-1bd7-4600-9447-3d27d11a6477"), + // }, + // PublisherID: to.Ptr("microsoft-hcb"), + // SaasResourceName: to.Ptr("diyakobo-transfer"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2020-10-12T05:08:40.9235607Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-11-12T21:25:40.2736665Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2020-12-11T00:00:00Z"), + // StartDate: to.Ptr("2020-11-12T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // } +} diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_operations_client.go b/sdk/resourcemanager/saas/armsaas/operations_client.go similarity index 77% rename from sdk/resourcemanager/saas/armsaas/zz_generated_operations_client.go rename to sdk/resourcemanager/saas/armsaas/operations_client.go index 6d9cae66e69d..77bc4bacb3d5 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_operations_client.go +++ b/sdk/resourcemanager/saas/armsaas/operations_client.go @@ -5,6 +5,7 @@ // 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 armsaas @@ -12,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" @@ -22,36 +21,27 @@ 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. +// - 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 } // NewListPager - Gets all SaaS app operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,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 } @@ -83,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.SaaS/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/saas/armsaas/operations_client_example_test.go b/sdk/resourcemanager/saas/armsaas/operations_client_example_test.go new file mode 100644 index 000000000000..a644ca804dd8 --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/operations_client_example_test.go @@ -0,0 +1,118 @@ +//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 armsaas_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV1/SaaSGetOperations.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().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.AppOperationsResponseWithContinuation = armsaas.AppOperationsResponseWithContinuation{ + // Value: []*armsaas.AppOperation{ + // { + // Name: to.Ptr("Microsoft.SaaS/register/action"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Register Saas resource provider in the tenant"), + // Operation: to.Ptr("Register SaaS resource provider"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Resources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.SaaS/saasresources/read"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Get all SaaS resources or one resource"), + // Operation: to.Ptr("Get SaaS Resources"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Resources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.SaaS/saasresources/write"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Create or Update a SaaS resource"), + // Operation: to.Ptr("Create or Update a SaaS resource"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Resources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.SaaS/saasresources/delete"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Delete a SaaS Resource"), + // Operation: to.Ptr("Delete a SaaS Resource"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Resources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.SaaS/resources/read"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Get one resource"), + // Operation: to.Ptr("Get SaaS Subscription Level Resources"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Subscription Level Resources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.SaaS/resources/write"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Create or Update a SaaS Subscription Level resource"), + // Operation: to.Ptr("Create or Update a SaaS Subscription Level resource"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Subscription Level Resources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.SaaS/resources/delete"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Delete a SaaS Subscription Level Resource"), + // Operation: to.Ptr("Delete a SaaS Subscription Level Resource"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Subscription Level Resources"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.SaaS/saasresources/listaccesstoken/action"), + // Display: &armsaas.AppOperationDisplay{ + // Description: to.Ptr("Get the access Token for a SaaS resource"), + // Operation: to.Ptr("Get the access Token"), + // Provider: to.Ptr("Microsoft"), + // Resource: to.Ptr("SaaS Resources"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_resources_client.go b/sdk/resourcemanager/saas/armsaas/resources_client.go similarity index 80% rename from sdk/resourcemanager/saas/armsaas/zz_generated_resources_client.go rename to sdk/resourcemanager/saas/armsaas/resources_client.go index 7aae485eae9f..365ca1033801 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_resources_client.go +++ b/sdk/resourcemanager/saas/armsaas/resources_client.go @@ -5,6 +5,7 @@ // 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 armsaas @@ -13,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" @@ -25,36 +24,27 @@ import ( // ResourcesClient contains the methods for the SaasResources group. // Don't use this type directly, use NewResourcesClient() instead. type ResourcesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewResourcesClient creates a new instance of ResourcesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewResourcesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourcesClient, 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+".ResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourcesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Get All Resources -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// options - ResourcesClientListOptions contains the optional parameters for the ResourcesClient.List method. +// - options - ResourcesClientListOptions contains the optional parameters for the ResourcesClient.NewListPager method. func (client *ResourcesClient) NewListPager(options *ResourcesClientListOptions) *runtime.Pager[ResourcesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourcesClientListResponse]{ More: func(page ResourcesClientListResponse) bool { @@ -71,7 +61,7 @@ func (client *ResourcesClient) NewListPager(options *ResourcesClientListOptions) if err != nil { return ResourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcesClientListResponse{}, err } @@ -86,7 +76,7 @@ func (client *ResourcesClient) NewListPager(options *ResourcesClientListOptions) // listCreateRequest creates the List request. func (client *ResourcesClient) listCreateRequest(ctx context.Context, options *ResourcesClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.SaaS/saasresources" - 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 } @@ -108,16 +98,17 @@ func (client *ResourcesClient) listHandleResponse(resp *http.Response) (Resource // ListAccessToken - Gets the ISV access token for a SaaS resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// options - ResourcesClientListAccessTokenOptions contains the optional parameters for the ResourcesClient.ListAccessToken -// method. +// - resourceID - The Saas resource ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - options - ResourcesClientListAccessTokenOptions contains the optional parameters for the ResourcesClient.ListAccessToken +// method. func (client *ResourcesClient) ListAccessToken(ctx context.Context, resourceID string, options *ResourcesClientListAccessTokenOptions) (ResourcesClientListAccessTokenResponse, error) { req, err := client.listAccessTokenCreateRequest(ctx, resourceID, options) if err != nil { return ResourcesClientListAccessTokenResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcesClientListAccessTokenResponse{}, err } @@ -134,7 +125,7 @@ func (client *ResourcesClient) listAccessTokenCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceId}", url.PathEscape(resourceID)) - 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/saas/armsaas/resources_client_example_test.go b/sdk/resourcemanager/saas/armsaas/resources_client_example_test.go new file mode 100644 index 000000000000..0bdefad89aed --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/resources_client_example_test.go @@ -0,0 +1,122 @@ +//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 armsaas_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaaSGetAllResources.json +func ExampleResourcesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewResourcesClient().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.ResourceResponseWithContinuation = armsaas.ResourceResponseWithContinuation{ + // Value: []*armsaas.Resource{ + // { + // Name: to.Ptr("diyakobo-transfer"), + // Type: to.Ptr("Microsoft.SaaS/saasresources"), + // ID: to.Ptr("/providers/Microsoft.SaaS/saasresources/115c3523-1fae-757f-af86-7b27cfd29805"), + // Properties: &armsaas.ResourceProperties{ + // OfferID: to.Ptr("microsofthealthcarebot"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), + // "resourceId": to.Ptr("b25dba9a-1bd7-4600-9447-3d27d11a6477"), + // }, + // PublisherID: to.Ptr("microsoft-hcb"), + // SaasResourceName: to.Ptr("diyakobo-transfer"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2020-10-12T05:08:40.9235607Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-11-12T21:25:40.2736665Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2020-12-11T00:00:00Z"), + // StartDate: to.Ptr("2020-11-12T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // }, + // { + // Name: to.Ptr("test-transfer"), + // Type: to.Ptr("Microsoft.SaaS/saasresources"), + // ID: to.Ptr("/providers/Microsoft.SaaS/saasresources/7a4a733c-2204-ee2c-2f51-47c2dfbcb7fd"), + // Properties: &armsaas.ResourceProperties{ + // OfferID: to.Ptr("microsofthealthcarebot"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), + // "resourceId": to.Ptr("f5816b76-67e3-45e1-b331-91fbb021e068"), + // }, + // PublisherID: to.Ptr("microsoft-hcb"), + // SaasResourceName: to.Ptr("test-transfer"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2020-09-30T16:45:41.2981172Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-10-30T16:22:15.4319475Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2020-11-29T00:00:00Z"), + // StartDate: to.Ptr("2020-10-30T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/ListAccessTokenPost.json +func ExampleResourcesClient_ListAccessToken() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewResourcesClient().ListAccessToken(ctx, "c825645b-e31b-9cf4-1cee-2aba9e58bc7c", 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.AccessTokenResult = armsaas.AccessTokenResult{ + // PublisherOfferBaseURI: to.Ptr("https://contoso.website.com/api/v1/marketplace/azure/common/auth"), + // Token: to.Ptr("jyhAtr3AiFTXO0QsEkYizsNzqIAUJ+E0M1SXhl4E5hwAl7+GJT6t+dEwuWpSizgR0Vn6dMhzpS94JRzkUh2Xuq5L1QDgmDkDUeIikTFNviwtwxtF8CwipcB49rq5d8whmVp0CmWEjd/FzU0vvlikBRuy+asxC1UhXv6XxBkSxkZKj29AAFiGgsgRvXIld47C"), + // } +} diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_response_types.go b/sdk/resourcemanager/saas/armsaas/response_types.go similarity index 83% rename from sdk/resourcemanager/saas/armsaas/zz_generated_response_types.go rename to sdk/resourcemanager/saas/armsaas/response_types.go index aa94777cc7cd..04835167c93e 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_response_types.go +++ b/sdk/resourcemanager/saas/armsaas/response_types.go @@ -5,20 +5,21 @@ // 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 armsaas -// ApplicationsClientListResponse contains the response from method ApplicationsClient.List. +// ApplicationsClientListResponse contains the response from method ApplicationsClient.NewListPager. type ApplicationsClientListResponse struct { AppResponseWithContinuation } -// ClientCreateResourceResponse contains the response from method Client.CreateResource. +// ClientCreateResourceResponse contains the response from method Client.BeginCreateResource. type ClientCreateResourceResponse struct { Resource } -// ClientDeleteResponse contains the response from method Client.Delete. +// ClientDeleteResponse contains the response from method Client.BeginDelete. type ClientDeleteResponse struct { // placeholder for future response values } @@ -28,17 +29,17 @@ type ClientGetResourceResponse struct { Resource } -// ClientUpdateResourceResponse contains the response from method Client.UpdateResource. +// ClientUpdateResourceResponse contains the response from method Client.BeginUpdateResource. type ClientUpdateResourceResponse struct { Resource } -// OperationClientGetResponse contains the response from method OperationClient.Get. +// OperationClientGetResponse contains the response from method OperationClient.BeginGet. type OperationClientGetResponse struct { Resource } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { AppOperationsResponseWithContinuation } @@ -48,17 +49,17 @@ type ResourcesClientListAccessTokenResponse struct { AccessTokenResult } -// ResourcesClientListResponse contains the response from method ResourcesClient.List. +// ResourcesClientListResponse contains the response from method ResourcesClient.NewListPager. type ResourcesClientListResponse struct { ResourceResponseWithContinuation } -// SubscriptionLevelClientCreateOrUpdateResponse contains the response from method SubscriptionLevelClient.CreateOrUpdate. +// SubscriptionLevelClientCreateOrUpdateResponse contains the response from method SubscriptionLevelClient.BeginCreateOrUpdate. type SubscriptionLevelClientCreateOrUpdateResponse struct { Resource } -// SubscriptionLevelClientDeleteResponse contains the response from method SubscriptionLevelClient.Delete. +// SubscriptionLevelClientDeleteResponse contains the response from method SubscriptionLevelClient.BeginDelete. type SubscriptionLevelClientDeleteResponse struct { // placeholder for future response values } @@ -73,27 +74,27 @@ type SubscriptionLevelClientListAccessTokenResponse struct { AccessTokenResult } -// SubscriptionLevelClientListByAzureSubscriptionResponse contains the response from method SubscriptionLevelClient.ListByAzureSubscription. +// SubscriptionLevelClientListByAzureSubscriptionResponse contains the response from method SubscriptionLevelClient.NewListByAzureSubscriptionPager. type SubscriptionLevelClientListByAzureSubscriptionResponse struct { ResourceResponseWithContinuation } -// SubscriptionLevelClientListByResourceGroupResponse contains the response from method SubscriptionLevelClient.ListByResourceGroup. +// SubscriptionLevelClientListByResourceGroupResponse contains the response from method SubscriptionLevelClient.NewListByResourceGroupPager. type SubscriptionLevelClientListByResourceGroupResponse struct { ResourceResponseWithContinuation } -// SubscriptionLevelClientMoveResourcesResponse contains the response from method SubscriptionLevelClient.MoveResources. +// SubscriptionLevelClientMoveResourcesResponse contains the response from method SubscriptionLevelClient.BeginMoveResources. type SubscriptionLevelClientMoveResourcesResponse struct { // placeholder for future response values } -// SubscriptionLevelClientUpdateResponse contains the response from method SubscriptionLevelClient.Update. +// SubscriptionLevelClientUpdateResponse contains the response from method SubscriptionLevelClient.BeginUpdate. type SubscriptionLevelClientUpdateResponse struct { Resource } -// SubscriptionLevelClientUpdateToUnsubscribedResponse contains the response from method SubscriptionLevelClient.UpdateToUnsubscribed. +// SubscriptionLevelClientUpdateToUnsubscribedResponse contains the response from method SubscriptionLevelClient.BeginUpdateToUnsubscribed. type SubscriptionLevelClientUpdateToUnsubscribedResponse struct { // placeholder for future response values } diff --git a/sdk/resourcemanager/saas/armsaas/zz_generated_subscriptionlevel_client.go b/sdk/resourcemanager/saas/armsaas/subscriptionlevel_client.go similarity index 84% rename from sdk/resourcemanager/saas/armsaas/zz_generated_subscriptionlevel_client.go rename to sdk/resourcemanager/saas/armsaas/subscriptionlevel_client.go index 68dd1210ea29..00889c18ca7c 100644 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_subscriptionlevel_client.go +++ b/sdk/resourcemanager/saas/armsaas/subscriptionlevel_client.go @@ -5,6 +5,7 @@ // 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 armsaas @@ -13,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" @@ -25,66 +24,59 @@ import ( // SubscriptionLevelClient contains the methods for the SaasSubscriptionLevel group. // Don't use this type directly, use NewSubscriptionLevelClient() instead. type SubscriptionLevelClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSubscriptionLevelClient creates a new instance of SubscriptionLevelClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSubscriptionLevelClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SubscriptionLevelClient, 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+".SubscriptionLevelClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SubscriptionLevelClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a SaaS resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// resourceName - The name of the resource. -// parameters - Parameters supplied to the create or update subscription level saas operation. -// options - SubscriptionLevelClientBeginCreateOrUpdateOptions contains the optional parameters for the SubscriptionLevelClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - resourceName - The name of the resource. +// - parameters - Parameters supplied to the create or update subscription level saas operation. +// - options - SubscriptionLevelClientBeginCreateOrUpdateOptions contains the optional parameters for the SubscriptionLevelClient.BeginCreateOrUpdate +// method. func (client *SubscriptionLevelClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters ResourceCreation, options *SubscriptionLevelClientBeginCreateOrUpdateOptions) (*runtime.Poller[SubscriptionLevelClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SubscriptionLevelClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionLevelClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SubscriptionLevelClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SubscriptionLevelClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a SaaS resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *SubscriptionLevelClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters ResourceCreation, options *SubscriptionLevelClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) 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 } @@ -109,7 +101,7 @@ func (client *SubscriptionLevelClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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 } @@ -122,34 +114,36 @@ func (client *SubscriptionLevelClient) createOrUpdateCreateRequest(ctx context.C // BeginDelete - Deletes the specified SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// resourceName - The name of the resource. -// options - SubscriptionLevelClientBeginDeleteOptions contains the optional parameters for the SubscriptionLevelClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - resourceName - The name of the resource. +// - options - SubscriptionLevelClientBeginDeleteOptions contains the optional parameters for the SubscriptionLevelClient.BeginDelete +// method. func (client *SubscriptionLevelClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *SubscriptionLevelClientBeginDeleteOptions) (*runtime.Poller[SubscriptionLevelClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SubscriptionLevelClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionLevelClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SubscriptionLevelClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SubscriptionLevelClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the specified SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *SubscriptionLevelClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *SubscriptionLevelClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) 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 } @@ -174,7 +168,7 @@ func (client *SubscriptionLevelClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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 } @@ -187,16 +181,17 @@ func (client *SubscriptionLevelClient) deleteCreateRequest(ctx context.Context, // Get - Gets information about the specified Subscription Level SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// resourceName - The name of the resource. -// options - SubscriptionLevelClientGetOptions contains the optional parameters for the SubscriptionLevelClient.Get method. +// - resourceGroupName - The name of the resource group. +// - resourceName - The name of the resource. +// - options - SubscriptionLevelClientGetOptions contains the optional parameters for the SubscriptionLevelClient.Get method. func (client *SubscriptionLevelClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *SubscriptionLevelClientGetOptions) (SubscriptionLevelClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return SubscriptionLevelClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubscriptionLevelClientGetResponse{}, err } @@ -221,7 +216,7 @@ func (client *SubscriptionLevelClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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 } @@ -243,17 +238,18 @@ func (client *SubscriptionLevelClient) getHandleResponse(resp *http.Response) (S // ListAccessToken - Gets the ISV access token for a specified Subscription Level SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// resourceName - The name of the resource. -// options - SubscriptionLevelClientListAccessTokenOptions contains the optional parameters for the SubscriptionLevelClient.ListAccessToken -// method. +// - resourceGroupName - The name of the resource group. +// - resourceName - The name of the resource. +// - options - SubscriptionLevelClientListAccessTokenOptions contains the optional parameters for the SubscriptionLevelClient.ListAccessToken +// method. func (client *SubscriptionLevelClient) ListAccessToken(ctx context.Context, resourceGroupName string, resourceName string, options *SubscriptionLevelClientListAccessTokenOptions) (SubscriptionLevelClientListAccessTokenResponse, error) { req, err := client.listAccessTokenCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return SubscriptionLevelClientListAccessTokenResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubscriptionLevelClientListAccessTokenResponse{}, err } @@ -278,7 +274,7 @@ func (client *SubscriptionLevelClient) listAccessTokenCreateRequest(ctx context. return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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 } @@ -299,10 +295,10 @@ func (client *SubscriptionLevelClient) listAccessTokenHandleResponse(resp *http. } // NewListByAzureSubscriptionPager - Gets information about all the Subscription Level SaaS in a certain Azure subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// options - SubscriptionLevelClientListByAzureSubscriptionOptions contains the optional parameters for the SubscriptionLevelClient.ListByAzureSubscription -// method. +// - options - SubscriptionLevelClientListByAzureSubscriptionOptions contains the optional parameters for the SubscriptionLevelClient.NewListByAzureSubscriptionPager +// method. func (client *SubscriptionLevelClient) NewListByAzureSubscriptionPager(options *SubscriptionLevelClientListByAzureSubscriptionOptions) *runtime.Pager[SubscriptionLevelClientListByAzureSubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[SubscriptionLevelClientListByAzureSubscriptionResponse]{ More: func(page SubscriptionLevelClientListByAzureSubscriptionResponse) bool { @@ -319,7 +315,7 @@ func (client *SubscriptionLevelClient) NewListByAzureSubscriptionPager(options * if err != nil { return SubscriptionLevelClientListByAzureSubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubscriptionLevelClientListByAzureSubscriptionResponse{}, err } @@ -338,7 +334,7 @@ func (client *SubscriptionLevelClient) listByAzureSubscriptionCreateRequest(ctx 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 } @@ -359,11 +355,11 @@ func (client *SubscriptionLevelClient) listByAzureSubscriptionHandleResponse(res } // NewListByResourceGroupPager - Gets information about all the Subscription Level SaaS in a certain resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// options - SubscriptionLevelClientListByResourceGroupOptions contains the optional parameters for the SubscriptionLevelClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. +// - options - SubscriptionLevelClientListByResourceGroupOptions contains the optional parameters for the SubscriptionLevelClient.NewListByResourceGroupPager +// method. func (client *SubscriptionLevelClient) NewListByResourceGroupPager(resourceGroupName string, options *SubscriptionLevelClientListByResourceGroupOptions) *runtime.Pager[SubscriptionLevelClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[SubscriptionLevelClientListByResourceGroupResponse]{ More: func(page SubscriptionLevelClientListByResourceGroupResponse) bool { @@ -380,7 +376,7 @@ func (client *SubscriptionLevelClient) NewListByResourceGroupPager(resourceGroup if err != nil { return SubscriptionLevelClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubscriptionLevelClientListByResourceGroupResponse{}, err } @@ -403,7 +399,7 @@ func (client *SubscriptionLevelClient) listByResourceGroupCreateRequest(ctx cont return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - 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 } @@ -425,34 +421,36 @@ func (client *SubscriptionLevelClient) listByResourceGroupHandleResponse(resp *h // BeginMoveResources - Move a specified Subscription Level SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// moveResourceParameter - Object that represents the resources to move. -// options - SubscriptionLevelClientBeginMoveResourcesOptions contains the optional parameters for the SubscriptionLevelClient.BeginMoveResources -// method. +// - resourceGroupName - The name of the resource group. +// - moveResourceParameter - Object that represents the resources to move. +// - options - SubscriptionLevelClientBeginMoveResourcesOptions contains the optional parameters for the SubscriptionLevelClient.BeginMoveResources +// method. func (client *SubscriptionLevelClient) BeginMoveResources(ctx context.Context, resourceGroupName string, moveResourceParameter MoveResource, options *SubscriptionLevelClientBeginMoveResourcesOptions) (*runtime.Poller[SubscriptionLevelClientMoveResourcesResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.moveResources(ctx, resourceGroupName, moveResourceParameter, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SubscriptionLevelClientMoveResourcesResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionLevelClientMoveResourcesResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SubscriptionLevelClientMoveResourcesResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SubscriptionLevelClientMoveResourcesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // MoveResources - Move a specified Subscription Level SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *SubscriptionLevelClient) moveResources(ctx context.Context, resourceGroupName string, moveResourceParameter MoveResource, options *SubscriptionLevelClientBeginMoveResourcesOptions) (*http.Response, error) { req, err := client.moveResourcesCreateRequest(ctx, resourceGroupName, moveResourceParameter, options) 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 } @@ -473,7 +471,7 @@ func (client *SubscriptionLevelClient) moveResourcesCreateRequest(ctx context.Co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - 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 } @@ -486,35 +484,37 @@ func (client *SubscriptionLevelClient) moveResourcesCreateRequest(ctx context.Co // BeginUpdate - Updates a SaaS Subscription Level resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// resourceName - The name of the resource. -// parameters - Parameters supplied to the update saas operation. -// options - SubscriptionLevelClientBeginUpdateOptions contains the optional parameters for the SubscriptionLevelClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - resourceName - The name of the resource. +// - parameters - Parameters supplied to the update saas operation. +// - options - SubscriptionLevelClientBeginUpdateOptions contains the optional parameters for the SubscriptionLevelClient.BeginUpdate +// method. func (client *SubscriptionLevelClient) BeginUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters ResourceCreation, options *SubscriptionLevelClientBeginUpdateOptions) (*runtime.Poller[SubscriptionLevelClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SubscriptionLevelClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionLevelClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SubscriptionLevelClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SubscriptionLevelClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a SaaS Subscription Level resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *SubscriptionLevelClient) update(ctx context.Context, resourceGroupName string, resourceName string, parameters ResourceCreation, options *SubscriptionLevelClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) 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 } @@ -539,7 +539,7 @@ func (client *SubscriptionLevelClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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 } @@ -552,35 +552,37 @@ func (client *SubscriptionLevelClient) updateCreateRequest(ctx context.Context, // BeginUpdateToUnsubscribed - Unsubscribe from a specified Subscription Level SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// resourceName - The name of the resource. -// parameters - Parameters supplied to unsubscribe saas operation. -// options - SubscriptionLevelClientBeginUpdateToUnsubscribedOptions contains the optional parameters for the SubscriptionLevelClient.BeginUpdateToUnsubscribed -// method. +// - resourceGroupName - The name of the resource group. +// - resourceName - The name of the resource. +// - parameters - Parameters supplied to unsubscribe saas operation. +// - options - SubscriptionLevelClientBeginUpdateToUnsubscribedOptions contains the optional parameters for the SubscriptionLevelClient.BeginUpdateToUnsubscribed +// method. func (client *SubscriptionLevelClient) BeginUpdateToUnsubscribed(ctx context.Context, resourceGroupName string, resourceName string, parameters DeleteOptions, options *SubscriptionLevelClientBeginUpdateToUnsubscribedOptions) (*runtime.Poller[SubscriptionLevelClientUpdateToUnsubscribedResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.updateToUnsubscribed(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SubscriptionLevelClientUpdateToUnsubscribedResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubscriptionLevelClientUpdateToUnsubscribedResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SubscriptionLevelClientUpdateToUnsubscribedResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SubscriptionLevelClientUpdateToUnsubscribedResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // UpdateToUnsubscribed - Unsubscribe from a specified Subscription Level SaaS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta func (client *SubscriptionLevelClient) updateToUnsubscribed(ctx context.Context, resourceGroupName string, resourceName string, parameters DeleteOptions, options *SubscriptionLevelClientBeginUpdateToUnsubscribedOptions) (*http.Response, error) { req, err := client.updateToUnsubscribedCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) 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 } @@ -605,7 +607,7 @@ func (client *SubscriptionLevelClient) updateToUnsubscribedCreateRequest(ctx con return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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 } @@ -618,17 +620,18 @@ func (client *SubscriptionLevelClient) updateToUnsubscribedCreateRequest(ctx con // ValidateMoveResources - Validate whether a specified Subscription Level SaaS can be moved. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-03-01-beta -// resourceGroupName - The name of the resource group. -// moveResourceParameter - Object that represents the resources to move. -// options - SubscriptionLevelClientValidateMoveResourcesOptions contains the optional parameters for the SubscriptionLevelClient.ValidateMoveResources -// method. +// - resourceGroupName - The name of the resource group. +// - moveResourceParameter - Object that represents the resources to move. +// - options - SubscriptionLevelClientValidateMoveResourcesOptions contains the optional parameters for the SubscriptionLevelClient.ValidateMoveResources +// method. func (client *SubscriptionLevelClient) ValidateMoveResources(ctx context.Context, resourceGroupName string, moveResourceParameter MoveResource, options *SubscriptionLevelClientValidateMoveResourcesOptions) (SubscriptionLevelClientValidateMoveResourcesResponse, error) { req, err := client.validateMoveResourcesCreateRequest(ctx, resourceGroupName, moveResourceParameter, options) if err != nil { return SubscriptionLevelClientValidateMoveResourcesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SubscriptionLevelClientValidateMoveResourcesResponse{}, err } @@ -649,7 +652,7 @@ func (client *SubscriptionLevelClient) validateMoveResourcesCreateRequest(ctx co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - 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/saas/armsaas/subscriptionlevel_client_example_test.go b/sdk/resourcemanager/saas/armsaas/subscriptionlevel_client_example_test.go new file mode 100644 index 000000000000..462ecbd192eb --- /dev/null +++ b/sdk/resourcemanager/saas/armsaas/subscriptionlevel_client_example_test.go @@ -0,0 +1,422 @@ +//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 armsaas_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/saas/armsaas" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasGetAllInAzureSubscription.json +func ExampleSubscriptionLevelClient_NewListByAzureSubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionLevelClient().NewListByAzureSubscriptionPager(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.ResourceResponseWithContinuation = armsaas.ResourceResponseWithContinuation{ + // Value: []*armsaas.Resource{ + // { + // Name: to.Ptr("MyContosoSubscription"), + // Type: to.Ptr("Microsoft.SaaS/resources"), + // ID: to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/MyContosoSubscription"), + // Properties: &armsaas.ResourceProperties{ + // AutoRenew: to.Ptr(true), + // OfferID: to.Ptr("contosoOffer"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("c825645b-e31b-9cf4-1cee-2aba9e58bc7c"), + // "resourceId": to.Ptr("263ebe8c-3621-4ac0-a6ba-f1419bfb9166"), + // }, + // PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + // PublisherID: to.Ptr("microsoft-contoso"), + // SaasResourceName: to.Ptr("MyContosoSubscription"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2021-01-01T08:30:10.1234567Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-01-01T08:35:05.7654321Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2021-02-31T00:00:00Z"), + // StartDate: to.Ptr("2021-01-01T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasGetAllInResourceGroup.json +func ExampleSubscriptionLevelClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSubscriptionLevelClient().NewListByResourceGroupPager("my-saas-rg", 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.ResourceResponseWithContinuation = armsaas.ResourceResponseWithContinuation{ + // Value: []*armsaas.Resource{ + // { + // Name: to.Ptr("MyContosoSubscription"), + // Type: to.Ptr("Microsoft.SaaS/resources"), + // ID: to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/MyContosoSubscription"), + // Properties: &armsaas.ResourceProperties{ + // AutoRenew: to.Ptr(true), + // OfferID: to.Ptr("contosoOffer"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("c825645b-e31b-9cf4-1cee-2aba9e58bc7c"), + // "resourceId": to.Ptr("263ebe8c-3621-4ac0-a6ba-f1419bfb9166"), + // }, + // PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + // PublisherID: to.Ptr("microsoft-contoso"), + // SaasResourceName: to.Ptr("MyContosoSubscription"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2021-01-01T08:30:10.1234567Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-01-01T08:35:05.7654321Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2021-02-31T00:00:00Z"), + // StartDate: to.Ptr("2021-01-01T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasGet.json +func ExampleSubscriptionLevelClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSubscriptionLevelClient().Get(ctx, "my-saas-rg", "MyContosoSubscription", 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.Resource = armsaas.Resource{ + // Name: to.Ptr("MyContosoSubscription"), + // Type: to.Ptr("Microsoft.SaaS/resources"), + // ID: to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/MyContosoSubscription"), + // Properties: &armsaas.ResourceProperties{ + // AutoRenew: to.Ptr(true), + // OfferID: to.Ptr("contosoOffer"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("c825645b-e31b-9cf4-1cee-2aba9e58bc7c"), + // "resourceId": to.Ptr("263ebe8c-3621-4ac0-a6ba-f1419bfb9166"), + // }, + // PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + // PublisherID: to.Ptr("microsoft-contoso"), + // SaasResourceName: to.Ptr("MyContosoSubscription"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2021-01-01T08:30:10.1234567Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-01-01T08:35:05.7654321Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2021-02-31T00:00:00Z"), + // StartDate: to.Ptr("2021-01-01T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasPut.json +func ExampleSubscriptionLevelClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionLevelClient().BeginCreateOrUpdate(ctx, "my-saas-rg", "MyContosoSubscription", armsaas.ResourceCreation{ + Name: to.Ptr("MyContosoSubscription"), + Location: to.Ptr("global"), + Properties: &armsaas.CreationProperties{ + OfferID: to.Ptr("contosoOffer"), + PaymentChannelMetadata: map[string]*string{ + "AzureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), + }, + PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + PublisherID: to.Ptr("microsoft-contoso"), + SaasResourceName: to.Ptr("MyContosoSubscription"), + SKUID: to.Ptr("free"), + TermID: to.Ptr("hjdtn7tfnxcy"), + }, + }, 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.Resource = armsaas.Resource{ + // Name: to.Ptr("MyContosoSubscription"), + // Type: to.Ptr("Microsoft.SaaS/resources"), + // ID: to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/MyContosoSubscription"), + // Properties: &armsaas.ResourceProperties{ + // AutoRenew: to.Ptr(true), + // OfferID: to.Ptr("contosoOffer"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("c825645b-e31b-9cf4-1cee-2aba9e58bc7c"), + // "resourceId": to.Ptr("263ebe8c-3621-4ac0-a6ba-f1419bfb9166"), + // }, + // PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + // PublisherID: to.Ptr("microsoft-contoso"), + // SaasResourceName: to.Ptr("MyContosoSubscription"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2021-01-01T08:30:10.1234567Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-01-01T08:35:05.7654321Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2021-02-31T00:00:00Z"), + // StartDate: to.Ptr("2021-01-01T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasPatch.json +func ExampleSubscriptionLevelClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionLevelClient().BeginUpdate(ctx, "my-saas-rg", "MyContosoSubscription", armsaas.ResourceCreation{ + Properties: &armsaas.CreationProperties{ + SKUID: to.Ptr("premium"), + }, + Tags: map[string]*string{}, + }, 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.Resource = armsaas.Resource{ + // Name: to.Ptr("MyContosoSubscription"), + // Type: to.Ptr("Microsoft.SaaS/resources"), + // ID: to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/MyContosoSubscription"), + // Properties: &armsaas.ResourceProperties{ + // AutoRenew: to.Ptr(true), + // OfferID: to.Ptr("contosoOffer"), + // PaymentChannelMetadata: map[string]*string{ + // "azureSubscriptionId": to.Ptr("c825645b-e31b-9cf4-1cee-2aba9e58bc7c"), + // "resourceId": to.Ptr("263ebe8c-3621-4ac0-a6ba-f1419bfb9166"), + // }, + // PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), + // PublisherID: to.Ptr("microsoft-contoso"), + // SaasResourceName: to.Ptr("MyContosoSubscription"), + // SKUID: to.Ptr("free"), + // Created: to.Ptr("2021-01-01T08:30:10.1234567Z"), + // IsFreeTrial: to.Ptr(false), + // LastModified: to.Ptr("2020-01-01T08:35:05.7654321Z"), + // Status: to.Ptr(armsaas.SaasResourceStatusSubscribed), + // Term: &armsaas.PropertiesTerm{ + // EndDate: to.Ptr("2021-02-31T00:00:00Z"), + // StartDate: to.Ptr("2021-01-01T00:00:00Z"), + // TermUnit: to.Ptr("P1M"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasDelete.json +func ExampleSubscriptionLevelClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionLevelClient().BeginDelete(ctx, "my-saas-rg", "MyContosoSubscription", 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/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasUnsubscribe.json +func ExampleSubscriptionLevelClient_BeginUpdateToUnsubscribed() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionLevelClient().BeginUpdateToUnsubscribed(ctx, "my-saas-rg", "MyContosoSubscription", armsaas.DeleteOptions{ + Feedback: to.Ptr("No longer need this SaaS"), + ReasonCode: to.Ptr[float32](0), + UnsubscribeOnly: to.Ptr(true), + }, 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/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/ListAccessTokenPost.json +func ExampleSubscriptionLevelClient_ListAccessToken() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSubscriptionLevelClient().ListAccessToken(ctx, "my-saas-rg", "MyContosoSubscription", 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.AccessTokenResult = armsaas.AccessTokenResult{ + // PublisherOfferBaseURI: to.Ptr("https://contoso.website.com/api/v1/marketplace/azure/common/auth"), + // Token: to.Ptr("jyhAtr3AiFTXO0QsEkYizsNzqIAUJ+E0M1SXhl4E5hwAl7+GJT6t+dEwuWpSizgR0Vn6dMhzpS94JRzkUh2Xuq5L1QDgmDkDUeIikTFNviwtwxtF8CwipcB49rq5d8whmVp0CmWEjd/FzU0vvlikBRuy+asxC1UhXv6XxBkSxkZKj29AAFiGgsgRvXIld47C"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/ValidateResourceMove.json +func ExampleSubscriptionLevelClient_ValidateMoveResources() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewSubscriptionLevelClient().ValidateMoveResources(ctx, "my-saas-rg", armsaas.MoveResource{ + Resources: []*string{ + to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas1"), + to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas2"), + to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas3")}, + TargetResourceGroup: to.Ptr("/subscriptions/5122d0a3-1e10-4baf-bdc5-c2a452489525/resourceGroups/new-saas-rg"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/ResourceMove.json +func ExampleSubscriptionLevelClient_BeginMoveResources() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsaas.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSubscriptionLevelClient().BeginMoveResources(ctx, "my-saas-rg", armsaas.MoveResource{ + Resources: []*string{ + to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas1"), + to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas2"), + to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas3")}, + TargetResourceGroup: to.Ptr("/subscriptions/5122d0a3-1e10-4baf-bdc5-c2a452489525/resourceGroups/new-saas-rg"), + }, 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/saas/armsaas/ze_generated_example_applications_client_test.go b/sdk/resourcemanager/saas/armsaas/ze_generated_example_applications_client_test.go deleted file mode 100644 index a6f997aed69a..000000000000 --- a/sdk/resourcemanager/saas/armsaas/ze_generated_example_applications_client_test.go +++ /dev/null @@ -1,42 +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. - -package armsaas_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV1/SaaSGetApplications.json -func ExampleApplicationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewApplicationsClient("bc6c2f82-a39d-41b8-a648-71527498a23e", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myResourceGroup", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/saas/armsaas/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/saas/armsaas/ze_generated_example_operations_client_test.go deleted file mode 100644 index bcdb4b51a653..000000000000 --- a/sdk/resourcemanager/saas/armsaas/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +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. - -package armsaas_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV1/SaaSGetOperations.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 := armsaas.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saas_client_test.go b/sdk/resourcemanager/saas/armsaas/ze_generated_example_saas_client_test.go deleted file mode 100644 index 49bb212f592a..000000000000 --- a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saas_client_test.go +++ /dev/null @@ -1,134 +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. - -package armsaas_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/saas/armsaas" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasDelete.json -func ExampleClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "115c3523-1fae-757f-af86-7b27cfd29805", - armsaas.DeleteOptions{ - ReasonCode: to.Ptr[float32](0), - UnsubscribeOnly: to.Ptr(true), - }, - 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/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasGet.json -func ExampleClient_GetResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetResource(ctx, - "115c3523-1fae-757f-af86-7b27cfd29805", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasPatch.json -func ExampleClient_BeginUpdateResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdateResource(ctx, - "115c3523-1fae-757f-af86-7b27cfd29805", - armsaas.ResourceCreation{ - Properties: &armsaas.CreationProperties{ - SKUID: to.Ptr("premium"), - }, - Tags: map[string]*string{}, - }, - 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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaasPut.json -func ExampleClient_BeginCreateResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateResource(ctx, - armsaas.ResourceCreation{ - Properties: &armsaas.CreationProperties{ - OfferID: to.Ptr("microsofthealthcarebot"), - PaymentChannelMetadata: map[string]*string{ - "AzureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), - }, - PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), - PublisherID: to.Ptr("microsoft-hcb"), - SaasResourceName: to.Ptr("testRunnerFromArm"), - SKUID: to.Ptr("free"), - TermID: to.Ptr("hjdtn7tfnxcy"), - }, - }, - 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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saasoperation_client_test.go b/sdk/resourcemanager/saas/armsaas/ze_generated_example_saasoperation_client_test.go deleted file mode 100644 index afb414ccfeaf..000000000000 --- a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saasoperation_client_test.go +++ /dev/null @@ -1,42 +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. - -package armsaas_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/OperationResults/Get.json -func ExampleOperationClient_BeginGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewOperationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginGet(ctx, - "5f35cb4c-8065-45b3-9116-5ba335462e95", - 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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saasresources_client_test.go b/sdk/resourcemanager/saas/armsaas/ze_generated_example_saasresources_client_test.go deleted file mode 100644 index c8761f289123..000000000000 --- a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saasresources_client_test.go +++ /dev/null @@ -1,62 +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. - -package armsaas_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/saas/armsaas" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/SaaSGetAllResources.json -func ExampleResourcesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewResourcesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasV2/ListAccessTokenPost.json -func ExampleResourcesClient_ListAccessToken() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewResourcesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListAccessToken(ctx, - "c825645b-e31b-9cf4-1cee-2aba9e58bc7c", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saassubscriptionlevel_client_test.go b/sdk/resourcemanager/saas/armsaas/ze_generated_example_saassubscriptionlevel_client_test.go deleted file mode 100644 index 72e1e0e75ca1..000000000000 --- a/sdk/resourcemanager/saas/armsaas/ze_generated_example_saassubscriptionlevel_client_test.go +++ /dev/null @@ -1,293 +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. - -package armsaas_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/saas/armsaas" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasGetAllInAzureSubscription.json -func ExampleSubscriptionLevelClient_NewListByAzureSubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByAzureSubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasGetAllInResourceGroup.json -func ExampleSubscriptionLevelClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("my-saas-rg", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasGet.json -func ExampleSubscriptionLevelClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "my-saas-rg", - "MyContosoSubscription", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasPut.json -func ExampleSubscriptionLevelClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "my-saas-rg", - "MyContosoSubscription", - armsaas.ResourceCreation{ - Name: to.Ptr("MyContosoSubscription"), - Location: to.Ptr("global"), - Properties: &armsaas.CreationProperties{ - OfferID: to.Ptr("contosoOffer"), - PaymentChannelMetadata: map[string]*string{ - "AzureSubscriptionId": to.Ptr("155af98a-3205-47e7-883b-a2ab9db9f88d"), - }, - PaymentChannelType: to.Ptr(armsaas.PaymentChannelTypeSubscriptionDelegated), - PublisherID: to.Ptr("microsoft-contoso"), - SaasResourceName: to.Ptr("MyContosoSubscription"), - SKUID: to.Ptr("free"), - TermID: to.Ptr("hjdtn7tfnxcy"), - }, - }, - 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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasPatch.json -func ExampleSubscriptionLevelClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "my-saas-rg", - "MyContosoSubscription", - armsaas.ResourceCreation{ - Properties: &armsaas.CreationProperties{ - SKUID: to.Ptr("premium"), - }, - Tags: map[string]*string{}, - }, - 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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasDelete.json -func ExampleSubscriptionLevelClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "my-saas-rg", - "MyContosoSubscription", - 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/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/SaasUnsubscribe.json -func ExampleSubscriptionLevelClient_BeginUpdateToUnsubscribed() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdateToUnsubscribed(ctx, - "my-saas-rg", - "MyContosoSubscription", - armsaas.DeleteOptions{ - Feedback: to.Ptr("No longer need this SaaS"), - ReasonCode: to.Ptr[float32](0), - UnsubscribeOnly: to.Ptr(true), - }, - 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/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/ListAccessTokenPost.json -func ExampleSubscriptionLevelClient_ListAccessToken() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListAccessToken(ctx, - "my-saas-rg", - "MyContosoSubscription", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/ValidateResourceMove.json -func ExampleSubscriptionLevelClient_ValidateMoveResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.ValidateMoveResources(ctx, - "my-saas-rg", - armsaas.MoveResource{ - Resources: []*string{ - to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas1"), - to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas2"), - to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas3")}, - TargetResourceGroup: to.Ptr("/subscriptions/5122d0a3-1e10-4baf-bdc5-c2a452489525/resourceGroups/new-saas-rg"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/saas/resource-manager/Microsoft.SaaS/preview/2018-03-01-beta/examples/saasSubscriptionLevel/ResourceMove.json -func ExampleSubscriptionLevelClient_BeginMoveResources() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsaas.NewSubscriptionLevelClient("c825645b-e31b-9cf4-1cee-2aba9e58bc7c", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginMoveResources(ctx, - "my-saas-rg", - armsaas.MoveResource{ - Resources: []*string{ - to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas1"), - to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas2"), - to.Ptr("/subscriptions/c825645b-e31b-9cf4-1cee-2aba9e58bc7c/resourceGroups/my-saas-rg/providers/Microsoft.SaaS/resources/saas3")}, - TargetResourceGroup: to.Ptr("/subscriptions/5122d0a3-1e10-4baf-bdc5-c2a452489525/resourceGroups/new-saas-rg"), - }, - 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/saas/armsaas/zz_generated_models_serde.go b/sdk/resourcemanager/saas/armsaas/zz_generated_models_serde.go deleted file mode 100644 index 84dbde3bb5f6..000000000000 --- a/sdk/resourcemanager/saas/armsaas/zz_generated_models_serde.go +++ /dev/null @@ -1,86 +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. - -package armsaas - -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type CreationProperties. -func (c CreationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "autoRenew", c.AutoRenew) - populate(objectMap, "offerId", c.OfferID) - populate(objectMap, "paymentChannelMetadata", c.PaymentChannelMetadata) - populate(objectMap, "paymentChannelType", c.PaymentChannelType) - populate(objectMap, "publisherId", c.PublisherID) - populate(objectMap, "publisherTestEnvironment", c.PublisherTestEnvironment) - populate(objectMap, "quantity", c.Quantity) - populate(objectMap, "skuId", c.SKUID) - populate(objectMap, "saasResourceName", c.SaasResourceName) - populate(objectMap, "saasSessionId", c.SaasSessionID) - populate(objectMap, "saasSubscriptionId", c.SaasSubscriptionID) - populate(objectMap, "termId", c.TermID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type MoveResource. -func (m MoveResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "resources", m.Resources) - populate(objectMap, "targetResourceGroup", m.TargetResourceGroup) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceCreation. -func (r ResourceCreation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceProperties. -func (r ResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "autoRenew", r.AutoRenew) - populate(objectMap, "created", r.Created) - populate(objectMap, "isFreeTrial", r.IsFreeTrial) - populate(objectMap, "lastModified", r.LastModified) - populate(objectMap, "offerId", r.OfferID) - populate(objectMap, "paymentChannelMetadata", r.PaymentChannelMetadata) - populate(objectMap, "paymentChannelType", r.PaymentChannelType) - populate(objectMap, "publisherId", r.PublisherID) - populate(objectMap, "publisherTestEnvironment", r.PublisherTestEnvironment) - populate(objectMap, "quantity", r.Quantity) - populate(objectMap, "skuId", r.SKUID) - populate(objectMap, "saasResourceName", r.SaasResourceName) - populate(objectMap, "saasSessionId", r.SaasSessionID) - populate(objectMap, "saasSubscriptionId", r.SaasSubscriptionID) - populate(objectMap, "status", r.Status) - populate(objectMap, "term", r.Term) - populate(objectMap, "termId", r.TermID) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md b/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md index 0b1adc019460..030bc1804f89 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.2.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.1.0 (2023-01-11) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/README.md b/sdk/resourcemanager/servicenetworking/armservicenetworking/README.md index 956e5473458e..e0fdef39fc64 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/README.md +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Servicenetworking modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Servicenetworking module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armservicenetworking.NewAssociationsInterfaceClient(, cred, nil) +clientFactory, err := armservicenetworking.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armservicenetworking.NewAssociationsInterfaceClient(, cred, &options) +clientFactory, err := armservicenetworking.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewAssociationsInterfaceClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client.go index e5029bffcd69..4d6d707c14d4 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_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,67 +24,60 @@ import ( // AssociationsInterfaceClient contains the methods for the AssociationsInterface group. // Don't use this type directly, use NewAssociationsInterfaceClient() instead. type AssociationsInterfaceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssociationsInterfaceClient creates a new instance of AssociationsInterfaceClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssociationsInterfaceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssociationsInterfaceClient, 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+".AssociationsInterfaceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssociationsInterfaceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create a Traffic Controller Association // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// associationName - Name of Association -// resource - Resource create parameters. -// options - AssociationsInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the AssociationsInterfaceClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - associationName - Name of Association +// - resource - Resource create parameters. +// - options - AssociationsInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the AssociationsInterfaceClient.BeginCreateOrUpdate +// method. func (client *AssociationsInterfaceClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, resource Association, options *AssociationsInterfaceClientBeginCreateOrUpdateOptions) (*runtime.Poller[AssociationsInterfaceClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, trafficControllerName, associationName, resource, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AssociationsInterfaceClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AssociationsInterfaceClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AssociationsInterfaceClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AssociationsInterfaceClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create a Traffic Controller Association // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview func (client *AssociationsInterfaceClient) createOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, resource Association, options *AssociationsInterfaceClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, trafficControllerName, associationName, resource, options) 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 } @@ -115,7 +106,7 @@ func (client *AssociationsInterfaceClient) createOrUpdateCreateRequest(ctx conte return nil, errors.New("parameter associationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{associationName}", url.PathEscape(associationName)) - 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 } @@ -128,35 +119,37 @@ func (client *AssociationsInterfaceClient) createOrUpdateCreateRequest(ctx conte // BeginDelete - Delete a Traffic Controller Association // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// associationName - Name of Association -// options - AssociationsInterfaceClientBeginDeleteOptions contains the optional parameters for the AssociationsInterfaceClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - associationName - Name of Association +// - options - AssociationsInterfaceClientBeginDeleteOptions contains the optional parameters for the AssociationsInterfaceClient.BeginDelete +// method. func (client *AssociationsInterfaceClient) BeginDelete(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, options *AssociationsInterfaceClientBeginDeleteOptions) (*runtime.Poller[AssociationsInterfaceClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, trafficControllerName, associationName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AssociationsInterfaceClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AssociationsInterfaceClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[AssociationsInterfaceClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AssociationsInterfaceClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a Traffic Controller Association // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview func (client *AssociationsInterfaceClient) deleteOperation(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, options *AssociationsInterfaceClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, trafficControllerName, associationName, options) 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 } @@ -185,7 +178,7 @@ func (client *AssociationsInterfaceClient) deleteCreateRequest(ctx context.Conte return nil, errors.New("parameter associationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{associationName}", url.PathEscape(associationName)) - 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 } @@ -198,18 +191,19 @@ func (client *AssociationsInterfaceClient) deleteCreateRequest(ctx context.Conte // Get - Get a Traffic Controller Association // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// associationName - Name of Association -// options - AssociationsInterfaceClientGetOptions contains the optional parameters for the AssociationsInterfaceClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - associationName - Name of Association +// - options - AssociationsInterfaceClientGetOptions contains the optional parameters for the AssociationsInterfaceClient.Get +// method. func (client *AssociationsInterfaceClient) Get(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, options *AssociationsInterfaceClientGetOptions) (AssociationsInterfaceClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, trafficControllerName, associationName, options) if err != nil { return AssociationsInterfaceClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssociationsInterfaceClientGetResponse{}, err } @@ -238,7 +232,7 @@ func (client *AssociationsInterfaceClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter associationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{associationName}", url.PathEscape(associationName)) - 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 } @@ -259,11 +253,12 @@ func (client *AssociationsInterfaceClient) getHandleResponse(resp *http.Response } // NewListByTrafficControllerPager - List Association resources by TrafficController +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// options - AssociationsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the AssociationsInterfaceClient.ListByTrafficController -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - options - AssociationsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the AssociationsInterfaceClient.NewListByTrafficControllerPager +// method. func (client *AssociationsInterfaceClient) NewListByTrafficControllerPager(resourceGroupName string, trafficControllerName string, options *AssociationsInterfaceClientListByTrafficControllerOptions) *runtime.Pager[AssociationsInterfaceClientListByTrafficControllerResponse] { return runtime.NewPager(runtime.PagingHandler[AssociationsInterfaceClientListByTrafficControllerResponse]{ More: func(page AssociationsInterfaceClientListByTrafficControllerResponse) bool { @@ -280,7 +275,7 @@ func (client *AssociationsInterfaceClient) NewListByTrafficControllerPager(resou if err != nil { return AssociationsInterfaceClientListByTrafficControllerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssociationsInterfaceClientListByTrafficControllerResponse{}, err } @@ -307,7 +302,7 @@ func (client *AssociationsInterfaceClient) listByTrafficControllerCreateRequest( return nil, errors.New("parameter trafficControllerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) - 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 } @@ -329,19 +324,20 @@ func (client *AssociationsInterfaceClient) listByTrafficControllerHandleResponse // Update - Update a Traffic Controller Association // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// associationName - Name of Association -// properties - The resource properties to be updated. -// options - AssociationsInterfaceClientUpdateOptions contains the optional parameters for the AssociationsInterfaceClient.Update -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - associationName - Name of Association +// - properties - The resource properties to be updated. +// - options - AssociationsInterfaceClientUpdateOptions contains the optional parameters for the AssociationsInterfaceClient.Update +// method. func (client *AssociationsInterfaceClient) Update(ctx context.Context, resourceGroupName string, trafficControllerName string, associationName string, properties AssociationUpdate, options *AssociationsInterfaceClientUpdateOptions) (AssociationsInterfaceClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, trafficControllerName, associationName, properties, options) if err != nil { return AssociationsInterfaceClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssociationsInterfaceClientUpdateResponse{}, err } @@ -370,7 +366,7 @@ func (client *AssociationsInterfaceClient) updateCreateRequest(ctx context.Conte return nil, errors.New("parameter associationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{associationName}", url.PathEscape(associationName)) - 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 } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client_example_test.go index 56aab1ff2f74..e45a3a5a0993 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client_example_test.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/associationsinterface_client_example_test.go @@ -5,6 +5,7 @@ // 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 armservicenetworking_test @@ -17,61 +18,92 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationsGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationsGet.json func ExampleAssociationsInterfaceClient_NewListByTrafficControllerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewAssociationsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByTrafficControllerPager("rg1", "TC1", nil) + pager := clientFactory.NewAssociationsInterfaceClient().NewListByTrafficControllerPager("rg1", "TC1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.AssociationListResult = armservicenetworking.AssociationListResult{ + // Value: []*armservicenetworking.Association{ + // { + // Name: to.Ptr("associatedvnet-2"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), + // ID: to.Ptr("resourceUriAsString"), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.AssociationProperties{ + // AssociationType: to.Ptr("subnets"), + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // Subnet: &armservicenetworking.AssociationSubnet{ + // ID: to.Ptr("subnetFullRef"), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationGet.json func ExampleAssociationsInterfaceClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewAssociationsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "TC1", "associatedvnet-2", nil) + res, err := clientFactory.NewAssociationsInterfaceClient().Get(ctx, "rg1", "TC1", "associatedvnet-2", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.Association = armservicenetworking.Association{ + // Name: to.Ptr("associatedvnet-2"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), + // ID: to.Ptr("resourceUriAsString"), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.AssociationProperties{ + // AssociationType: to.Ptr("subnets"), + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // Subnet: &armservicenetworking.AssociationSubnet{ + // ID: to.Ptr("subnetFullRef"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationPut.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationPut.json func ExampleAssociationsInterfaceClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewAssociationsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "TC1", "associatedvnet-1", armservicenetworking.Association{ + poller, err := clientFactory.NewAssociationsInterfaceClient().BeginCreateOrUpdate(ctx, "rg1", "TC1", "associatedvnet-1", armservicenetworking.Association{ Location: to.Ptr("West US"), Properties: &armservicenetworking.AssociationProperties{ AssociationType: to.Ptr("subnets"), @@ -87,22 +119,36 @@ func ExampleAssociationsInterfaceClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.Association = armservicenetworking.Association{ + // Name: to.Ptr("associatedvnet-1"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), + // ID: to.Ptr("resourceUriAsString "), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.AssociationProperties{ + // AssociationType: to.Ptr("subnets"), + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // Subnet: &armservicenetworking.AssociationSubnet{ + // ID: to.Ptr("subnetFullRef"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationPatch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationPatch.json func ExampleAssociationsInterfaceClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewAssociationsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "rg1", "TC1", "associatedvnet-1", armservicenetworking.AssociationUpdate{ + res, err := clientFactory.NewAssociationsInterfaceClient().Update(ctx, "rg1", "TC1", "associatedvnet-1", armservicenetworking.AssociationUpdate{ Properties: &armservicenetworking.AssociationUpdateProperties{ AssociationType: to.Ptr("subnets"), Subnet: &armservicenetworking.AssociationSubnet{ @@ -113,22 +159,35 @@ func ExampleAssociationsInterfaceClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.Association = armservicenetworking.Association{ + // Name: to.Ptr("associatedvnet-1"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/associations"), + // ID: to.Ptr("resourceUriAsString "), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.AssociationProperties{ + // AssociationType: to.Ptr("subnets"), + // Subnet: &armservicenetworking.AssociationSubnet{ + // ID: to.Ptr("subnetFullRef"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/AssociationDelete.json func ExampleAssociationsInterfaceClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewAssociationsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "TC1", "associatedvnet-2", nil) + poller, err := clientFactory.NewAssociationsInterfaceClient().BeginDelete(ctx, "rg1", "TC1", "associatedvnet-2", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md b/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md index a9713e7e32e7..14e0d9dcae1e 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 +module-version: 0.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/client_factory.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/client_factory.go new file mode 100644 index 000000000000..f6a45e9c3ff3 --- /dev/null +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/client_factory.go @@ -0,0 +1,59 @@ +//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 armservicenetworking + +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 - The ID of the target subscription. +// - 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) NewTrafficControllerInterfaceClient() *TrafficControllerInterfaceClient { + subClient, _ := NewTrafficControllerInterfaceClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssociationsInterfaceClient() *AssociationsInterfaceClient { + subClient, _ := NewAssociationsInterfaceClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFrontendsInterfaceClient() *FrontendsInterfaceClient { + subClient, _ := NewFrontendsInterfaceClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go index 1bdffd6741be..1478cceb156d 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/constants.go @@ -11,7 +11,7 @@ package armservicenetworking const ( moduleName = "armservicenetworking" - moduleVersion = "v0.1.0" + moduleVersion = "v0.2.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client.go index c62644cbfdba..f017c64452ee 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_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,67 +24,60 @@ import ( // FrontendsInterfaceClient contains the methods for the FrontendsInterface group. // Don't use this type directly, use NewFrontendsInterfaceClient() instead. type FrontendsInterfaceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFrontendsInterfaceClient creates a new instance of FrontendsInterfaceClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFrontendsInterfaceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FrontendsInterfaceClient, 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+".FrontendsInterfaceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FrontendsInterfaceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create a Traffic Controller Frontend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// frontendName - Frontends -// resource - Resource create parameters. -// options - FrontendsInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the FrontendsInterfaceClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - frontendName - Frontends +// - resource - Resource create parameters. +// - options - FrontendsInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the FrontendsInterfaceClient.BeginCreateOrUpdate +// method. func (client *FrontendsInterfaceClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, resource Frontend, options *FrontendsInterfaceClientBeginCreateOrUpdateOptions) (*runtime.Poller[FrontendsInterfaceClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, trafficControllerName, frontendName, resource, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FrontendsInterfaceClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FrontendsInterfaceClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[FrontendsInterfaceClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FrontendsInterfaceClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create a Traffic Controller Frontend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview func (client *FrontendsInterfaceClient) createOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, resource Frontend, options *FrontendsInterfaceClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, trafficControllerName, frontendName, resource, options) 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 } @@ -115,7 +106,7 @@ func (client *FrontendsInterfaceClient) createOrUpdateCreateRequest(ctx context. return nil, errors.New("parameter frontendName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontendName}", url.PathEscape(frontendName)) - 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 } @@ -128,35 +119,37 @@ func (client *FrontendsInterfaceClient) createOrUpdateCreateRequest(ctx context. // BeginDelete - Delete a Traffic Controller Frontend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// frontendName - Frontends -// options - FrontendsInterfaceClientBeginDeleteOptions contains the optional parameters for the FrontendsInterfaceClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - frontendName - Frontends +// - options - FrontendsInterfaceClientBeginDeleteOptions contains the optional parameters for the FrontendsInterfaceClient.BeginDelete +// method. func (client *FrontendsInterfaceClient) BeginDelete(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, options *FrontendsInterfaceClientBeginDeleteOptions) (*runtime.Poller[FrontendsInterfaceClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, trafficControllerName, frontendName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FrontendsInterfaceClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FrontendsInterfaceClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[FrontendsInterfaceClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FrontendsInterfaceClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a Traffic Controller Frontend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview func (client *FrontendsInterfaceClient) deleteOperation(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, options *FrontendsInterfaceClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, trafficControllerName, frontendName, options) 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 } @@ -185,7 +178,7 @@ func (client *FrontendsInterfaceClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter frontendName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontendName}", url.PathEscape(frontendName)) - 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 } @@ -198,17 +191,18 @@ func (client *FrontendsInterfaceClient) deleteCreateRequest(ctx context.Context, // Get - Get a Traffic Controller Frontend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// frontendName - Frontends -// options - FrontendsInterfaceClientGetOptions contains the optional parameters for the FrontendsInterfaceClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - frontendName - Frontends +// - options - FrontendsInterfaceClientGetOptions contains the optional parameters for the FrontendsInterfaceClient.Get method. func (client *FrontendsInterfaceClient) Get(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, options *FrontendsInterfaceClientGetOptions) (FrontendsInterfaceClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, trafficControllerName, frontendName, options) if err != nil { return FrontendsInterfaceClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontendsInterfaceClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *FrontendsInterfaceClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter frontendName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontendName}", url.PathEscape(frontendName)) - 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 } @@ -258,11 +252,12 @@ func (client *FrontendsInterfaceClient) getHandleResponse(resp *http.Response) ( } // NewListByTrafficControllerPager - List Frontend resources by TrafficController +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// options - FrontendsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the FrontendsInterfaceClient.ListByTrafficController -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - options - FrontendsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the FrontendsInterfaceClient.NewListByTrafficControllerPager +// method. func (client *FrontendsInterfaceClient) NewListByTrafficControllerPager(resourceGroupName string, trafficControllerName string, options *FrontendsInterfaceClientListByTrafficControllerOptions) *runtime.Pager[FrontendsInterfaceClientListByTrafficControllerResponse] { return runtime.NewPager(runtime.PagingHandler[FrontendsInterfaceClientListByTrafficControllerResponse]{ More: func(page FrontendsInterfaceClientListByTrafficControllerResponse) bool { @@ -279,7 +274,7 @@ func (client *FrontendsInterfaceClient) NewListByTrafficControllerPager(resource if err != nil { return FrontendsInterfaceClientListByTrafficControllerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontendsInterfaceClientListByTrafficControllerResponse{}, err } @@ -306,7 +301,7 @@ func (client *FrontendsInterfaceClient) listByTrafficControllerCreateRequest(ctx return nil, errors.New("parameter trafficControllerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) - 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 } @@ -328,19 +323,20 @@ func (client *FrontendsInterfaceClient) listByTrafficControllerHandleResponse(re // Update - Update a Traffic Controller Frontend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// frontendName - Frontends -// properties - The resource properties to be updated. -// options - FrontendsInterfaceClientUpdateOptions contains the optional parameters for the FrontendsInterfaceClient.Update -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - frontendName - Frontends +// - properties - The resource properties to be updated. +// - options - FrontendsInterfaceClientUpdateOptions contains the optional parameters for the FrontendsInterfaceClient.Update +// method. func (client *FrontendsInterfaceClient) Update(ctx context.Context, resourceGroupName string, trafficControllerName string, frontendName string, properties FrontendUpdate, options *FrontendsInterfaceClientUpdateOptions) (FrontendsInterfaceClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, trafficControllerName, frontendName, properties, options) if err != nil { return FrontendsInterfaceClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontendsInterfaceClientUpdateResponse{}, err } @@ -369,7 +365,7 @@ func (client *FrontendsInterfaceClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter frontendName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontendName}", url.PathEscape(frontendName)) - 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 } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client_example_test.go index 5d2d83da2dda..900f12a83873 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client_example_test.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/frontendsinterface_client_example_test.go @@ -5,6 +5,7 @@ // 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 armservicenetworking_test @@ -17,61 +18,94 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendsGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendsGet.json func ExampleFrontendsInterfaceClient_NewListByTrafficControllerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewFrontendsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByTrafficControllerPager("rg1", "TC1", nil) + pager := clientFactory.NewFrontendsInterfaceClient().NewListByTrafficControllerPager("rg1", "TC1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.FrontendListResult = armservicenetworking.FrontendListResult{ + // Value: []*armservicenetworking.Frontend{ + // { + // Name: to.Ptr("publicIp1"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), + // ID: to.Ptr("resourceUriAsString"), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.FrontendProperties{ + // IPAddressVersion: to.Ptr(armservicenetworking.FrontendIPAddressVersionIPv4), + // Mode: to.Ptr("public"), + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // PublicIPAddress: &armservicenetworking.FrontendPropertiesIPAddress{ + // ID: to.Ptr("resourceUriAsString"), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendGet.json func ExampleFrontendsInterfaceClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewFrontendsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "TC1", "publicIp1", nil) + res, err := clientFactory.NewFrontendsInterfaceClient().Get(ctx, "rg1", "TC1", "publicIp1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.Frontend = armservicenetworking.Frontend{ + // Name: to.Ptr("publicIp1"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), + // ID: to.Ptr("resourceUriAsString"), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.FrontendProperties{ + // IPAddressVersion: to.Ptr(armservicenetworking.FrontendIPAddressVersionIPv4), + // Mode: to.Ptr("public"), + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // PublicIPAddress: &armservicenetworking.FrontendPropertiesIPAddress{ + // ID: to.Ptr("resourceUriAsString"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendPut.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendPut.json func ExampleFrontendsInterfaceClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewFrontendsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "TC1", "publicIp1", armservicenetworking.Frontend{ + poller, err := clientFactory.NewFrontendsInterfaceClient().BeginCreateOrUpdate(ctx, "rg1", "TC1", "publicIp1", armservicenetworking.Frontend{ Location: to.Ptr("West US"), Properties: &armservicenetworking.FrontendProperties{ IPAddressVersion: to.Ptr(armservicenetworking.FrontendIPAddressVersionIPv4), @@ -88,22 +122,37 @@ func ExampleFrontendsInterfaceClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.Frontend = armservicenetworking.Frontend{ + // Name: to.Ptr("publicIp1"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), + // ID: to.Ptr("resourceUriAsString"), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.FrontendProperties{ + // IPAddressVersion: to.Ptr(armservicenetworking.FrontendIPAddressVersionIPv4), + // Mode: to.Ptr("public"), + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // PublicIPAddress: &armservicenetworking.FrontendPropertiesIPAddress{ + // ID: to.Ptr("resourceUriAsString"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendPatch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendPatch.json func ExampleFrontendsInterfaceClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewFrontendsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "rg1", "TC1", "publicIp1", armservicenetworking.FrontendUpdate{ + res, err := clientFactory.NewFrontendsInterfaceClient().Update(ctx, "rg1", "TC1", "publicIp1", armservicenetworking.FrontendUpdate{ Properties: &armservicenetworking.FrontendUpdateProperties{ IPAddressVersion: to.Ptr(armservicenetworking.FrontendIPAddressVersionIPv4), Mode: to.Ptr("public"), @@ -115,22 +164,37 @@ func ExampleFrontendsInterfaceClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.Frontend = armservicenetworking.Frontend{ + // Name: to.Ptr("publicIp1"), + // Type: to.Ptr("Microsoft.ServiceNetworking/trafficControllers/frontends"), + // ID: to.Ptr("resourceUriAsString"), + // Location: to.Ptr("West US"), + // Properties: &armservicenetworking.FrontendProperties{ + // IPAddressVersion: to.Ptr(armservicenetworking.FrontendIPAddressVersionIPv4), + // Mode: to.Ptr("public"), + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // PublicIPAddress: &armservicenetworking.FrontendPropertiesIPAddress{ + // ID: to.Ptr("resourceUriAsString"), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/FrontendDelete.json func ExampleFrontendsInterfaceClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewFrontendsInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "TC1", "publicIp1", nil) + poller, err := clientFactory.NewFrontendsInterfaceClient().BeginDelete(ctx, "rg1", "TC1", "publicIp1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod index 2480ae3075f9..7e086ffa5b1b 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/a 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.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // 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/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum index 8c0539b73123..8ba445a8c4da 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/go.sum @@ -1,30 +1,31 @@ -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.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -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.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +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/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +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/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go index 5d362543188b..48074a20c7e6 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/models.go @@ -100,7 +100,7 @@ type AssociationsInterfaceClientGetOptions struct { // placeholder for future optional parameters } -// AssociationsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the AssociationsInterfaceClient.ListByTrafficController +// AssociationsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the AssociationsInterfaceClient.NewListByTrafficControllerPager // method. type AssociationsInterfaceClientListByTrafficControllerOptions struct { // placeholder for future optional parameters @@ -205,7 +205,7 @@ type FrontendsInterfaceClientGetOptions struct { // placeholder for future optional parameters } -// FrontendsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the FrontendsInterfaceClient.ListByTrafficController +// FrontendsInterfaceClientListByTrafficControllerOptions contains the optional parameters for the FrontendsInterfaceClient.NewListByTrafficControllerPager // method. type FrontendsInterfaceClientListByTrafficControllerOptions struct { // placeholder for future optional parameters @@ -265,7 +265,7 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -341,13 +341,13 @@ type TrafficControllerInterfaceClientGetOptions struct { // placeholder for future optional parameters } -// TrafficControllerInterfaceClientListByResourceGroupOptions contains the optional parameters for the TrafficControllerInterfaceClient.ListByResourceGroup +// TrafficControllerInterfaceClientListByResourceGroupOptions contains the optional parameters for the TrafficControllerInterfaceClient.NewListByResourceGroupPager // method. type TrafficControllerInterfaceClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// TrafficControllerInterfaceClientListBySubscriptionOptions contains the optional parameters for the TrafficControllerInterfaceClient.ListBySubscription +// TrafficControllerInterfaceClientListBySubscriptionOptions contains the optional parameters for the TrafficControllerInterfaceClient.NewListBySubscriptionPager // method. type TrafficControllerInterfaceClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -386,7 +386,7 @@ type TrafficControllerProperties struct { // TrafficControllerUpdate - The type used for update operations of the TrafficController. type TrafficControllerUpdate struct { // The updatable properties of the TrafficController. - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` // Resource tags. Tags map[string]*string `json:"tags,omitempty"` diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go index c72289d4ef45..9e56552725a8 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type Association. func (a Association) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) populate(objectMap, "name", a.Name) @@ -69,7 +69,7 @@ func (a *Association) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssociationListResult. func (a AssociationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -100,7 +100,7 @@ func (a *AssociationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssociationProperties. func (a AssociationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["associationType"] = "subnets" populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "subnet", a.Subnet) @@ -135,7 +135,7 @@ func (a *AssociationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssociationSubnet. func (a AssociationSubnet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) return json.Marshal(objectMap) } @@ -162,7 +162,7 @@ func (a *AssociationSubnet) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssociationUpdate. func (a AssociationUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", a.Properties) populate(objectMap, "tags", a.Tags) return json.Marshal(objectMap) @@ -193,7 +193,7 @@ func (a *AssociationUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssociationUpdateProperties. func (a AssociationUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["associationType"] = "subnets" populate(objectMap, "subnet", a.Subnet) return json.Marshal(objectMap) @@ -224,7 +224,7 @@ func (a *AssociationUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Frontend. func (f Frontend) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", f.ID) populate(objectMap, "location", f.Location) populate(objectMap, "name", f.Name) @@ -275,7 +275,7 @@ func (f *Frontend) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FrontendListResult. func (f FrontendListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", f.NextLink) populate(objectMap, "value", f.Value) return json.Marshal(objectMap) @@ -306,7 +306,7 @@ func (f *FrontendListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FrontendProperties. func (f FrontendProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ipAddressVersion", f.IPAddressVersion) objectMap["mode"] = "public" populate(objectMap, "provisioningState", f.ProvisioningState) @@ -345,7 +345,7 @@ func (f *FrontendProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FrontendPropertiesIPAddress. func (f FrontendPropertiesIPAddress) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", f.ID) return json.Marshal(objectMap) } @@ -372,7 +372,7 @@ func (f *FrontendPropertiesIPAddress) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FrontendUpdate. func (f FrontendUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", f.Properties) populate(objectMap, "tags", f.Tags) return json.Marshal(objectMap) @@ -403,7 +403,7 @@ func (f *FrontendUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FrontendUpdateProperties. func (f FrontendUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ipAddressVersion", f.IPAddressVersion) objectMap["mode"] = "public" populate(objectMap, "publicIPAddress", f.PublicIPAddress) @@ -438,7 +438,7 @@ func (f *FrontendUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) @@ -481,7 +481,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -520,7 +520,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -551,7 +551,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceID. func (r ResourceID) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) return json.Marshal(objectMap) } @@ -578,7 +578,7 @@ func (r *ResourceID) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -625,7 +625,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficController. func (t TrafficController) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -676,7 +676,7 @@ func (t *TrafficController) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficControllerListResult. func (t TrafficControllerListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", t.NextLink) populate(objectMap, "value", t.Value) return json.Marshal(objectMap) @@ -707,7 +707,7 @@ func (t *TrafficControllerListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficControllerProperties. func (t TrafficControllerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "associations", t.Associations) populate(objectMap, "configurationEndpoints", t.ConfigurationEndpoints) populate(objectMap, "frontends", t.Frontends) @@ -746,7 +746,7 @@ func (t *TrafficControllerProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficControllerUpdate. func (t TrafficControllerUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", &t.Properties) populate(objectMap, "tags", t.Tags) return json.Marshal(objectMap) @@ -775,7 +775,7 @@ func (t *TrafficControllerUpdate) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -785,7 +785,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client.go index 4ad7738d1841..10a56538dcd2 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/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,35 +21,27 @@ 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. +// - 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 } // NewListPager - List the operations for the provider +// // Generated from API version 2022-10-01-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,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 } @@ -83,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.ServiceNetworking/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/servicenetworking/armservicenetworking/operations_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client_example_test.go index e3ab351a1e36..c19c0c5f77f1 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client_example_test.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/operations_client_example_test.go @@ -5,6 +5,7 @@ // 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 armservicenetworking_test @@ -16,26 +17,41 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/OperationsList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/OperationsList.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 := armservicenetworking.NewOperationsClient(cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.OperationListResult = armservicenetworking.OperationListResult{ + // Value: []*armservicenetworking.Operation{ + // { + // Name: to.Ptr("Microsoft.ServiceNetworking/trafficController/read"), + // Display: &armservicenetworking.OperationDisplay{ + // Description: to.Ptr("Traffic Controller is a L7 Load Balancing solution for a Multi Cluster setup"), + // Operation: to.Ptr("Get Traffic Controller configuration"), + // Provider: to.Ptr("Microsoft Service Networking"), + // Resource: to.Ptr("Traffic Controller"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armservicenetworking.OriginUserSystem), + // }}, + // } } } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/response_types.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/response_types.go index 4735d11570c2..3e6bf4aa4c33 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/response_types.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/response_types.go @@ -9,12 +9,12 @@ package armservicenetworking -// AssociationsInterfaceClientCreateOrUpdateResponse contains the response from method AssociationsInterfaceClient.CreateOrUpdate. +// AssociationsInterfaceClientCreateOrUpdateResponse contains the response from method AssociationsInterfaceClient.BeginCreateOrUpdate. type AssociationsInterfaceClientCreateOrUpdateResponse struct { Association } -// AssociationsInterfaceClientDeleteResponse contains the response from method AssociationsInterfaceClient.Delete. +// AssociationsInterfaceClientDeleteResponse contains the response from method AssociationsInterfaceClient.BeginDelete. type AssociationsInterfaceClientDeleteResponse struct { // placeholder for future response values } @@ -24,7 +24,7 @@ type AssociationsInterfaceClientGetResponse struct { Association } -// AssociationsInterfaceClientListByTrafficControllerResponse contains the response from method AssociationsInterfaceClient.ListByTrafficController. +// AssociationsInterfaceClientListByTrafficControllerResponse contains the response from method AssociationsInterfaceClient.NewListByTrafficControllerPager. type AssociationsInterfaceClientListByTrafficControllerResponse struct { AssociationListResult } @@ -34,12 +34,12 @@ type AssociationsInterfaceClientUpdateResponse struct { Association } -// FrontendsInterfaceClientCreateOrUpdateResponse contains the response from method FrontendsInterfaceClient.CreateOrUpdate. +// FrontendsInterfaceClientCreateOrUpdateResponse contains the response from method FrontendsInterfaceClient.BeginCreateOrUpdate. type FrontendsInterfaceClientCreateOrUpdateResponse struct { Frontend } -// FrontendsInterfaceClientDeleteResponse contains the response from method FrontendsInterfaceClient.Delete. +// FrontendsInterfaceClientDeleteResponse contains the response from method FrontendsInterfaceClient.BeginDelete. type FrontendsInterfaceClientDeleteResponse struct { // placeholder for future response values } @@ -49,7 +49,7 @@ type FrontendsInterfaceClientGetResponse struct { Frontend } -// FrontendsInterfaceClientListByTrafficControllerResponse contains the response from method FrontendsInterfaceClient.ListByTrafficController. +// FrontendsInterfaceClientListByTrafficControllerResponse contains the response from method FrontendsInterfaceClient.NewListByTrafficControllerPager. type FrontendsInterfaceClientListByTrafficControllerResponse struct { FrontendListResult } @@ -59,17 +59,17 @@ type FrontendsInterfaceClientUpdateResponse struct { Frontend } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// TrafficControllerInterfaceClientCreateOrUpdateResponse contains the response from method TrafficControllerInterfaceClient.CreateOrUpdate. +// TrafficControllerInterfaceClientCreateOrUpdateResponse contains the response from method TrafficControllerInterfaceClient.BeginCreateOrUpdate. type TrafficControllerInterfaceClientCreateOrUpdateResponse struct { TrafficController } -// TrafficControllerInterfaceClientDeleteResponse contains the response from method TrafficControllerInterfaceClient.Delete. +// TrafficControllerInterfaceClientDeleteResponse contains the response from method TrafficControllerInterfaceClient.BeginDelete. type TrafficControllerInterfaceClientDeleteResponse struct { // placeholder for future response values } @@ -79,12 +79,12 @@ type TrafficControllerInterfaceClientGetResponse struct { TrafficController } -// TrafficControllerInterfaceClientListByResourceGroupResponse contains the response from method TrafficControllerInterfaceClient.ListByResourceGroup. +// TrafficControllerInterfaceClientListByResourceGroupResponse contains the response from method TrafficControllerInterfaceClient.NewListByResourceGroupPager. type TrafficControllerInterfaceClientListByResourceGroupResponse struct { TrafficControllerListResult } -// TrafficControllerInterfaceClientListBySubscriptionResponse contains the response from method TrafficControllerInterfaceClient.ListBySubscription. +// TrafficControllerInterfaceClientListBySubscriptionResponse contains the response from method TrafficControllerInterfaceClient.NewListBySubscriptionPager. type TrafficControllerInterfaceClientListBySubscriptionResponse struct { TrafficControllerListResult } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go index 4ddcbc792748..446f0e25de9b 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client.go index 92c40c440df8..4cf0480978f9 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_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,66 +24,59 @@ import ( // TrafficControllerInterfaceClient contains the methods for the TrafficControllerInterface group. // Don't use this type directly, use NewTrafficControllerInterfaceClient() instead. type TrafficControllerInterfaceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTrafficControllerInterfaceClient creates a new instance of TrafficControllerInterfaceClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTrafficControllerInterfaceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TrafficControllerInterfaceClient, 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+".TrafficControllerInterfaceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TrafficControllerInterfaceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create a TrafficController // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// resource - Resource create parameters. -// options - TrafficControllerInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the TrafficControllerInterfaceClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - resource - Resource create parameters. +// - options - TrafficControllerInterfaceClientBeginCreateOrUpdateOptions contains the optional parameters for the TrafficControllerInterfaceClient.BeginCreateOrUpdate +// method. func (client *TrafficControllerInterfaceClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, resource TrafficController, options *TrafficControllerInterfaceClientBeginCreateOrUpdateOptions) (*runtime.Poller[TrafficControllerInterfaceClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, trafficControllerName, resource, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TrafficControllerInterfaceClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TrafficControllerInterfaceClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[TrafficControllerInterfaceClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TrafficControllerInterfaceClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create a TrafficController // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview func (client *TrafficControllerInterfaceClient) createOrUpdate(ctx context.Context, resourceGroupName string, trafficControllerName string, resource TrafficController, options *TrafficControllerInterfaceClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, trafficControllerName, resource, options) 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 } @@ -110,7 +101,7 @@ func (client *TrafficControllerInterfaceClient) createOrUpdateCreateRequest(ctx return nil, errors.New("parameter trafficControllerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) - 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 } @@ -123,34 +114,36 @@ func (client *TrafficControllerInterfaceClient) createOrUpdateCreateRequest(ctx // BeginDelete - Delete a TrafficController // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// options - TrafficControllerInterfaceClientBeginDeleteOptions contains the optional parameters for the TrafficControllerInterfaceClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - options - TrafficControllerInterfaceClientBeginDeleteOptions contains the optional parameters for the TrafficControllerInterfaceClient.BeginDelete +// method. func (client *TrafficControllerInterfaceClient) BeginDelete(ctx context.Context, resourceGroupName string, trafficControllerName string, options *TrafficControllerInterfaceClientBeginDeleteOptions) (*runtime.Poller[TrafficControllerInterfaceClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, trafficControllerName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TrafficControllerInterfaceClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TrafficControllerInterfaceClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[TrafficControllerInterfaceClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TrafficControllerInterfaceClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a TrafficController // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview func (client *TrafficControllerInterfaceClient) deleteOperation(ctx context.Context, resourceGroupName string, trafficControllerName string, options *TrafficControllerInterfaceClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, trafficControllerName, options) 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 } @@ -175,7 +168,7 @@ func (client *TrafficControllerInterfaceClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter trafficControllerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) - 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 } @@ -188,17 +181,18 @@ func (client *TrafficControllerInterfaceClient) deleteCreateRequest(ctx context. // Get - Get a TrafficController // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// options - TrafficControllerInterfaceClientGetOptions contains the optional parameters for the TrafficControllerInterfaceClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - options - TrafficControllerInterfaceClientGetOptions contains the optional parameters for the TrafficControllerInterfaceClient.Get +// method. func (client *TrafficControllerInterfaceClient) Get(ctx context.Context, resourceGroupName string, trafficControllerName string, options *TrafficControllerInterfaceClientGetOptions) (TrafficControllerInterfaceClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, trafficControllerName, options) if err != nil { return TrafficControllerInterfaceClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TrafficControllerInterfaceClientGetResponse{}, err } @@ -223,7 +217,7 @@ func (client *TrafficControllerInterfaceClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter trafficControllerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) - 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 } @@ -244,10 +238,11 @@ func (client *TrafficControllerInterfaceClient) getHandleResponse(resp *http.Res } // NewListByResourceGroupPager - List TrafficController resources by resource group +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - TrafficControllerInterfaceClientListByResourceGroupOptions contains the optional parameters for the TrafficControllerInterfaceClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - TrafficControllerInterfaceClientListByResourceGroupOptions contains the optional parameters for the TrafficControllerInterfaceClient.NewListByResourceGroupPager +// method. func (client *TrafficControllerInterfaceClient) NewListByResourceGroupPager(resourceGroupName string, options *TrafficControllerInterfaceClientListByResourceGroupOptions) *runtime.Pager[TrafficControllerInterfaceClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[TrafficControllerInterfaceClientListByResourceGroupResponse]{ More: func(page TrafficControllerInterfaceClientListByResourceGroupResponse) bool { @@ -264,7 +259,7 @@ func (client *TrafficControllerInterfaceClient) NewListByResourceGroupPager(reso if err != nil { return TrafficControllerInterfaceClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TrafficControllerInterfaceClientListByResourceGroupResponse{}, err } @@ -287,7 +282,7 @@ func (client *TrafficControllerInterfaceClient) listByResourceGroupCreateRequest return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - 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 } @@ -308,9 +303,10 @@ func (client *TrafficControllerInterfaceClient) listByResourceGroupHandleRespons } // NewListBySubscriptionPager - List TrafficController resources by subscription ID +// // Generated from API version 2022-10-01-preview -// options - TrafficControllerInterfaceClientListBySubscriptionOptions contains the optional parameters for the TrafficControllerInterfaceClient.ListBySubscription -// method. +// - options - TrafficControllerInterfaceClientListBySubscriptionOptions contains the optional parameters for the TrafficControllerInterfaceClient.NewListBySubscriptionPager +// method. func (client *TrafficControllerInterfaceClient) NewListBySubscriptionPager(options *TrafficControllerInterfaceClientListBySubscriptionOptions) *runtime.Pager[TrafficControllerInterfaceClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[TrafficControllerInterfaceClientListBySubscriptionResponse]{ More: func(page TrafficControllerInterfaceClientListBySubscriptionResponse) bool { @@ -327,7 +323,7 @@ func (client *TrafficControllerInterfaceClient) NewListBySubscriptionPager(optio if err != nil { return TrafficControllerInterfaceClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TrafficControllerInterfaceClientListBySubscriptionResponse{}, err } @@ -346,7 +342,7 @@ func (client *TrafficControllerInterfaceClient) listBySubscriptionCreateRequest( 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 } @@ -368,18 +364,19 @@ func (client *TrafficControllerInterfaceClient) listBySubscriptionHandleResponse // Update - Update a TrafficController // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-10-01-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// trafficControllerName - traffic controller name for path -// properties - The resource properties to be updated. -// options - TrafficControllerInterfaceClientUpdateOptions contains the optional parameters for the TrafficControllerInterfaceClient.Update -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - trafficControllerName - traffic controller name for path +// - properties - The resource properties to be updated. +// - options - TrafficControllerInterfaceClientUpdateOptions contains the optional parameters for the TrafficControllerInterfaceClient.Update +// method. func (client *TrafficControllerInterfaceClient) Update(ctx context.Context, resourceGroupName string, trafficControllerName string, properties TrafficControllerUpdate, options *TrafficControllerInterfaceClientUpdateOptions) (TrafficControllerInterfaceClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, trafficControllerName, properties, options) if err != nil { return TrafficControllerInterfaceClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TrafficControllerInterfaceClientUpdateResponse{}, err } @@ -404,7 +401,7 @@ func (client *TrafficControllerInterfaceClient) updateCreateRequest(ctx context. return nil, errors.New("parameter trafficControllerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{trafficControllerName}", url.PathEscape(trafficControllerName)) - 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 } diff --git a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client_example_test.go b/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client_example_test.go index 368aa4919a22..1902c15edc5b 100644 --- a/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client_example_test.go +++ b/sdk/resourcemanager/servicenetworking/armservicenetworking/trafficcontrollerinterface_client_example_test.go @@ -5,6 +5,7 @@ // 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 armservicenetworking_test @@ -17,85 +18,160 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicenetworking/armservicenetworking" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllersGetList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllersGetList.json func ExampleTrafficControllerInterfaceClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewTrafficControllerInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewTrafficControllerInterfaceClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.TrafficControllerListResult = armservicenetworking.TrafficControllerListResult{ + // Value: []*armservicenetworking.TrafficController{ + // { + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.ServiceNetworking/TrafficController"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficController/tc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Properties: &armservicenetworking.TrafficControllerProperties{ + // Associations: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/association/as1"), + // }}, + // ConfigurationEndpoints: []*string{ + // to.Ptr("abc.westus.trafficcontroller.azure.net")}, + // Frontends: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/frontends/fe1"), + // }}, + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllersGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllersGet.json func ExampleTrafficControllerInterfaceClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewTrafficControllerInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("rg1", nil) + pager := clientFactory.NewTrafficControllerInterfaceClient().NewListByResourceGroupPager("rg1", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.TrafficControllerListResult = armservicenetworking.TrafficControllerListResult{ + // Value: []*armservicenetworking.TrafficController{ + // { + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.ServiceNetworking/TrafficController"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficController/tc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Properties: &armservicenetworking.TrafficControllerProperties{ + // Associations: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/association/as1"), + // }}, + // ConfigurationEndpoints: []*string{ + // to.Ptr("abc.westus.trafficcontroller.azure.net")}, + // Frontends: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/frontends/fe1"), + // }}, + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerGet.json func ExampleTrafficControllerInterfaceClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewTrafficControllerInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rg1", "TC1", nil) + res, err := clientFactory.NewTrafficControllerInterfaceClient().Get(ctx, "rg1", "TC1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.TrafficController = armservicenetworking.TrafficController{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.ServiceNetworking/TrafficController"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficController/tc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Properties: &armservicenetworking.TrafficControllerProperties{ + // Associations: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/association/as1"), + // }}, + // ConfigurationEndpoints: []*string{ + // to.Ptr("abc.westus.trafficcontroller.azure.net")}, + // Frontends: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/frontends/fe1"), + // }}, + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerPut.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerPut.json func ExampleTrafficControllerInterfaceClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewTrafficControllerInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "rg1", "TC1", armservicenetworking.TrafficController{ + poller, err := clientFactory.NewTrafficControllerInterfaceClient().BeginCreateOrUpdate(ctx, "rg1", "TC1", armservicenetworking.TrafficController{ Location: to.Ptr("West US"), Tags: map[string]*string{ "key1": to.Ptr("value1"), @@ -108,24 +184,47 @@ func ExampleTrafficControllerInterfaceClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.TrafficController = armservicenetworking.TrafficController{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.ServiceNetworking/TrafficController"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficController/tc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Properties: &armservicenetworking.TrafficControllerProperties{ + // Associations: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/association/as1"), + // }}, + // ConfigurationEndpoints: []*string{ + // to.Ptr("abc.westus.trafficcontroller.azure.net")}, + // Frontends: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/frontends/fe1"), + // }}, + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerPatch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerPatch.json func ExampleTrafficControllerInterfaceClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewTrafficControllerInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "rg1", "TC1", armservicenetworking.TrafficControllerUpdate{ - Properties: map[string]interface{}{ - "configurationEndpoints": []interface{}{ + res, err := clientFactory.NewTrafficControllerInterfaceClient().Update(ctx, "rg1", "TC1", armservicenetworking.TrafficControllerUpdate{ + Properties: map[string]any{ + "configurationEndpoints": []any{ "abc.eastus.trafficcontroller.azure.net", }, }, @@ -133,22 +232,45 @@ func ExampleTrafficControllerInterfaceClient_Update() { if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.TrafficController = armservicenetworking.TrafficController{ + // Name: to.Ptr("atc"), + // Type: to.Ptr("Microsoft.ServiceNetworking/TrafficController"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ServiceNetworking/trafficController/tc"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // Properties: &armservicenetworking.TrafficControllerProperties{ + // Associations: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/association/as1"), + // }}, + // ConfigurationEndpoints: []*string{ + // to.Ptr("abc.westus.trafficcontroller.azure.net")}, + // Frontends: []*armservicenetworking.ResourceID{ + // { + // ID: to.Ptr("/sub1/rg2/tc/tcame/frontends/fe1"), + // }}, + // ProvisioningState: to.Ptr(armservicenetworking.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/71121282e39bccae590462648e77bca283df6d2b/specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/cadl/examples/TrafficControllerDelete.json func ExampleTrafficControllerInterfaceClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armservicenetworking.NewTrafficControllerInterfaceClient("subid", cred, nil) + clientFactory, err := armservicenetworking.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rg1", "TC1", nil) + poller, err := clientFactory.NewTrafficControllerInterfaceClient().BeginDelete(ctx, "rg1", "TC1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/support/armsupport/CHANGELOG.md b/sdk/resourcemanager/support/armsupport/CHANGELOG.md index e5155dc8bd09..0ac002c77395 100644 --- a/sdk/resourcemanager/support/armsupport/CHANGELOG.md +++ b/sdk/resourcemanager/support/armsupport/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/support/armsupport/README.md b/sdk/resourcemanager/support/armsupport/README.md index ebab40ff5176..e009cd7fc234 100644 --- a/sdk/resourcemanager/support/armsupport/README.md +++ b/sdk/resourcemanager/support/armsupport/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Support modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Support module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armsupport.NewCommunicationsClient(, cred, nil) +clientFactory, err := armsupport.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armsupport.NewCommunicationsClient(, cred, &options) +clientFactory, err := armsupport.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewServicesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/support/armsupport/autorest.md b/sdk/resourcemanager/support/armsupport/autorest.md index 4f003a9f4dcf..4c1e19f84507 100644 --- a/sdk/resourcemanager/support/armsupport/autorest.md +++ b/sdk/resourcemanager/support/armsupport/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/support/armsupport/client_factory.go b/sdk/resourcemanager/support/armsupport/client_factory.go new file mode 100644 index 000000000000..e101d91ffc70 --- /dev/null +++ b/sdk/resourcemanager/support/armsupport/client_factory.go @@ -0,0 +1,64 @@ +//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 armsupport + +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 - Azure subscription Id. +// - 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) NewServicesClient() *ServicesClient { + subClient, _ := NewServicesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewProblemClassificationsClient() *ProblemClassificationsClient { + subClient, _ := NewProblemClassificationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTicketsClient() *TicketsClient { + subClient, _ := NewTicketsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCommunicationsClient() *CommunicationsClient { + subClient, _ := NewCommunicationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_communications_client.go b/sdk/resourcemanager/support/armsupport/communications_client.go similarity index 85% rename from sdk/resourcemanager/support/armsupport/zz_generated_communications_client.go rename to sdk/resourcemanager/support/armsupport/communications_client.go index 61409eed6864..77c8e8a43193 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_communications_client.go +++ b/sdk/resourcemanager/support/armsupport/communications_client.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -13,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,31 +25,22 @@ import ( // CommunicationsClient contains the methods for the Communications group. // Don't use this type directly, use NewCommunicationsClient() instead. type CommunicationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCommunicationsClient creates a new instance of CommunicationsClient with the specified values. -// subscriptionID - Azure subscription Id. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription Id. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCommunicationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CommunicationsClient, 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+".CommunicationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CommunicationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,17 +48,18 @@ func NewCommunicationsClient(subscriptionID string, credential azcore.TokenCrede // CheckNameAvailability - Check the availability of a resource name. This API should be used to check the uniqueness of the // name for adding a new communication to the support ticket. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// supportTicketName - Support ticket name. -// checkNameAvailabilityInput - Input to check. -// options - CommunicationsClientCheckNameAvailabilityOptions contains the optional parameters for the CommunicationsClient.CheckNameAvailability -// method. +// - supportTicketName - Support ticket name. +// - checkNameAvailabilityInput - Input to check. +// - options - CommunicationsClientCheckNameAvailabilityOptions contains the optional parameters for the CommunicationsClient.CheckNameAvailability +// method. func (client *CommunicationsClient) CheckNameAvailability(ctx context.Context, supportTicketName string, checkNameAvailabilityInput CheckNameAvailabilityInput, options *CommunicationsClientCheckNameAvailabilityOptions) (CommunicationsClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, supportTicketName, checkNameAvailabilityInput, options) if err != nil { return CommunicationsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommunicationsClientCheckNameAvailabilityResponse{}, err } @@ -89,7 +80,7 @@ func (client *CommunicationsClient) checkNameAvailabilityCreateRequest(ctx conte 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 } @@ -111,35 +102,37 @@ func (client *CommunicationsClient) checkNameAvailabilityHandleResponse(resp *ht // BeginCreate - Adds a new customer communication to an Azure support ticket. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// supportTicketName - Support ticket name. -// communicationName - Communication name. -// createCommunicationParameters - Communication object. -// options - CommunicationsClientBeginCreateOptions contains the optional parameters for the CommunicationsClient.BeginCreate -// method. +// - supportTicketName - Support ticket name. +// - communicationName - Communication name. +// - createCommunicationParameters - Communication object. +// - options - CommunicationsClientBeginCreateOptions contains the optional parameters for the CommunicationsClient.BeginCreate +// method. func (client *CommunicationsClient) BeginCreate(ctx context.Context, supportTicketName string, communicationName string, createCommunicationParameters CommunicationDetails, options *CommunicationsClientBeginCreateOptions) (*runtime.Poller[CommunicationsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, supportTicketName, communicationName, createCommunicationParameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommunicationsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunicationsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CommunicationsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CommunicationsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Adds a new customer communication to an Azure support ticket. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 func (client *CommunicationsClient) create(ctx context.Context, supportTicketName string, communicationName string, createCommunicationParameters CommunicationDetails, options *CommunicationsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, supportTicketName, communicationName, createCommunicationParameters, options) 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 } @@ -164,7 +157,7 @@ func (client *CommunicationsClient) createCreateRequest(ctx context.Context, sup 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.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 } @@ -177,16 +170,17 @@ func (client *CommunicationsClient) createCreateRequest(ctx context.Context, sup // Get - Returns communication details for a support ticket. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// supportTicketName - Support ticket name. -// communicationName - Communication name. -// options - CommunicationsClientGetOptions contains the optional parameters for the CommunicationsClient.Get method. +// - supportTicketName - Support ticket name. +// - communicationName - Communication name. +// - options - CommunicationsClientGetOptions contains the optional parameters for the CommunicationsClient.Get method. func (client *CommunicationsClient) Get(ctx context.Context, supportTicketName string, communicationName string, options *CommunicationsClientGetOptions) (CommunicationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, supportTicketName, communicationName, options) if err != nil { return CommunicationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommunicationsClientGetResponse{}, err } @@ -211,7 +205,7 @@ func (client *CommunicationsClient) getCreateRequest(ctx context.Context, suppor 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 } @@ -237,10 +231,10 @@ func (client *CommunicationsClient) getHandleResponse(resp *http.Response) (Comm // with nextLink, using which you can retrieve the next set of Communication results. // Support ticket data is available for 18 months after ticket creation. If a ticket was created more than 18 months ago, // a request for data might cause an error. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// supportTicketName - Support ticket name. -// options - CommunicationsClientListOptions contains the optional parameters for the CommunicationsClient.List method. +// - supportTicketName - Support ticket name. +// - options - CommunicationsClientListOptions contains the optional parameters for the CommunicationsClient.NewListPager method. func (client *CommunicationsClient) NewListPager(supportTicketName string, options *CommunicationsClientListOptions) *runtime.Pager[CommunicationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CommunicationsClientListResponse]{ More: func(page CommunicationsClientListResponse) bool { @@ -257,7 +251,7 @@ func (client *CommunicationsClient) NewListPager(supportTicketName string, optio if err != nil { return CommunicationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CommunicationsClientListResponse{}, err } @@ -280,7 +274,7 @@ func (client *CommunicationsClient) listCreateRequest(ctx context.Context, suppo 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/support/armsupport/communications_client_example_test.go b/sdk/resourcemanager/support/armsupport/communications_client_example_test.go new file mode 100644 index 000000000000..cbcb1ac13893 --- /dev/null +++ b/sdk/resourcemanager/support/armsupport/communications_client_example_test.go @@ -0,0 +1,291 @@ +//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 armsupport_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/support/armsupport" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CheckNameAvailabilityForSupportTicketCommunication.json +func ExampleCommunicationsClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCommunicationsClient().CheckNameAvailability(ctx, "testticket", armsupport.CheckNameAvailabilityInput{ + Name: to.Ptr("sampleName"), + Type: to.Ptr(armsupport.TypeMicrosoftSupportCommunications), + }, 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.CheckNameAvailabilityOutput = armsupport.CheckNameAvailabilityOutput{ + // Message: to.Ptr("Name not available"), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr("Name is already in use"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListCommunicationsForSubscriptionSupportTicket.json +func ExampleCommunicationsClient_NewListPager_listCommunicationsForASubscriptionSupportTicket() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunicationsClient().NewListPager("testticket", &armsupport.CommunicationsClientListOptions{Top: nil, + Filter: 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.CommunicationsListResult = armsupport.CommunicationsListResult{ + // Value: []*armsupport.CommunicationDetails{ + // { + // Name: to.Ptr("testmessage1"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testmessage1"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("this is a test message"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-24T20:18:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("this is a test message"), + // }, + // }, + // { + // Name: to.Ptr("testmessage2"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testmessage2"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("test"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-29T10:53:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("test"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListWebCommunicationsForSubscriptionSupportTicketCreatedOnOrAfter.json +func ExampleCommunicationsClient_NewListPager_listWebCommunicationCreatedOnOrAfterASpecificDateForASubscriptionSupportTicket() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunicationsClient().NewListPager("testticket", &armsupport.CommunicationsClientListOptions{Top: nil, + Filter: to.Ptr("communicationType eq 'web' and createdDate ge 2020-03-10T22:08:51Z"), + }) + 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.CommunicationsListResult = armsupport.CommunicationsListResult{ + // Value: []*armsupport.CommunicationDetails{ + // { + // Name: to.Ptr("testmessage1"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testmessage1"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("this is a test message"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-11T20:18:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("this is a test message"), + // }, + // }, + // { + // Name: to.Ptr("testmessage2"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testmessage2"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("test"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-12T10:53:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("test"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListWebCommunicationsForSubscriptionSupportTicket.json +func ExampleCommunicationsClient_NewListPager_listWebCommunicationsForASubscriptionSupportTicket() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunicationsClient().NewListPager("testticket", &armsupport.CommunicationsClientListOptions{Top: nil, + Filter: to.Ptr("communicationType eq 'web'"), + }) + 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.CommunicationsListResult = armsupport.CommunicationsListResult{ + // Value: []*armsupport.CommunicationDetails{ + // { + // Name: to.Ptr("testmessage1"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testmessage1"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("this is a test message"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-10T20:18:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("this is a test message"), + // }, + // }, + // { + // Name: to.Ptr("testmessage2"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testmessage2"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("test"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-11T10:53:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("test"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetCommunicationDetailsForSubscriptionSupportTicket.json +func ExampleCommunicationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCommunicationsClient().Get(ctx, "testticket", "testmessage", 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.CommunicationDetails = armsupport.CommunicationDetails{ + // Name: to.Ptr("testmessage"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testmessage"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("this is a test message"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-10T20:18:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("this is a test message"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSupportTicketCommunication.json +func ExampleCommunicationsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunicationsClient().BeginCreate(ctx, "testticket", "testcommunication", armsupport.CommunicationDetails{ + Properties: &armsupport.CommunicationDetailsProperties{ + Body: to.Ptr("This is a test message from a customer!"), + Sender: to.Ptr("user@contoso.com"), + Subject: to.Ptr("This is a test message from a customer!"), + }, + }, 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.CommunicationDetails = armsupport.CommunicationDetails{ + // Name: to.Ptr("testcommunication"), + // Type: to.Ptr("Microsoft.Support/communications"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket/communications/testcommunication"), + // Properties: &armsupport.CommunicationDetailsProperties{ + // Body: to.Ptr("This is a test message from a customer!"), + // CommunicationDirection: to.Ptr(armsupport.CommunicationDirectionOutbound), + // CommunicationType: to.Ptr(armsupport.CommunicationTypeWeb), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-10T20:18:19Z"); return t}()), + // Sender: to.Ptr("user@contoso.com"), + // Subject: to.Ptr("This is a test message from a customer!"), + // }, + // } +} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_constants.go b/sdk/resourcemanager/support/armsupport/constants.go similarity index 98% rename from sdk/resourcemanager/support/armsupport/zz_generated_constants.go rename to sdk/resourcemanager/support/armsupport/constants.go index 9ee2920fb080..5b8e264d2898 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_constants.go +++ b/sdk/resourcemanager/support/armsupport/constants.go @@ -5,12 +5,13 @@ // 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 armsupport const ( moduleName = "armsupport" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CommunicationDirection - Direction of communication. diff --git a/sdk/resourcemanager/support/armsupport/go.mod b/sdk/resourcemanager/support/armsupport/go.mod index c083a4f9a02a..cda731fe93bb 100644 --- a/sdk/resourcemanager/support/armsupport/go.mod +++ b/sdk/resourcemanager/support/armsupport/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport 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.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // 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/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/support/armsupport/go.sum b/sdk/resourcemanager/support/armsupport/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/support/armsupport/go.sum +++ b/sdk/resourcemanager/support/armsupport/go.sum @@ -1,33 +1,31 @@ -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.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -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.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +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/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= 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 v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -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/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +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/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_models.go b/sdk/resourcemanager/support/armsupport/models.go similarity index 98% rename from sdk/resourcemanager/support/armsupport/zz_generated_models.go rename to sdk/resourcemanager/support/armsupport/models.go index 62277ab70d69..e89145f6e372 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_models.go +++ b/sdk/resourcemanager/support/armsupport/models.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -84,7 +85,7 @@ type CommunicationsClientGetOptions struct { // placeholder for future optional parameters } -// CommunicationsClientListOptions contains the optional parameters for the CommunicationsClient.List method. +// CommunicationsClientListOptions contains the optional parameters for the CommunicationsClient.NewListPager method. type CommunicationsClientListOptions struct { // The filter to apply on the operation. You can filter by communicationType and createdDate properties. CommunicationType // supports Equals ('eq') operator and createdDate supports Greater Than ('gt') and @@ -175,7 +176,7 @@ type OperationDisplay struct { Resource *string `json:"resource,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -212,7 +213,8 @@ type ProblemClassificationsClientGetOptions struct { // placeholder for future optional parameters } -// ProblemClassificationsClientListOptions contains the optional parameters for the ProblemClassificationsClient.List method. +// ProblemClassificationsClientListOptions contains the optional parameters for the ProblemClassificationsClient.NewListPager +// method. type ProblemClassificationsClientListOptions struct { // placeholder for future optional parameters } @@ -314,7 +316,7 @@ type ServicesClientGetOptions struct { // placeholder for future optional parameters } -// ServicesClientListOptions contains the optional parameters for the ServicesClient.List method. +// ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. type ServicesClientListOptions struct { // placeholder for future optional parameters } @@ -431,7 +433,7 @@ type TicketsClientGetOptions struct { // placeholder for future optional parameters } -// TicketsClientListOptions contains the optional parameters for the TicketsClient.List method. +// TicketsClientListOptions contains the optional parameters for the TicketsClient.NewListPager method. type TicketsClientListOptions struct { // The filter to apply on the operation. We support 'odata v4.0' filter semantics. Learn more [https://docs.microsoft.com/odata/concepts/queryoptions-overview]. // Status filter can only be used with Equals diff --git a/sdk/resourcemanager/support/armsupport/models_serde.go b/sdk/resourcemanager/support/armsupport/models_serde.go new file mode 100644 index 000000000000..a0051fd36ad2 --- /dev/null +++ b/sdk/resourcemanager/support/armsupport/models_serde.go @@ -0,0 +1,1089 @@ +//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 armsupport + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityInput. +func (c CheckNameAvailabilityInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityInput. +func (c *CheckNameAvailabilityInput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityOutput. +func (c CheckNameAvailabilityOutput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityOutput. +func (c *CheckNameAvailabilityOutput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationDetails. +func (c CommunicationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationDetails. +func (c *CommunicationDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationDetailsProperties. +func (c CommunicationDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "body", c.Body) + populate(objectMap, "communicationDirection", c.CommunicationDirection) + populate(objectMap, "communicationType", c.CommunicationType) + populateTimeRFC3339(objectMap, "createdDate", c.CreatedDate) + populate(objectMap, "sender", c.Sender) + populate(objectMap, "subject", c.Subject) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationDetailsProperties. +func (c *CommunicationDetailsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "body": + err = unpopulate(val, "Body", &c.Body) + delete(rawMsg, key) + case "communicationDirection": + err = unpopulate(val, "CommunicationDirection", &c.CommunicationDirection) + delete(rawMsg, key) + case "communicationType": + err = unpopulate(val, "CommunicationType", &c.CommunicationType) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &c.CreatedDate) + delete(rawMsg, key) + case "sender": + err = unpopulate(val, "Sender", &c.Sender) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, "Subject", &c.Subject) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationsListResult. +func (c CommunicationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationsListResult. +func (c *CommunicationsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContactProfile. +func (c ContactProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalEmailAddresses", c.AdditionalEmailAddresses) + populate(objectMap, "country", c.Country) + populate(objectMap, "firstName", c.FirstName) + populate(objectMap, "lastName", c.LastName) + populate(objectMap, "phoneNumber", c.PhoneNumber) + populate(objectMap, "preferredContactMethod", c.PreferredContactMethod) + populate(objectMap, "preferredSupportLanguage", c.PreferredSupportLanguage) + populate(objectMap, "preferredTimeZone", c.PreferredTimeZone) + populate(objectMap, "primaryEmailAddress", c.PrimaryEmailAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactProfile. +func (c *ContactProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalEmailAddresses": + err = unpopulate(val, "AdditionalEmailAddresses", &c.AdditionalEmailAddresses) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &c.Country) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &c.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &c.LastName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &c.PhoneNumber) + delete(rawMsg, key) + case "preferredContactMethod": + err = unpopulate(val, "PreferredContactMethod", &c.PreferredContactMethod) + delete(rawMsg, key) + case "preferredSupportLanguage": + err = unpopulate(val, "PreferredSupportLanguage", &c.PreferredSupportLanguage) + delete(rawMsg, key) + case "preferredTimeZone": + err = unpopulate(val, "PreferredTimeZone", &c.PreferredTimeZone) + delete(rawMsg, key) + case "primaryEmailAddress": + err = unpopulate(val, "PrimaryEmailAddress", &c.PrimaryEmailAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Engineer. +func (e Engineer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "emailAddress", e.EmailAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Engineer. +func (e *Engineer) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "emailAddress": + err = unpopulate(val, "EmailAddress", &e.EmailAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExceptionResponse. +func (e ExceptionResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExceptionResponse. +func (e *ExceptionResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationsListResult. +func (o OperationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationsListResult. +func (o *OperationsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProblemClassification. +func (p ProblemClassification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProblemClassification. +func (p *ProblemClassification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProblemClassificationProperties. +func (p ProblemClassificationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", p.DisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProblemClassificationProperties. +func (p *ProblemClassificationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProblemClassificationsListResult. +func (p ProblemClassificationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProblemClassificationsListResult. +func (p *ProblemClassificationsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaChangeRequest. +func (q QuotaChangeRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "payload", q.Payload) + populate(objectMap, "region", q.Region) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaChangeRequest. +func (q *QuotaChangeRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "payload": + err = unpopulate(val, "Payload", &q.Payload) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &q.Region) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaTicketDetails. +func (q QuotaTicketDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "quotaChangeRequestSubType", q.QuotaChangeRequestSubType) + populate(objectMap, "quotaChangeRequestVersion", q.QuotaChangeRequestVersion) + populate(objectMap, "quotaChangeRequests", q.QuotaChangeRequests) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaTicketDetails. +func (q *QuotaTicketDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "quotaChangeRequestSubType": + err = unpopulate(val, "QuotaChangeRequestSubType", &q.QuotaChangeRequestSubType) + delete(rawMsg, key) + case "quotaChangeRequestVersion": + err = unpopulate(val, "QuotaChangeRequestVersion", &q.QuotaChangeRequestVersion) + delete(rawMsg, key) + case "quotaChangeRequests": + err = unpopulate(val, "QuotaChangeRequests", &q.QuotaChangeRequests) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Service. +func (s Service) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Service. +func (s *Service) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceError. +func (s ServiceError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", s.Code) + populate(objectMap, "details", s.Details) + populate(objectMap, "message", s.Message) + populate(objectMap, "target", s.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceError. +func (s *ServiceError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &s.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &s.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &s.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &s.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceErrorDetail. +func (s ServiceErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", s.Code) + populate(objectMap, "message", s.Message) + populate(objectMap, "target", s.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceErrorDetail. +func (s *ServiceErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &s.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &s.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &s.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceLevelAgreement. +func (s ServiceLevelAgreement) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "expirationTime", s.ExpirationTime) + populate(objectMap, "slaMinutes", s.SLAMinutes) + populateTimeRFC3339(objectMap, "startTime", s.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceLevelAgreement. +func (s *ServiceLevelAgreement) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expirationTime": + err = unpopulateTimeRFC3339(val, "ExpirationTime", &s.ExpirationTime) + delete(rawMsg, key) + case "slaMinutes": + err = unpopulate(val, "SLAMinutes", &s.SLAMinutes) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceProperties. +func (s ServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "resourceTypes", s.ResourceTypes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceProperties. +func (s *ServiceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "resourceTypes": + err = unpopulate(val, "ResourceTypes", &s.ResourceTypes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServicesListResult. +func (s ServicesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServicesListResult. +func (s *ServicesListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TechnicalTicketDetails. +func (t TechnicalTicketDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceId", t.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TechnicalTicketDetails. +func (t *TechnicalTicketDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceId": + err = unpopulate(val, "ResourceID", &t.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TicketDetails. +func (t TicketDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TicketDetails. +func (t *TicketDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TicketDetailsProperties. +func (t TicketDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contactDetails", t.ContactDetails) + populateTimeRFC3339(objectMap, "createdDate", t.CreatedDate) + populate(objectMap, "description", t.Description) + populate(objectMap, "enrollmentId", t.EnrollmentID) + populateTimeRFC3339(objectMap, "modifiedDate", t.ModifiedDate) + populate(objectMap, "problemClassificationDisplayName", t.ProblemClassificationDisplayName) + populate(objectMap, "problemClassificationId", t.ProblemClassificationID) + populateTimeRFC3339(objectMap, "problemStartTime", t.ProblemStartTime) + populate(objectMap, "quotaTicketDetails", t.QuotaTicketDetails) + populate(objectMap, "require24X7Response", t.Require24X7Response) + populate(objectMap, "serviceDisplayName", t.ServiceDisplayName) + populate(objectMap, "serviceId", t.ServiceID) + populate(objectMap, "serviceLevelAgreement", t.ServiceLevelAgreement) + populate(objectMap, "severity", t.Severity) + populate(objectMap, "status", t.Status) + populate(objectMap, "supportEngineer", t.SupportEngineer) + populate(objectMap, "supportPlanType", t.SupportPlanType) + populate(objectMap, "supportTicketId", t.SupportTicketID) + populate(objectMap, "technicalTicketDetails", t.TechnicalTicketDetails) + populate(objectMap, "title", t.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TicketDetailsProperties. +func (t *TicketDetailsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contactDetails": + err = unpopulate(val, "ContactDetails", &t.ContactDetails) + delete(rawMsg, key) + case "createdDate": + err = unpopulateTimeRFC3339(val, "CreatedDate", &t.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &t.Description) + delete(rawMsg, key) + case "enrollmentId": + err = unpopulate(val, "EnrollmentID", &t.EnrollmentID) + delete(rawMsg, key) + case "modifiedDate": + err = unpopulateTimeRFC3339(val, "ModifiedDate", &t.ModifiedDate) + delete(rawMsg, key) + case "problemClassificationDisplayName": + err = unpopulate(val, "ProblemClassificationDisplayName", &t.ProblemClassificationDisplayName) + delete(rawMsg, key) + case "problemClassificationId": + err = unpopulate(val, "ProblemClassificationID", &t.ProblemClassificationID) + delete(rawMsg, key) + case "problemStartTime": + err = unpopulateTimeRFC3339(val, "ProblemStartTime", &t.ProblemStartTime) + delete(rawMsg, key) + case "quotaTicketDetails": + err = unpopulate(val, "QuotaTicketDetails", &t.QuotaTicketDetails) + delete(rawMsg, key) + case "require24X7Response": + err = unpopulate(val, "Require24X7Response", &t.Require24X7Response) + delete(rawMsg, key) + case "serviceDisplayName": + err = unpopulate(val, "ServiceDisplayName", &t.ServiceDisplayName) + delete(rawMsg, key) + case "serviceId": + err = unpopulate(val, "ServiceID", &t.ServiceID) + delete(rawMsg, key) + case "serviceLevelAgreement": + err = unpopulate(val, "ServiceLevelAgreement", &t.ServiceLevelAgreement) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &t.Severity) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &t.Status) + delete(rawMsg, key) + case "supportEngineer": + err = unpopulate(val, "SupportEngineer", &t.SupportEngineer) + delete(rawMsg, key) + case "supportPlanType": + err = unpopulate(val, "SupportPlanType", &t.SupportPlanType) + delete(rawMsg, key) + case "supportTicketId": + err = unpopulate(val, "SupportTicketID", &t.SupportTicketID) + delete(rawMsg, key) + case "technicalTicketDetails": + err = unpopulate(val, "TechnicalTicketDetails", &t.TechnicalTicketDetails) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &t.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TicketsListResult. +func (t TicketsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TicketsListResult. +func (t *TicketsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UpdateContactProfile. +func (u UpdateContactProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalEmailAddresses", u.AdditionalEmailAddresses) + populate(objectMap, "country", u.Country) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "lastName", u.LastName) + populate(objectMap, "phoneNumber", u.PhoneNumber) + populate(objectMap, "preferredContactMethod", u.PreferredContactMethod) + populate(objectMap, "preferredSupportLanguage", u.PreferredSupportLanguage) + populate(objectMap, "preferredTimeZone", u.PreferredTimeZone) + populate(objectMap, "primaryEmailAddress", u.PrimaryEmailAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateContactProfile. +func (u *UpdateContactProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalEmailAddresses": + err = unpopulate(val, "AdditionalEmailAddresses", &u.AdditionalEmailAddresses) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &u.Country) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &u.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &u.LastName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &u.PhoneNumber) + delete(rawMsg, key) + case "preferredContactMethod": + err = unpopulate(val, "PreferredContactMethod", &u.PreferredContactMethod) + delete(rawMsg, key) + case "preferredSupportLanguage": + err = unpopulate(val, "PreferredSupportLanguage", &u.PreferredSupportLanguage) + delete(rawMsg, key) + case "preferredTimeZone": + err = unpopulate(val, "PreferredTimeZone", &u.PreferredTimeZone) + delete(rawMsg, key) + case "primaryEmailAddress": + err = unpopulate(val, "PrimaryEmailAddress", &u.PrimaryEmailAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UpdateSupportTicket. +func (u UpdateSupportTicket) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contactDetails", u.ContactDetails) + populate(objectMap, "severity", u.Severity) + populate(objectMap, "status", u.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateSupportTicket. +func (u *UpdateSupportTicket) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contactDetails": + err = unpopulate(val, "ContactDetails", &u.ContactDetails) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &u.Severity) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &u.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_operations_client.go b/sdk/resourcemanager/support/armsupport/operations_client.go similarity index 76% rename from sdk/resourcemanager/support/armsupport/zz_generated_operations_client.go rename to sdk/resourcemanager/support/armsupport/operations_client.go index b7a661ec5cfa..5fd6fd382221 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_operations_client.go +++ b/sdk/resourcemanager/support/armsupport/operations_client.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -12,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" @@ -22,36 +21,27 @@ 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. +// - 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 } // NewListPager - This lists all the available Microsoft Support REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -62,7 +52,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 } @@ -77,7 +67,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.Support/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/support/armsupport/operations_client_example_test.go b/sdk/resourcemanager/support/armsupport/operations_client_example_test.go new file mode 100644 index 000000000000..dabc4b2885d6 --- /dev/null +++ b/sdk/resourcemanager/support/armsupport/operations_client_example_test.go @@ -0,0 +1,127 @@ +//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 armsupport_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListOperations.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().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.OperationsListResult = armsupport.OperationsListResult{ + // Value: []*armsupport.Operation{ + // { + // Name: to.Ptr("Microsoft.Support/services/read"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Gets all the Azure services available for support"), + // Operation: to.Ptr("Reads Services"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("Service"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/problemClassifications/read"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Gets all the problem classifications available for a specific Azure service"), + // Operation: to.Ptr("Reads Problem Classifications"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("Problem Classification"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/supportTickets/read"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Gets all the support tickets"), + // Operation: to.Ptr("Reads Support Tickets"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("Support Ticket"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/supportTickets/write"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Updates support ticket"), + // Operation: to.Ptr("Updates support ticket"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("Support Ticket"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/communications/read"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Gets all the communications"), + // Operation: to.Ptr("Reads Communications"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("Communication"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/communications/write"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Creates a communication"), + // Operation: to.Ptr("Creates a communication"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("Communication"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/register/action"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Registers Support Resource Provider"), + // Operation: to.Ptr("Registers Support Resource Provider"), + // Provider: to.Ptr("Registers Support Resource Provider"), + // Resource: to.Ptr("Support Registration"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/createSupportTicket/action"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Creates support ticket"), + // Operation: to.Ptr("Registers Support Resource Provider"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("SupportTicket"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Support/addCommunication/action"), + // Display: &armsupport.OperationDisplay{ + // Description: to.Ptr("Add communication to support ticket"), + // Operation: to.Ptr("Registers Support Resource Provider"), + // Provider: to.Ptr("Microsoft Support"), + // Resource: to.Ptr("Communication"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_problemclassifications_client.go b/sdk/resourcemanager/support/armsupport/problemclassifications_client.go similarity index 81% rename from sdk/resourcemanager/support/armsupport/zz_generated_problemclassifications_client.go rename to sdk/resourcemanager/support/armsupport/problemclassifications_client.go index 0fc165e41446..71fde6370e07 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_problemclassifications_client.go +++ b/sdk/resourcemanager/support/armsupport/problemclassifications_client.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -13,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" @@ -25,45 +24,37 @@ import ( // ProblemClassificationsClient contains the methods for the ProblemClassifications group. // Don't use this type directly, use NewProblemClassificationsClient() instead. type ProblemClassificationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewProblemClassificationsClient creates a new instance of ProblemClassificationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewProblemClassificationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ProblemClassificationsClient, 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+".ProblemClassificationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ProblemClassificationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get problem classification details for a specific Azure service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// serviceName - Name of the Azure service available for support. -// problemClassificationName - Name of problem classification. -// options - ProblemClassificationsClientGetOptions contains the optional parameters for the ProblemClassificationsClient.Get -// method. +// - serviceName - Name of the Azure service available for support. +// - problemClassificationName - Name of problem classification. +// - options - ProblemClassificationsClientGetOptions contains the optional parameters for the ProblemClassificationsClient.Get +// method. func (client *ProblemClassificationsClient) Get(ctx context.Context, serviceName string, problemClassificationName string, options *ProblemClassificationsClientGetOptions) (ProblemClassificationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, serviceName, problemClassificationName, options) if err != nil { return ProblemClassificationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProblemClassificationsClientGetResponse{}, err } @@ -84,7 +75,7 @@ func (client *ProblemClassificationsClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter problemClassificationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{problemClassificationName}", url.PathEscape(problemClassificationName)) - 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 } @@ -107,11 +98,11 @@ func (client *ProblemClassificationsClient) getHandleResponse(resp *http.Respons // NewListPager - Lists all the problem classifications (categories) available for a specific Azure service. Always use the // service and problem classifications obtained programmatically. This practice ensures that you // always have the most recent set of service and problem classification Ids. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// serviceName - Name of the Azure service for which the problem classifications need to be retrieved. -// options - ProblemClassificationsClientListOptions contains the optional parameters for the ProblemClassificationsClient.List -// method. +// - serviceName - Name of the Azure service for which the problem classifications need to be retrieved. +// - options - ProblemClassificationsClientListOptions contains the optional parameters for the ProblemClassificationsClient.NewListPager +// method. func (client *ProblemClassificationsClient) NewListPager(serviceName string, options *ProblemClassificationsClientListOptions) *runtime.Pager[ProblemClassificationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ProblemClassificationsClientListResponse]{ More: func(page ProblemClassificationsClientListResponse) bool { @@ -122,7 +113,7 @@ func (client *ProblemClassificationsClient) NewListPager(serviceName string, opt if err != nil { return ProblemClassificationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProblemClassificationsClientListResponse{}, err } @@ -141,7 +132,7 @@ func (client *ProblemClassificationsClient) listCreateRequest(ctx context.Contex return nil, errors.New("parameter serviceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) - 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/support/armsupport/problemclassifications_client_example_test.go b/sdk/resourcemanager/support/armsupport/problemclassifications_client_example_test.go new file mode 100644 index 000000000000..553580f7d02d --- /dev/null +++ b/sdk/resourcemanager/support/armsupport/problemclassifications_client_example_test.go @@ -0,0 +1,106 @@ +//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 armsupport_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListProblemClassifications.json +func ExampleProblemClassificationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProblemClassificationsClient().NewListPager("service_guid", 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.ProblemClassificationsListResult = armsupport.ProblemClassificationsListResult{ + // Value: []*armsupport.ProblemClassification{ + // { + // Name: to.Ptr("problemClassification_guid_1"), + // Type: to.Ptr("Microsoft.Support/problemClassifications"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid/problemClassifications/problemClassification_guid_1"), + // Properties: &armsupport.ProblemClassificationProperties{ + // DisplayName: to.Ptr("Reservation Management / Exchanges and Refunds"), + // }, + // }, + // { + // Name: to.Ptr("problemClassification_guid_2"), + // Type: to.Ptr("Microsoft.Support/problemClassifications"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid/problemClassifications/problemClassification_guid_2"), + // Properties: &armsupport.ProblemClassificationProperties{ + // DisplayName: to.Ptr("Reservation Management / Request Invoices"), + // }, + // }, + // { + // Name: to.Ptr("problemClassification_guid_3"), + // Type: to.Ptr("Microsoft.Support/problemClassifications"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid/problemClassifications/problemClassification_guid_3"), + // Properties: &armsupport.ProblemClassificationProperties{ + // DisplayName: to.Ptr("Reservation Management / Other Iissues or Requests"), + // }, + // }, + // { + // Name: to.Ptr("problemClassification_guid_4"), + // Type: to.Ptr("Microsoft.Support/problemClassifications"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid/problemClassifications/problemClassification_guid_4"), + // Properties: &armsupport.ProblemClassificationProperties{ + // DisplayName: to.Ptr("Other General Billing Questions"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetProblemClassification.json +func ExampleProblemClassificationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProblemClassificationsClient().Get(ctx, "service_guid", "problemClassification_guid", 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.ProblemClassification = armsupport.ProblemClassification{ + // Name: to.Ptr("problemClassification_guid"), + // Type: to.Ptr("Microsoft.Support/problemClassifications"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid/problemClassifications/problemClassification_guid"), + // Properties: &armsupport.ProblemClassificationProperties{ + // DisplayName: to.Ptr("Reservation Management / Exchanges and Refunds"), + // }, + // } +} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_response_types.go b/sdk/resourcemanager/support/armsupport/response_types.go similarity index 90% rename from sdk/resourcemanager/support/armsupport/zz_generated_response_types.go rename to sdk/resourcemanager/support/armsupport/response_types.go index b985c2dd2f06..f2ec9995d055 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_response_types.go +++ b/sdk/resourcemanager/support/armsupport/response_types.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -13,7 +14,7 @@ type CommunicationsClientCheckNameAvailabilityResponse struct { CheckNameAvailabilityOutput } -// CommunicationsClientCreateResponse contains the response from method CommunicationsClient.Create. +// CommunicationsClientCreateResponse contains the response from method CommunicationsClient.BeginCreate. type CommunicationsClientCreateResponse struct { CommunicationDetails } @@ -23,12 +24,12 @@ type CommunicationsClientGetResponse struct { CommunicationDetails } -// CommunicationsClientListResponse contains the response from method CommunicationsClient.List. +// CommunicationsClientListResponse contains the response from method CommunicationsClient.NewListPager. type CommunicationsClientListResponse struct { CommunicationsListResult } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationsListResult } @@ -38,7 +39,7 @@ type ProblemClassificationsClientGetResponse struct { ProblemClassification } -// ProblemClassificationsClientListResponse contains the response from method ProblemClassificationsClient.List. +// ProblemClassificationsClientListResponse contains the response from method ProblemClassificationsClient.NewListPager. type ProblemClassificationsClientListResponse struct { ProblemClassificationsListResult } @@ -48,7 +49,7 @@ type ServicesClientGetResponse struct { Service } -// ServicesClientListResponse contains the response from method ServicesClient.List. +// ServicesClientListResponse contains the response from method ServicesClient.NewListPager. type ServicesClientListResponse struct { ServicesListResult } @@ -58,7 +59,7 @@ type TicketsClientCheckNameAvailabilityResponse struct { CheckNameAvailabilityOutput } -// TicketsClientCreateResponse contains the response from method TicketsClient.Create. +// TicketsClientCreateResponse contains the response from method TicketsClient.BeginCreate. type TicketsClientCreateResponse struct { TicketDetails } @@ -68,7 +69,7 @@ type TicketsClientGetResponse struct { TicketDetails } -// TicketsClientListResponse contains the response from method TicketsClient.List. +// TicketsClientListResponse contains the response from method TicketsClient.NewListPager. type TicketsClientListResponse struct { TicketsListResult } diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_services_client.go b/sdk/resourcemanager/support/armsupport/services_client.go similarity index 82% rename from sdk/resourcemanager/support/armsupport/zz_generated_services_client.go rename to sdk/resourcemanager/support/armsupport/services_client.go index 816f558b82d0..f1052ce884ba 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_services_client.go +++ b/sdk/resourcemanager/support/armsupport/services_client.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -13,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" @@ -25,43 +24,35 @@ import ( // ServicesClient contains the methods for the Services group. // Don't use this type directly, use NewServicesClient() instead. type ServicesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewServicesClient creates a new instance of ServicesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServicesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ServicesClient, 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+".ServicesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServicesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a specific Azure service for support ticket creation. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// serviceName - Name of the Azure service. -// options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. +// - serviceName - Name of the Azure service. +// - options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. func (client *ServicesClient) Get(ctx context.Context, serviceName string, options *ServicesClientGetOptions) (ServicesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, serviceName, options) if err != nil { return ServicesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientGetResponse{}, err } @@ -78,7 +69,7 @@ func (client *ServicesClient) getCreateRequest(ctx context.Context, serviceName return nil, errors.New("parameter serviceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) - 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 } @@ -104,9 +95,9 @@ func (client *ServicesClient) getHandleResponse(resp *http.Response) (ServicesCl // page. Always use the service and its corresponding problem classification(s) // obtained programmatically for support ticket creation. This practice ensures that you always have the most recent set of // service and problem classification Ids. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// options - ServicesClientListOptions contains the optional parameters for the ServicesClient.List method. +// - options - ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. func (client *ServicesClient) NewListPager(options *ServicesClientListOptions) *runtime.Pager[ServicesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServicesClientListResponse]{ More: func(page ServicesClientListResponse) bool { @@ -117,7 +108,7 @@ func (client *ServicesClient) NewListPager(options *ServicesClientListOptions) * if err != nil { return ServicesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientListResponse{}, err } @@ -132,7 +123,7 @@ func (client *ServicesClient) NewListPager(options *ServicesClientListOptions) * // listCreateRequest creates the List request. func (client *ServicesClient) listCreateRequest(ctx context.Context, options *ServicesClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Support/services" - 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/support/armsupport/services_client_example_test.go b/sdk/resourcemanager/support/armsupport/services_client_example_test.go new file mode 100644 index 000000000000..bcf1a4c87d72 --- /dev/null +++ b/sdk/resourcemanager/support/armsupport/services_client_example_test.go @@ -0,0 +1,151 @@ +//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 armsupport_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListServices.json +func ExampleServicesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServicesClient().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.ServicesListResult = armsupport.ServicesListResult{ + // Value: []*armsupport.Service{ + // { + // Name: to.Ptr("service_guid_1"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid_1"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Billing"), + // ResourceTypes: []*string{ + // }, + // }, + // }, + // { + // Name: to.Ptr("service_guid_2"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid_2"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ResourceTypes: []*string{ + // }, + // }, + // }, + // { + // Name: to.Ptr("service_guid_3"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid_3"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Subscription management"), + // ResourceTypes: []*string{ + // }, + // }, + // }, + // { + // Name: to.Ptr("service_guid_4"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid_4"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Data Explorer"), + // ResourceTypes: []*string{ + // to.Ptr("MICROSOFT.KUSTO/CLUSTERS"), + // to.Ptr("MICROSOFT.KUSTO/DATABASES")}, + // }, + // }, + // { + // Name: to.Ptr("service_guid_5"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid_5"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Virtual Machine running Windows"), + // ResourceTypes: []*string{ + // to.Ptr("MICROSOFT.CLASSICCOMPUTE/VIRTUALMACHINES"), + // to.Ptr("MICROSOFT.COMPUTE/VIRTUALMACHINES")}, + // }, + // }, + // { + // Name: to.Ptr("service_guid_6"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid_6"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Virtual Machine running Linux"), + // ResourceTypes: []*string{ + // to.Ptr("MICROSOFT.CLASSICCOMPUTE/VIRTUALMACHINES"), + // to.Ptr("MICROSOFT.COMPUTE/VIRTUALMACHINES")}, + // }, + // }, + // { + // Name: to.Ptr("service_guid_7"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid_7"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Virtual Network"), + // ResourceTypes: []*string{ + // to.Ptr("MICROSOFT.NETWORK/VIRTUALNETWORKS"), + // to.Ptr("MICROSOFT.CLASSICNETWORK/VIRTUALNETWORKS")}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetService.json +func ExampleServicesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().Get(ctx, "service_guid", 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.Service = armsupport.Service{ + // Name: to.Ptr("service_guid"), + // Type: to.Ptr("Microsoft.Support/services"), + // ID: to.Ptr("/providers/Microsoft.Support/services/service_guid"), + // Properties: &armsupport.ServiceProperties{ + // DisplayName: to.Ptr("Virtual Machine running Windows"), + // ResourceTypes: []*string{ + // to.Ptr("MICROSOFT.CLASSICCOMPUTE/VIRTUALMACHINES"), + // to.Ptr("MICROSOFT.COMPUTE/VIRTUALMACHINES")}, + // }, + // } +} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_tickets_client.go b/sdk/resourcemanager/support/armsupport/tickets_client.go similarity index 88% rename from sdk/resourcemanager/support/armsupport/zz_generated_tickets_client.go rename to sdk/resourcemanager/support/armsupport/tickets_client.go index 55ad77c73ba2..958fb65313bb 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_tickets_client.go +++ b/sdk/resourcemanager/support/armsupport/tickets_client.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -13,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,31 +25,22 @@ import ( // TicketsClient contains the methods for the SupportTickets group. // Don't use this type directly, use NewTicketsClient() instead. type TicketsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTicketsClient creates a new instance of TicketsClient with the specified values. -// subscriptionID - Azure subscription Id. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure subscription Id. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTicketsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TicketsClient, 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+".TicketsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TicketsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,16 +48,17 @@ func NewTicketsClient(subscriptionID string, credential azcore.TokenCredential, // CheckNameAvailability - Check the availability of a resource name. This API should be used to check the uniqueness of the // name for support ticket creation for the selected subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// checkNameAvailabilityInput - Input to check. -// options - TicketsClientCheckNameAvailabilityOptions contains the optional parameters for the TicketsClient.CheckNameAvailability -// method. +// - checkNameAvailabilityInput - Input to check. +// - options - TicketsClientCheckNameAvailabilityOptions contains the optional parameters for the TicketsClient.CheckNameAvailability +// method. func (client *TicketsClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityInput CheckNameAvailabilityInput, options *TicketsClientCheckNameAvailabilityOptions) (TicketsClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, checkNameAvailabilityInput, options) if err != nil { return TicketsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TicketsClientCheckNameAvailabilityResponse{}, err } @@ -84,7 +75,7 @@ func (client *TicketsClient) checkNameAvailabilityCreateRequest(ctx context.Cont 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 } @@ -123,21 +114,22 @@ func (client *TicketsClient) checkNameAvailabilityHandleResponse(resp *http.Resp // subscription, i.e. Cloud solution provider (CSP) customer tenant. The auxiliary token will be from the Cloud solution provider // (CSP) partner tenant. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// supportTicketName - Support ticket name. -// createSupportTicketParameters - Support ticket request payload. -// options - TicketsClientBeginCreateOptions contains the optional parameters for the TicketsClient.BeginCreate method. +// - supportTicketName - Support ticket name. +// - createSupportTicketParameters - Support ticket request payload. +// - options - TicketsClientBeginCreateOptions contains the optional parameters for the TicketsClient.BeginCreate method. func (client *TicketsClient) BeginCreate(ctx context.Context, supportTicketName string, createSupportTicketParameters TicketDetails, options *TicketsClientBeginCreateOptions) (*runtime.Poller[TicketsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, supportTicketName, createSupportTicketParameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TicketsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TicketsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[TicketsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TicketsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -160,13 +152,14 @@ func (client *TicketsClient) BeginCreate(ctx context.Context, supportTicketName // subscription, i.e. Cloud solution provider (CSP) customer tenant. The auxiliary token will be from the Cloud solution provider // (CSP) partner tenant. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 func (client *TicketsClient) create(ctx context.Context, supportTicketName string, createSupportTicketParameters TicketDetails, options *TicketsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, supportTicketName, createSupportTicketParameters, options) 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 } @@ -187,7 +180,7 @@ func (client *TicketsClient) createCreateRequest(ctx context.Context, supportTic 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.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 } @@ -202,15 +195,16 @@ func (client *TicketsClient) createCreateRequest(ctx context.Context, supportTic // If a ticket was created more than 18 months ago, a request for data might cause an // error. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// supportTicketName - Support ticket name. -// options - TicketsClientGetOptions contains the optional parameters for the TicketsClient.Get method. +// - supportTicketName - Support ticket name. +// - options - TicketsClientGetOptions contains the optional parameters for the TicketsClient.Get method. func (client *TicketsClient) Get(ctx context.Context, supportTicketName string, options *TicketsClientGetOptions) (TicketsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, supportTicketName, options) if err != nil { return TicketsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TicketsClientGetResponse{}, err } @@ -231,7 +225,7 @@ func (client *TicketsClient) getCreateRequest(ctx context.Context, supportTicket 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 } @@ -256,9 +250,9 @@ func (client *TicketsClient) getHandleResponse(resp *http.Response) (TicketsClie // using which you can retrieve the next set of support tickets. // Support ticket data is available for 18 months after ticket creation. If a ticket was created more than 18 months ago, // a request for data might cause an error. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// options - TicketsClientListOptions contains the optional parameters for the TicketsClient.List method. +// - options - TicketsClientListOptions contains the optional parameters for the TicketsClient.NewListPager method. func (client *TicketsClient) NewListPager(options *TicketsClientListOptions) *runtime.Pager[TicketsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TicketsClientListResponse]{ More: func(page TicketsClientListResponse) bool { @@ -275,7 +269,7 @@ func (client *TicketsClient) NewListPager(options *TicketsClientListOptions) *ru if err != nil { return TicketsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TicketsClientListResponse{}, err } @@ -294,7 +288,7 @@ func (client *TicketsClient) listCreateRequest(ctx context.Context, options *Tic 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 } @@ -327,16 +321,17 @@ func (client *TicketsClient) listHandleResponse(resp *http.Response) (TicketsCli // Changing the ticket status to closed is allowed only on an unassigned case. When an engineer is actively working on the // ticket, send your ticket closure request by sending a note to your engineer. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-04-01 -// supportTicketName - Support ticket name. -// updateSupportTicket - UpdateSupportTicket object. -// options - TicketsClientUpdateOptions contains the optional parameters for the TicketsClient.Update method. +// - supportTicketName - Support ticket name. +// - updateSupportTicket - UpdateSupportTicket object. +// - options - TicketsClientUpdateOptions contains the optional parameters for the TicketsClient.Update method. func (client *TicketsClient) Update(ctx context.Context, supportTicketName string, updateSupportTicket UpdateSupportTicket, options *TicketsClientUpdateOptions) (TicketsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, supportTicketName, updateSupportTicket, options) if err != nil { return TicketsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TicketsClientUpdateResponse{}, err } @@ -357,7 +352,7 @@ func (client *TicketsClient) updateCreateRequest(ctx context.Context, supportTic 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.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 } diff --git a/sdk/resourcemanager/support/armsupport/tickets_client_example_test.go b/sdk/resourcemanager/support/armsupport/tickets_client_example_test.go new file mode 100644 index 000000000000..bd39d3019e66 --- /dev/null +++ b/sdk/resourcemanager/support/armsupport/tickets_client_example_test.go @@ -0,0 +1,2178 @@ +//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 armsupport_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/support/armsupport" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CheckNameAvailabilityWithSubscription.json +func ExampleTicketsClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTicketsClient().CheckNameAvailability(ctx, armsupport.CheckNameAvailabilityInput{ + Name: to.Ptr("sampleName"), + Type: to.Ptr(armsupport.TypeMicrosoftSupportSupportTickets), + }, 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.CheckNameAvailabilityOutput = armsupport.CheckNameAvailabilityOutput{ + // Message: to.Ptr("Name not available"), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr("Name is already in use"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListSupportTicketsCreatedOnOrAfterAndInOpenStateBySubscription.json +func ExampleTicketsClient_NewListPager_listSupportTicketsCreatedOnOrAfterACertainDateAndInOpenStateForASubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTicketsClient().NewListPager(&armsupport.TicketsClientListOptions{Top: nil, + Filter: to.Ptr("createdDate ge 2020-03-10T22:08:51Z and status eq 'Open'"), + }) + 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.TicketsListResult = armsupport.TicketsListResult{ + // Value: []*armsupport.TicketDetails{ + // { + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-11T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-12T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Connectivity / Cannot connect to virtual machine by using RDP or SSH"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Virtual Machine running Linux"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-12T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-11T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // TechnicalTicketDetails: &armsupport.TechnicalTicketDetails{ + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/testserver"), + // }, + // Title: to.Ptr("my title"), + // }, + // }, + // { + // Name: to.Ptr("testticket2"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket2"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("This is a test - please ignore"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("USA"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-11T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-12T21:36:18Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Add or Edit VAT, TAX ID, or PO Number"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-12T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-11T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelMinimal), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("118032014183771"), + // Title: to.Ptr("Test - please ignore"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListSupportTicketsBySubscription.json +func ExampleTicketsClient_NewListPager_listSupportTicketsForASubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTicketsClient().NewListPager(&armsupport.TicketsClientListOptions{Top: nil, + Filter: 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.TicketsListResult = armsupport.TicketsListResult{ + // Value: []*armsupport.TicketDetails{ + // { + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Connectivity / Cannot connect to virtual machine by using RDP or SSH"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Virtual Machine running Linux"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // TechnicalTicketDetails: &armsupport.TechnicalTicketDetails{ + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/testserver"), + // }, + // Title: to.Ptr("my title"), + // }, + // }, + // { + // Name: to.Ptr("testticket2"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket2"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("This is a test - please ignore"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("USA"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Add or Edit VAT, TAX ID, or PO Number"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelMinimal), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("118032014183771"), + // Title: to.Ptr("Test - please ignore"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListSupportTicketsInOpenStateBySubscription.json +func ExampleTicketsClient_NewListPager_listSupportTicketsInOpenStateForASubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTicketsClient().NewListPager(&armsupport.TicketsClientListOptions{Top: nil, + Filter: to.Ptr("status eq 'Open'"), + }) + 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.TicketsListResult = armsupport.TicketsListResult{ + // Value: []*armsupport.TicketDetails{ + // { + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Connectivity / Cannot connect to virtual machine by using RDP or SSH"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Virtual Machine running Linux"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // TechnicalTicketDetails: &armsupport.TechnicalTicketDetails{ + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/testserver"), + // }, + // Title: to.Ptr("my title"), + // }, + // }, + // { + // Name: to.Ptr("testticket2"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket2"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("This is a test - please ignore"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("USA"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Add or Edit VAT, TAX ID, or PO Number"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelMinimal), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("118032014183771"), + // Title: to.Ptr("Test - please ignore"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetSubscriptionSupportTicketDetails.json +func ExampleTicketsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTicketsClient().Get(ctx, "testticket", 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("This is a test - please ignore"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("USA"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Add or Edit VAT, TAX ID, or PO Number"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelMinimal), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("118032014183770"), + // Title: to.Ptr("Test - please ignore"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/UpdateContactDetailsOfSupportTicketForSubscription.json +func ExampleTicketsClient_Update_updateContactDetailsOfASupportTicket() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTicketsClient().Update(ctx, "testticket", armsupport.UpdateSupportTicket{ + ContactDetails: &armsupport.UpdateContactProfile{ + AdditionalEmailAddresses: []*string{ + to.Ptr("tname@contoso.com"), + to.Ptr("teamtest@contoso.com")}, + Country: to.Ptr("USA"), + FirstName: to.Ptr("first name"), + LastName: to.Ptr("last name"), + PhoneNumber: to.Ptr("123-456-7890"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("test.name@contoso.com"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("This is a test - please ignore"), + // ContactDetails: &armsupport.ContactProfile{ + // AdditionalEmailAddresses: []*string{ + // to.Ptr("tname@contoso.com"), + // to.Ptr("teamtest@contoso.com")}, + // Country: to.Ptr("USA"), + // FirstName: to.Ptr("first name"), + // LastName: to.Ptr("last name"), + // PhoneNumber: to.Ptr("123-456-7890"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("test.name@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Add or Edit VAT, TAX ID, or PO Number"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelCritical), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("118032014183770"), + // Title: to.Ptr("Test - please ignore"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/UpdateSeverityOfSupportTicketForSubscription.json +func ExampleTicketsClient_Update_updateSeverityOfASupportTicket() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTicketsClient().Update(ctx, "testticket", armsupport.UpdateSupportTicket{ + Severity: to.Ptr(armsupport.SeverityLevelCritical), + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("This is a test - please ignore"), + // ContactDetails: &armsupport.ContactProfile{ + // AdditionalEmailAddresses: []*string{ + // to.Ptr("tname@contoso.com"), + // to.Ptr("teamtest@contoso.com")}, + // Country: to.Ptr("USA"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("test.name@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Add or Edit VAT, TAX ID, or PO Number"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelCritical), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // EmailAddress: to.Ptr("xyz@contoso.com"), + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("118032014183770"), + // Title: to.Ptr("Test - please ignore"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/UpdateStatusOfSupportTicketForSubscription.json +func ExampleTicketsClient_Update_updateStatusOfASupportTicket() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTicketsClient().Update(ctx, "testticket", armsupport.UpdateSupportTicket{ + Status: to.Ptr(armsupport.StatusClosed), + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("This is a test - please ignore"), + // ContactDetails: &armsupport.ContactProfile{ + // AdditionalEmailAddresses: []*string{ + // to.Ptr("tname@contoso.com"), + // to.Ptr("teamtest@contoso.com")}, + // Country: to.Ptr("USA"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("test.name@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Add or Edit VAT, TAX ID, or PO Number"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelCritical), + // Status: to.Ptr("Closed"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("118032014183770"), + // Title: to.Ptr("Test - please ignore"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateBillingSupportTicketForSubscription.json +func ExampleTicketsClient_BeginCreate_createATicketForBillingRelatedIssues() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/billing_service_guid/problemClassifications/billing_problemClassification_guid"), + ServiceID: to.Ptr("/providers/Microsoft.Support/services/billing_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Refund request"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/billing_service_guid/problemClassifications/billing_problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Billing"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/billing_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSubMgmtSupportTicketForSubscription.json +func ExampleTicketsClient_BeginCreate_createATicketForSubscriptionManagementRelatedIssues() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/subscription_management_problemClassification_guid"), + ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Transfer ownership of my subscription"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/subscription_management_problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Subscription management"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/subscription_management_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateTechnicalSupportTicketForSubscription.json +func ExampleTicketsClient_BeginCreate_createATicketForTechnicalIssueRelatedToASpecificResource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_running_linux_service_guid/problemClassifications/problemClassification_guid"), + ServiceID: to.Ptr("/providers/Microsoft.Support/services/cddd3eb5-1830-b494-44fd-782f691479dc"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + TechnicalTicketDetails: &armsupport.TechnicalTicketDetails{ + ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/testserver"), + }, + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Connectivity / Cannot connect to virtual machine by using RDP or SSH"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_running_linux_service_guid/problemClassifications/problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Virtual Machine running Linux"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/virtual_machine_running_linux_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // TechnicalTicketDetails: &armsupport.TechnicalTicketDetails{ + // ResourceID: to.Ptr("/subscriptions/subid/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/testserver"), + // }, + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForActiveJobs.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForActiveJobsAndJobSchedulesForABatchAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("Account"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Jobs\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Batch"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Account"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Jobs\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSqlManagedInstanceQuotaTicket.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForAzureSqlManagedInstance() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_managedinstance_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("SQLMI"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"vCore\"}"), + Region: to.Ptr("EastUS"), + }, + { + Payload: to.Ptr("{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"Subnet\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("SQL Database Managed Instance"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("SQLMI"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"vCore\"}"), + // Region: to.Ptr("EastUS"), + // }, + // { + // Payload: to.Ptr("{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"Subnet\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateBatchQuotaTicketForSubscription.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForBatchAccountsForASubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("Subscription"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"NewLimit\":200,\"Type\":\"Account\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Batch"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Subscription"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"NewLimit\":200,\"Type\":\"Account\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateCoresQuotaTicketForSubscription.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForComputeVmCores() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cores_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"SKU\":\"DSv3 Series\",\"NewLimit\":104}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Compute-VM (cores-vCPUs) subscription limit increases"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cores_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"VmFamily\":\"DSv3 Series\",\"NewLimit\":104}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSqlDatawarehouseQuotaTicketForDTUs.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForDtUsForAzureSynapseAnalytics() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("DTUs"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"ServerName\":\"testserver\",\"NewLimit\":54000}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("SQL Data Warehouse"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("DTUs"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"ServerName\":\"testserver\",\"NewLimit\":54000}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSqlDatabaseQuotaTicketForDTUs.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForDtUsForSqlDatabase() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("DTUs"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"ServerName\":\"testserver\",\"NewLimit\":54000}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("SQL database"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("DTUs"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"ServerName\":\"testserver\",\"NewLimit\":54000}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateMachineLearningQuotaTicketForLowPriorityCores.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForLowPriorityCoresForMachineLearningService() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("BatchAml"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"NewLimit\":200,\"Type\":\"LowPriority\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Machine Learning service"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Account"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"NewLimit\":200,\"Type\":\"LowPriority\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForLowPriorityCores.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForLowPriorityCoresForABatchAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("Account"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"LowPriority\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Batch"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Account"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"LowPriority\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForPools.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForPoolsForABatchAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("Account"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Pools\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Batch"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Account"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Pools\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSqlDatawarehouseQuotaTicketForServers.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForServersForAzureSynapseAnalytics() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("Servers"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"NewLimit\":200}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("SQL Data Warehouse"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Servers"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"NewLimit\":200}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSqlDatabaseQuotaTicketForServers.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForServersForSqlDatabase() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("Servers"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"NewLimit\":200}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("SQL database"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Servers"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"NewLimit\":200}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateGenericQuotaTicket.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForServicesThatDoNotRequireAdditionalDetailsInTheQuotaTicketDetailsObject() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("Increase the maximum throughput per container limit to 10000 for account foo bar"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cosmosdb_problemClassification_guid"), + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("Increase the maximum throughput per container limit to 10000 for account foo bar"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Cosmos DB"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cosmosdb_problemClassification_guid"), + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateMachineLearningQuotaTicketForDedicatedCores.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForSpecificVmFamilyCoresForMachineLearningService() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("BatchAml"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Machine Learning service"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Account"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForDedicatedCores.json +func ExampleTicketsClient_BeginCreate_createATicketToRequestQuotaIncreaseForSpecificVmFamilyCoresForABatchAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armsupport.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTicketsClient().BeginCreate(ctx, "testticket", armsupport.TicketDetails{ + Properties: &armsupport.TicketDetailsProperties{ + Description: to.Ptr("my description"), + ContactDetails: &armsupport.ContactProfile{ + Country: to.Ptr("usa"), + FirstName: to.Ptr("abc"), + LastName: to.Ptr("xyz"), + PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + PreferredSupportLanguage: to.Ptr("en-US"), + PreferredTimeZone: to.Ptr("Pacific Standard Time"), + PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + }, + ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + QuotaChangeRequestSubType: to.Ptr("Account"), + QuotaChangeRequestVersion: to.Ptr("1.0"), + QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + { + Payload: to.Ptr("{\"AccountName\":\"test\",\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}"), + Region: to.Ptr("EastUS"), + }}, + }, + ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + Severity: to.Ptr(armsupport.SeverityLevelModerate), + Title: to.Ptr("my title"), + }, + }, 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.TicketDetails = armsupport.TicketDetails{ + // Name: to.Ptr("testticket"), + // Type: to.Ptr("Microsoft.Support/supportTickets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Support/supportTickets/testticket"), + // Properties: &armsupport.TicketDetailsProperties{ + // Description: to.Ptr("my description"), + // ContactDetails: &armsupport.ContactProfile{ + // Country: to.Ptr("usa"), + // FirstName: to.Ptr("abc"), + // LastName: to.Ptr("xyz"), + // PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), + // PreferredSupportLanguage: to.Ptr("en-US"), + // PreferredTimeZone: to.Ptr("Pacific Standard Time"), + // PrimaryEmailAddress: to.Ptr("abc@contoso.com"), + // }, + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // ModifiedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:23Z"); return t}()), + // ProblemClassificationDisplayName: to.Ptr("Batch"), + // ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid"), + // QuotaTicketDetails: &armsupport.QuotaTicketDetails{ + // QuotaChangeRequestSubType: to.Ptr("Account"), + // QuotaChangeRequestVersion: to.Ptr("1.0"), + // QuotaChangeRequests: []*armsupport.QuotaChangeRequest{ + // { + // Payload: to.Ptr("{\"AccountName\":\"test\",\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}"), + // Region: to.Ptr("EastUS"), + // }}, + // }, + // Require24X7Response: to.Ptr(false), + // ServiceDisplayName: to.Ptr("Service and subscription limits (quotas)"), + // ServiceID: to.Ptr("/providers/Microsoft.Support/services/quota_service_guid"), + // ServiceLevelAgreement: &armsupport.ServiceLevelAgreement{ + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-21T17:36:18Z"); return t}()), + // SLAMinutes: to.Ptr[int32](240), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-03-20T21:36:18Z"); return t}()), + // }, + // Severity: to.Ptr(armsupport.SeverityLevelModerate), + // Status: to.Ptr("Open"), + // SupportEngineer: &armsupport.Engineer{ + // }, + // SupportPlanType: to.Ptr("Premier"), + // SupportTicketID: to.Ptr("119120321001170"), + // Title: to.Ptr("my title"), + // }, + // } +} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_time_rfc3339.go b/sdk/resourcemanager/support/armsupport/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/support/armsupport/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/support/armsupport/time_rfc3339.go index 80c96440edca..5f0e67da93ce 100644 --- a/sdk/resourcemanager/support/armsupport/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/support/armsupport/time_rfc3339.go @@ -5,6 +5,7 @@ // 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 armsupport @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/support/armsupport/ze_generated_example_communications_client_test.go b/sdk/resourcemanager/support/armsupport/ze_generated_example_communications_client_test.go deleted file mode 100644 index 1d8c2f5a1d9a..000000000000 --- a/sdk/resourcemanager/support/armsupport/ze_generated_example_communications_client_test.go +++ /dev/null @@ -1,125 +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. - -package armsupport_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/support/armsupport" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CheckNameAvailabilityForSupportTicketCommunication.json -func ExampleCommunicationsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewCommunicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckNameAvailability(ctx, - "testticket", - armsupport.CheckNameAvailabilityInput{ - Name: to.Ptr("sampleName"), - Type: to.Ptr(armsupport.TypeMicrosoftSupportCommunications), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListCommunicationsForSubscriptionSupportTicket.json -func ExampleCommunicationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewCommunicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("testticket", - &armsupport.CommunicationsClientListOptions{Top: nil, - Filter: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetCommunicationDetailsForSubscriptionSupportTicket.json -func ExampleCommunicationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewCommunicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testticket", - "testmessage", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateSupportTicketCommunication.json -func ExampleCommunicationsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewCommunicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "testticket", - "testcommunication", - armsupport.CommunicationDetails{ - Properties: &armsupport.CommunicationDetailsProperties{ - Body: to.Ptr("This is a test message from a customer!"), - Sender: to.Ptr("user@contoso.com"), - Subject: to.Ptr("This is a test message from a customer!"), - }, - }, - 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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/support/armsupport/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/support/armsupport/ze_generated_example_operations_client_test.go deleted file mode 100644 index bf2c5b248e42..000000000000 --- a/sdk/resourcemanager/support/armsupport/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +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. - -package armsupport_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListOperations.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 := armsupport.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/support/armsupport/ze_generated_example_problemclassifications_client_test.go b/sdk/resourcemanager/support/armsupport/ze_generated_example_problemclassifications_client_test.go deleted file mode 100644 index 19455cfb0fda..000000000000 --- a/sdk/resourcemanager/support/armsupport/ze_generated_example_problemclassifications_client_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. - -package armsupport_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListProblemClassifications.json -func ExampleProblemClassificationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewProblemClassificationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("service_guid", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetProblemClassification.json -func ExampleProblemClassificationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewProblemClassificationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "service_guid", - "problemClassification_guid", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/support/armsupport/ze_generated_example_services_client_test.go b/sdk/resourcemanager/support/armsupport/ze_generated_example_services_client_test.go deleted file mode 100644 index d7ab357d1e32..000000000000 --- a/sdk/resourcemanager/support/armsupport/ze_generated_example_services_client_test.go +++ /dev/null @@ -1,62 +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. - -package armsupport_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/support/armsupport" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListServices.json -func ExampleServicesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewServicesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetService.json -func ExampleServicesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewServicesClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "service_guid", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/support/armsupport/ze_generated_example_supporttickets_client_test.go b/sdk/resourcemanager/support/armsupport/ze_generated_example_supporttickets_client_test.go deleted file mode 100644 index 93dd42d0768b..000000000000 --- a/sdk/resourcemanager/support/armsupport/ze_generated_example_supporttickets_client_test.go +++ /dev/null @@ -1,168 +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. - -package armsupport_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/support/armsupport" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CheckNameAvailabilityWithSubscription.json -func ExampleTicketsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewTicketsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckNameAvailability(ctx, - armsupport.CheckNameAvailabilityInput{ - Name: to.Ptr("sampleName"), - Type: to.Ptr(armsupport.TypeMicrosoftSupportSupportTickets), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/ListSupportTicketsCreatedOnOrAfterAndInOpenStateBySubscription.json -func ExampleTicketsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewTicketsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(&armsupport.TicketsClientListOptions{Top: nil, - Filter: to.Ptr("createdDate ge 2020-03-10T22:08:51Z and status eq 'Open'"), - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/GetSubscriptionSupportTicketDetails.json -func ExampleTicketsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewTicketsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testticket", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/UpdateContactDetailsOfSupportTicketForSubscription.json -func ExampleTicketsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewTicketsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "testticket", - armsupport.UpdateSupportTicket{ - ContactDetails: &armsupport.UpdateContactProfile{ - AdditionalEmailAddresses: []*string{ - to.Ptr("tname@contoso.com"), - to.Ptr("teamtest@contoso.com")}, - Country: to.Ptr("USA"), - FirstName: to.Ptr("first name"), - LastName: to.Ptr("last name"), - PhoneNumber: to.Ptr("123-456-7890"), - PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), - PreferredSupportLanguage: to.Ptr("en-US"), - PreferredTimeZone: to.Ptr("Pacific Standard Time"), - PrimaryEmailAddress: to.Ptr("test.name@contoso.com"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/support/resource-manager/Microsoft.Support/stable/2020-04-01/examples/CreateBillingSupportTicketForSubscription.json -func ExampleTicketsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armsupport.NewTicketsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "testticket", - armsupport.TicketDetails{ - Properties: &armsupport.TicketDetailsProperties{ - Description: to.Ptr("my description"), - ContactDetails: &armsupport.ContactProfile{ - Country: to.Ptr("usa"), - FirstName: to.Ptr("abc"), - LastName: to.Ptr("xyz"), - PreferredContactMethod: to.Ptr(armsupport.PreferredContactMethodEmail), - PreferredSupportLanguage: to.Ptr("en-US"), - PreferredTimeZone: to.Ptr("Pacific Standard Time"), - PrimaryEmailAddress: to.Ptr("abc@contoso.com"), - }, - ProblemClassificationID: to.Ptr("/providers/Microsoft.Support/services/billing_service_guid/problemClassifications/billing_problemClassification_guid"), - ServiceID: to.Ptr("/providers/Microsoft.Support/services/billing_service_guid"), - Severity: to.Ptr(armsupport.SeverityLevelModerate), - Title: to.Ptr("my title"), - }, - }, - 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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/support/armsupport/zz_generated_models_serde.go b/sdk/resourcemanager/support/armsupport/zz_generated_models_serde.go deleted file mode 100644 index e76b21dbf984..000000000000 --- a/sdk/resourcemanager/support/armsupport/zz_generated_models_serde.go +++ /dev/null @@ -1,269 +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. - -package armsupport - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type CommunicationDetailsProperties. -func (c CommunicationDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "body", c.Body) - populate(objectMap, "communicationDirection", c.CommunicationDirection) - populate(objectMap, "communicationType", c.CommunicationType) - populateTimeRFC3339(objectMap, "createdDate", c.CreatedDate) - populate(objectMap, "sender", c.Sender) - populate(objectMap, "subject", c.Subject) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationDetailsProperties. -func (c *CommunicationDetailsProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "body": - err = unpopulate(val, "Body", &c.Body) - delete(rawMsg, key) - case "communicationDirection": - err = unpopulate(val, "CommunicationDirection", &c.CommunicationDirection) - delete(rawMsg, key) - case "communicationType": - err = unpopulate(val, "CommunicationType", &c.CommunicationType) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &c.CreatedDate) - delete(rawMsg, key) - case "sender": - err = unpopulate(val, "Sender", &c.Sender) - delete(rawMsg, key) - case "subject": - err = unpopulate(val, "Subject", &c.Subject) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ContactProfile. -func (c ContactProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "additionalEmailAddresses", c.AdditionalEmailAddresses) - populate(objectMap, "country", c.Country) - populate(objectMap, "firstName", c.FirstName) - populate(objectMap, "lastName", c.LastName) - populate(objectMap, "phoneNumber", c.PhoneNumber) - populate(objectMap, "preferredContactMethod", c.PreferredContactMethod) - populate(objectMap, "preferredSupportLanguage", c.PreferredSupportLanguage) - populate(objectMap, "preferredTimeZone", c.PreferredTimeZone) - populate(objectMap, "primaryEmailAddress", c.PrimaryEmailAddress) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type QuotaTicketDetails. -func (q QuotaTicketDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "quotaChangeRequestSubType", q.QuotaChangeRequestSubType) - populate(objectMap, "quotaChangeRequestVersion", q.QuotaChangeRequestVersion) - populate(objectMap, "quotaChangeRequests", q.QuotaChangeRequests) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ServiceLevelAgreement. -func (s ServiceLevelAgreement) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "expirationTime", s.ExpirationTime) - populate(objectMap, "slaMinutes", s.SLAMinutes) - populateTimeRFC3339(objectMap, "startTime", s.StartTime) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceLevelAgreement. -func (s *ServiceLevelAgreement) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "expirationTime": - err = unpopulateTimeRFC3339(val, "ExpirationTime", &s.ExpirationTime) - delete(rawMsg, key) - case "slaMinutes": - err = unpopulate(val, "SLAMinutes", &s.SLAMinutes) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type TicketDetailsProperties. -func (t TicketDetailsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "contactDetails", t.ContactDetails) - populateTimeRFC3339(objectMap, "createdDate", t.CreatedDate) - populate(objectMap, "description", t.Description) - populate(objectMap, "enrollmentId", t.EnrollmentID) - populateTimeRFC3339(objectMap, "modifiedDate", t.ModifiedDate) - populate(objectMap, "problemClassificationDisplayName", t.ProblemClassificationDisplayName) - populate(objectMap, "problemClassificationId", t.ProblemClassificationID) - populateTimeRFC3339(objectMap, "problemStartTime", t.ProblemStartTime) - populate(objectMap, "quotaTicketDetails", t.QuotaTicketDetails) - populate(objectMap, "require24X7Response", t.Require24X7Response) - populate(objectMap, "serviceDisplayName", t.ServiceDisplayName) - populate(objectMap, "serviceId", t.ServiceID) - populate(objectMap, "serviceLevelAgreement", t.ServiceLevelAgreement) - populate(objectMap, "severity", t.Severity) - populate(objectMap, "status", t.Status) - populate(objectMap, "supportEngineer", t.SupportEngineer) - populate(objectMap, "supportPlanType", t.SupportPlanType) - populate(objectMap, "supportTicketId", t.SupportTicketID) - populate(objectMap, "technicalTicketDetails", t.TechnicalTicketDetails) - populate(objectMap, "title", t.Title) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TicketDetailsProperties. -func (t *TicketDetailsProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "contactDetails": - err = unpopulate(val, "ContactDetails", &t.ContactDetails) - delete(rawMsg, key) - case "createdDate": - err = unpopulateTimeRFC3339(val, "CreatedDate", &t.CreatedDate) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &t.Description) - delete(rawMsg, key) - case "enrollmentId": - err = unpopulate(val, "EnrollmentID", &t.EnrollmentID) - delete(rawMsg, key) - case "modifiedDate": - err = unpopulateTimeRFC3339(val, "ModifiedDate", &t.ModifiedDate) - delete(rawMsg, key) - case "problemClassificationDisplayName": - err = unpopulate(val, "ProblemClassificationDisplayName", &t.ProblemClassificationDisplayName) - delete(rawMsg, key) - case "problemClassificationId": - err = unpopulate(val, "ProblemClassificationID", &t.ProblemClassificationID) - delete(rawMsg, key) - case "problemStartTime": - err = unpopulateTimeRFC3339(val, "ProblemStartTime", &t.ProblemStartTime) - delete(rawMsg, key) - case "quotaTicketDetails": - err = unpopulate(val, "QuotaTicketDetails", &t.QuotaTicketDetails) - delete(rawMsg, key) - case "require24X7Response": - err = unpopulate(val, "Require24X7Response", &t.Require24X7Response) - delete(rawMsg, key) - case "serviceDisplayName": - err = unpopulate(val, "ServiceDisplayName", &t.ServiceDisplayName) - delete(rawMsg, key) - case "serviceId": - err = unpopulate(val, "ServiceID", &t.ServiceID) - delete(rawMsg, key) - case "serviceLevelAgreement": - err = unpopulate(val, "ServiceLevelAgreement", &t.ServiceLevelAgreement) - delete(rawMsg, key) - case "severity": - err = unpopulate(val, "Severity", &t.Severity) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &t.Status) - delete(rawMsg, key) - case "supportEngineer": - err = unpopulate(val, "SupportEngineer", &t.SupportEngineer) - delete(rawMsg, key) - case "supportPlanType": - err = unpopulate(val, "SupportPlanType", &t.SupportPlanType) - delete(rawMsg, key) - case "supportTicketId": - err = unpopulate(val, "SupportTicketID", &t.SupportTicketID) - delete(rawMsg, key) - case "technicalTicketDetails": - err = unpopulate(val, "TechnicalTicketDetails", &t.TechnicalTicketDetails) - delete(rawMsg, key) - case "title": - err = unpopulate(val, "Title", &t.Title) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type UpdateContactProfile. -func (u UpdateContactProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "additionalEmailAddresses", u.AdditionalEmailAddresses) - populate(objectMap, "country", u.Country) - populate(objectMap, "firstName", u.FirstName) - populate(objectMap, "lastName", u.LastName) - populate(objectMap, "phoneNumber", u.PhoneNumber) - populate(objectMap, "preferredContactMethod", u.PreferredContactMethod) - populate(objectMap, "preferredSupportLanguage", u.PreferredSupportLanguage) - populate(objectMap, "preferredTimeZone", u.PreferredTimeZone) - populate(objectMap, "primaryEmailAddress", u.PrimaryEmailAddress) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type UpdateSupportTicket. -func (u UpdateSupportTicket) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "contactDetails", u.ContactDetails) - populate(objectMap, "severity", u.Severity) - populate(objectMap, "status", u.Status) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -}