diff --git a/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md b/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md index 9c2cb5a131d4..8160d69b22be 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md @@ -1,5 +1,22 @@ # Release History +## 0.5.0 (2022-05-13) +### Features Added + +- New function `*Client.GetBuiltIn(context.Context, string, *ClientGetBuiltInOptions) (ClientGetBuiltInResponse, error)` +- New function `*Client.NewListBuiltInsPager(*ClientListBuiltInsOptions) *runtime.Pager[ClientListBuiltInsResponse]` +- New function `*TemplateSpecVersionsClient.NewListBuiltInsPager(string, *TemplateSpecVersionsClientListBuiltInsOptions) *runtime.Pager[TemplateSpecVersionsClientListBuiltInsResponse]` +- New function `*TemplateSpecVersionsClient.GetBuiltIn(context.Context, string, string, *TemplateSpecVersionsClientGetBuiltInOptions) (TemplateSpecVersionsClientGetBuiltInResponse, error)` +- New struct `ClientGetBuiltInOptions` +- New struct `ClientGetBuiltInResponse` +- New struct `ClientListBuiltInsOptions` +- New struct `ClientListBuiltInsResponse` +- New struct `TemplateSpecVersionsClientGetBuiltInOptions` +- New struct `TemplateSpecVersionsClientGetBuiltInResponse` +- New struct `TemplateSpecVersionsClientListBuiltInsOptions` +- New struct `TemplateSpecVersionsClientListBuiltInsResponse` + + ## 0.4.0 (2022-04-18) ### Breaking Changes diff --git a/sdk/resourcemanager/resources/armtemplatespecs/autorest.md b/sdk/resourcemanager/resources/armtemplatespecs/autorest.md index d0718e2af4ca..c629c7172295 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/autorest.md +++ b/sdk/resourcemanager/resources/armtemplatespecs/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/f92aaf88f4c9d1ffb9a014eba196d887a9288c3a/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/f92aaf88f4c9d1ffb9a014eba196d887a9288c3a/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.4.0 +module-version: 0.5.0 package-templatespecs: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armtemplatespecs/go.mod b/sdk/resourcemanager/resources/armtemplatespecs/go.mod index dc99136dfe41..f66338bfb5a0 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/go.mod +++ b/sdk/resourcemanager/resources/armtemplatespecs/go.mod @@ -4,12 +4,12 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.3.0 github.com/stretchr/testify v1.7.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.4.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect diff --git a/sdk/resourcemanager/resources/armtemplatespecs/ze_generated_example_templatespecs_client_test.go b/sdk/resourcemanager/resources/armtemplatespecs/ze_generated_example_templatespecs_client_test.go deleted file mode 100644 index b82d046dc9f2..000000000000 --- a/sdk/resourcemanager/resources/armtemplatespecs/ze_generated_example_templatespecs_client_test.go +++ /dev/null @@ -1,166 +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 armtemplatespecs_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/resources/armtemplatespecs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsCreate.json -func ExampleClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "", - "", - armtemplatespecs.TemplateSpec{ - Location: to.Ptr(""), - Properties: &armtemplatespecs.TemplateSpecProperties{ - Description: to.Ptr(""), - }, - }, - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json -func ExampleClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "", - "", - &armtemplatespecs.ClientUpdateOptions{TemplateSpec: &armtemplatespecs.TemplateSpecUpdateModel{ - Tags: map[string]*string{ - "myTag": to.Ptr("My Value"), - }, - }, - }) - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "", - "", - &armtemplatespecs.ClientGetOptions{Expand: 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsDelete.json -func ExampleClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "", - "", - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json -func ExampleClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armtemplatespecs.ClientListBySubscriptionOptions{Expand: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json -func ExampleClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("", - &armtemplatespecs.ClientListByResourceGroupOptions{Expand: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armtemplatespecs/ze_generated_example_templatespecversions_client_test.go b/sdk/resourcemanager/resources/armtemplatespecs/ze_generated_example_templatespecversions_client_test.go deleted file mode 100644 index 2b4934ede044..000000000000 --- a/sdk/resourcemanager/resources/armtemplatespecs/ze_generated_example_templatespecversions_client_test.go +++ /dev/null @@ -1,152 +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 armtemplatespecs_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/resources/armtemplatespecs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsCreate.json -func ExampleTemplateSpecVersionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewTemplateSpecVersionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "", - "", - "", - armtemplatespecs.TemplateSpecVersion{ - Location: to.Ptr(""), - Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - Description: to.Ptr(""), - MainTemplate: map[string]interface{}{ - "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": map[string]interface{}{}, - "resources": []interface{}{}, - }, - }, - }, - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json -func ExampleTemplateSpecVersionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewTemplateSpecVersionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "", - "", - "", - &armtemplatespecs.TemplateSpecVersionsClientUpdateOptions{TemplateSpecVersionUpdateModel: &armtemplatespecs.TemplateSpecVersionUpdateModel{ - Tags: map[string]*string{ - "myTag": to.Ptr("My Value"), - }, - }, - }) - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json -func ExampleTemplateSpecVersionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewTemplateSpecVersionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "", - "", - "", - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json -func ExampleTemplateSpecVersionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewTemplateSpecVersionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "", - "", - "", - 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/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json -func ExampleTemplateSpecVersionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtemplatespecs.NewTemplateSpecVersionsClient("", 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) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_client.go b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_client.go index 86305b570319..9e4db5ab0303 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_client.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_client.go @@ -95,7 +95,7 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, runtime.MarshalAsJSON(req, templateSpec) @@ -150,7 +150,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -199,7 +199,7 @@ func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName st if options != nil && options.Expand != nil { reqQP.Set("$expand", string(*options.Expand)) } - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -214,6 +214,112 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, return result, nil } +// GetBuiltIn - Gets a built-in Template Spec with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// templateSpecName - Name of the Template Spec. +// options - ClientGetBuiltInOptions contains the optional parameters for the Client.GetBuiltIn method. +func (client *Client) GetBuiltIn(ctx context.Context, templateSpecName string, options *ClientGetBuiltInOptions) (ClientGetBuiltInResponse, error) { + req, err := client.getBuiltInCreateRequest(ctx, templateSpecName, options) + if err != nil { + return ClientGetBuiltInResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientGetBuiltInResponse{}, runtime.NewResponseError(resp) + } + return client.getBuiltInHandleResponse(resp) +} + +// getBuiltInCreateRequest creates the GetBuiltIn request. +func (client *Client) getBuiltInCreateRequest(ctx context.Context, templateSpecName string, options *ClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}" + if templateSpecName == "" { + return nil, errors.New("parameter templateSpecName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateSpecName}", url.PathEscape(templateSpecName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", string(*options.Expand)) + } + reqQP.Set("api-version", "2022-02-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getBuiltInHandleResponse handles the GetBuiltIn response. +func (client *Client) getBuiltInHandleResponse(resp *http.Response) (ClientGetBuiltInResponse, error) { + result := ClientGetBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpec); err != nil { + return ClientGetBuiltInResponse{}, err + } + return result, nil +} + +// NewListBuiltInsPager - Lists built-in Template Specs. +// If the operation fails it returns an *azcore.ResponseError type. +// options - ClientListBuiltInsOptions contains the optional parameters for the Client.ListBuiltIns method. +func (client *Client) NewListBuiltInsPager(options *ClientListBuiltInsOptions) *runtime.Pager[ClientListBuiltInsResponse] { + return runtime.NewPager(runtime.PageProcessor[ClientListBuiltInsResponse]{ + More: func(page ClientListBuiltInsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListBuiltInsResponse) (ClientListBuiltInsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBuiltInsCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListBuiltInsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClientListBuiltInsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListBuiltInsResponse{}, runtime.NewResponseError(resp) + } + return client.listBuiltInsHandleResponse(resp) + }, + }) +} + +// listBuiltInsCreateRequest creates the ListBuiltIns request. +func (client *Client) listBuiltInsCreateRequest(ctx context.Context, options *ClientListBuiltInsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Resources/builtInTemplateSpecs/" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", string(*options.Expand)) + } + reqQP.Set("api-version", "2022-02-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBuiltInsHandleResponse handles the ListBuiltIns response. +func (client *Client) listBuiltInsHandleResponse(resp *http.Response) (ClientListBuiltInsResponse, error) { + result := ClientListBuiltInsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil { + return ClientListBuiltInsResponse{}, err + } + return result, nil +} + // NewListByResourceGroupPager - Lists all the Template Specs within the specified resource group. // If the operation fails it returns an *azcore.ResponseError type. // resourceGroupName - The name of the resource group. The name is case insensitive. @@ -265,7 +371,7 @@ func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, reso if options != nil && options.Expand != nil { reqQP.Set("$expand", string(*options.Expand)) } - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -326,7 +432,7 @@ func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, optio if options != nil && options.Expand != nil { reqQP.Set("$expand", string(*options.Expand)) } - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -381,7 +487,7 @@ func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") if options != nil && options.TemplateSpec != nil { diff --git a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_constants.go b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_constants.go index efccb07cbfc0..ffb0cd71c55f 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_constants.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_constants.go @@ -10,7 +10,7 @@ package armtemplatespecs const ( moduleName = "armtemplatespecs" - moduleVersion = "v0.4.0" + moduleVersion = "v0.5.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_models.go b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_models.go index fcab3c20f5b0..74c1b59e511e 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_models.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_models.go @@ -35,12 +35,24 @@ type ClientDeleteOptions struct { // placeholder for future optional parameters } +// ClientGetBuiltInOptions contains the optional parameters for the Client.GetBuiltIn method. +type ClientGetBuiltInOptions struct { + // Allows for expansion of additional Template Spec details in the response. Optional. + Expand *TemplateSpecExpandKind +} + // ClientGetOptions contains the optional parameters for the Client.Get method. type ClientGetOptions struct { // Allows for expansion of additional Template Spec details in the response. Optional. Expand *TemplateSpecExpandKind } +// ClientListBuiltInsOptions contains the optional parameters for the Client.ListBuiltIns method. +type ClientListBuiltInsOptions struct { + // Allows for expansion of additional Template Spec details in the response. Optional. + Expand *TemplateSpecExpandKind +} + // ClientListByResourceGroupOptions contains the optional parameters for the Client.ListByResourceGroup method. type ClientListByResourceGroupOptions struct { // Allows for expansion of additional Template Spec details in the response. Optional. @@ -276,11 +288,23 @@ type TemplateSpecVersionsClientDeleteOptions struct { // placeholder for future optional parameters } +// TemplateSpecVersionsClientGetBuiltInOptions contains the optional parameters for the TemplateSpecVersionsClient.GetBuiltIn +// method. +type TemplateSpecVersionsClientGetBuiltInOptions struct { + // placeholder for future optional parameters +} + // TemplateSpecVersionsClientGetOptions contains the optional parameters for the TemplateSpecVersionsClient.Get method. type TemplateSpecVersionsClientGetOptions struct { // placeholder for future optional parameters } +// TemplateSpecVersionsClientListBuiltInsOptions contains the optional parameters for the TemplateSpecVersionsClient.ListBuiltIns +// method. +type TemplateSpecVersionsClientListBuiltInsOptions struct { + // placeholder for future optional parameters +} + // TemplateSpecVersionsClientListOptions contains the optional parameters for the TemplateSpecVersionsClient.List method. type TemplateSpecVersionsClientListOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_response_types.go b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_response_types.go index 0021b15d335e..8b94beceb060 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_response_types.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_response_types.go @@ -18,11 +18,21 @@ type ClientDeleteResponse struct { // placeholder for future response values } +// ClientGetBuiltInResponse contains the response from method Client.GetBuiltIn. +type ClientGetBuiltInResponse struct { + TemplateSpec +} + // ClientGetResponse contains the response from method Client.Get. type ClientGetResponse struct { TemplateSpec } +// ClientListBuiltInsResponse contains the response from method Client.ListBuiltIns. +type ClientListBuiltInsResponse struct { + ListResult +} + // ClientListByResourceGroupResponse contains the response from method Client.ListByResourceGroup. type ClientListByResourceGroupResponse struct { ListResult @@ -48,11 +58,21 @@ type TemplateSpecVersionsClientDeleteResponse struct { // placeholder for future response values } +// TemplateSpecVersionsClientGetBuiltInResponse contains the response from method TemplateSpecVersionsClient.GetBuiltIn. +type TemplateSpecVersionsClientGetBuiltInResponse struct { + TemplateSpecVersion +} + // TemplateSpecVersionsClientGetResponse contains the response from method TemplateSpecVersionsClient.Get. type TemplateSpecVersionsClientGetResponse struct { TemplateSpecVersion } +// TemplateSpecVersionsClientListBuiltInsResponse contains the response from method TemplateSpecVersionsClient.ListBuiltIns. +type TemplateSpecVersionsClientListBuiltInsResponse struct { + TemplateSpecVersionsListResult +} + // TemplateSpecVersionsClientListResponse contains the response from method TemplateSpecVersionsClient.List. type TemplateSpecVersionsClientListResponse struct { TemplateSpecVersionsListResult diff --git a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_templatespecversions_client.go b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_templatespecversions_client.go index caf8e5f3d6a7..de7482dffac9 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_templatespecversions_client.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/zz_generated_templatespecversions_client.go @@ -101,7 +101,7 @@ func (client *TemplateSpecVersionsClient) createOrUpdateCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, runtime.MarshalAsJSON(req, templateSpecVersionModel) @@ -162,7 +162,7 @@ func (client *TemplateSpecVersionsClient) deleteCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -214,7 +214,7 @@ func (client *TemplateSpecVersionsClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -229,6 +229,58 @@ func (client *TemplateSpecVersionsClient) getHandleResponse(resp *http.Response) return result, nil } +// GetBuiltIn - Gets a Template Spec version from a specific built-in Template Spec. +// If the operation fails it returns an *azcore.ResponseError type. +// templateSpecName - Name of the Template Spec. +// templateSpecVersion - The version of the Template Spec. +// options - TemplateSpecVersionsClientGetBuiltInOptions contains the optional parameters for the TemplateSpecVersionsClient.GetBuiltIn +// method. +func (client *TemplateSpecVersionsClient) GetBuiltIn(ctx context.Context, templateSpecName string, templateSpecVersion string, options *TemplateSpecVersionsClientGetBuiltInOptions) (TemplateSpecVersionsClientGetBuiltInResponse, error) { + req, err := client.getBuiltInCreateRequest(ctx, templateSpecName, templateSpecVersion, options) + if err != nil { + return TemplateSpecVersionsClientGetBuiltInResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TemplateSpecVersionsClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TemplateSpecVersionsClientGetBuiltInResponse{}, runtime.NewResponseError(resp) + } + return client.getBuiltInHandleResponse(resp) +} + +// getBuiltInCreateRequest creates the GetBuiltIn request. +func (client *TemplateSpecVersionsClient) getBuiltInCreateRequest(ctx context.Context, templateSpecName string, templateSpecVersion string, options *TemplateSpecVersionsClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions/{templateSpecVersion}" + if templateSpecName == "" { + return nil, errors.New("parameter templateSpecName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateSpecName}", url.PathEscape(templateSpecName)) + if templateSpecVersion == "" { + return nil, errors.New("parameter templateSpecVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateSpecVersion}", url.PathEscape(templateSpecVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-02-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getBuiltInHandleResponse handles the GetBuiltIn response. +func (client *TemplateSpecVersionsClient) getBuiltInHandleResponse(resp *http.Response) (TemplateSpecVersionsClientGetBuiltInResponse, error) { + result := TemplateSpecVersionsClientGetBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpecVersion); err != nil { + return TemplateSpecVersionsClientGetBuiltInResponse{}, err + } + return result, nil +} + // NewListPager - Lists all the Template Spec versions in the specified Template Spec. // If the operation fails it returns an *azcore.ResponseError type. // resourceGroupName - The name of the resource group. The name is case insensitive. @@ -283,7 +335,7 @@ func (client *TemplateSpecVersionsClient) listCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -298,6 +350,66 @@ func (client *TemplateSpecVersionsClient) listHandleResponse(resp *http.Response return result, nil } +// NewListBuiltInsPager - Lists all the Template Spec versions in the specified built-in Template Spec. +// If the operation fails it returns an *azcore.ResponseError type. +// templateSpecName - Name of the Template Spec. +// options - TemplateSpecVersionsClientListBuiltInsOptions contains the optional parameters for the TemplateSpecVersionsClient.ListBuiltIns +// method. +func (client *TemplateSpecVersionsClient) NewListBuiltInsPager(templateSpecName string, options *TemplateSpecVersionsClientListBuiltInsOptions) *runtime.Pager[TemplateSpecVersionsClientListBuiltInsResponse] { + return runtime.NewPager(runtime.PageProcessor[TemplateSpecVersionsClientListBuiltInsResponse]{ + More: func(page TemplateSpecVersionsClientListBuiltInsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TemplateSpecVersionsClientListBuiltInsResponse) (TemplateSpecVersionsClientListBuiltInsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBuiltInsCreateRequest(ctx, templateSpecName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return TemplateSpecVersionsClientListBuiltInsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TemplateSpecVersionsClientListBuiltInsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TemplateSpecVersionsClientListBuiltInsResponse{}, runtime.NewResponseError(resp) + } + return client.listBuiltInsHandleResponse(resp) + }, + }) +} + +// listBuiltInsCreateRequest creates the ListBuiltIns request. +func (client *TemplateSpecVersionsClient) listBuiltInsCreateRequest(ctx context.Context, templateSpecName string, options *TemplateSpecVersionsClientListBuiltInsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Resources/builtInTemplateSpecs/{templateSpecName}/versions" + if templateSpecName == "" { + return nil, errors.New("parameter templateSpecName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateSpecName}", url.PathEscape(templateSpecName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-02-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBuiltInsHandleResponse handles the ListBuiltIns response. +func (client *TemplateSpecVersionsClient) listBuiltInsHandleResponse(resp *http.Response) (TemplateSpecVersionsClientListBuiltInsResponse, error) { + result := TemplateSpecVersionsClientListBuiltInsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpecVersionsListResult); err != nil { + return TemplateSpecVersionsClientListBuiltInsResponse{}, err + } + return result, nil +} + // Update - Updates Template Spec Version tags with specified values. // If the operation fails it returns an *azcore.ResponseError type. // resourceGroupName - The name of the resource group. The name is case insensitive. @@ -344,7 +456,7 @@ func (client *TemplateSpecVersionsClient) updateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-02-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") if options != nil && options.TemplateSpecVersionUpdateModel != nil {