diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/CHANGELOG.md b/sdk/resourcemanager/databoundaries/armdataboundaries/CHANGELOG.md index 77c8ce7f50b4..3092842b83ba 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/CHANGELOG.md +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History +## 1.0.0 (2025-04-28) +### Features Added + +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `NewOperationsClient(azcore.TokenCredential, *arm.ClientOptions) (*OperationsClient, error)` +- New function `*OperationsClient.NewListPager(*OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]` + + ## 0.1.0 (2024-10-21) ### Other Changes diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md b/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md index fad32155fb5b..f92a2f9dba3b 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/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.1.0 +module-version: 1.0.0 package-databoundaries: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/client.go b/sdk/resourcemanager/databoundaries/armdataboundaries/client.go index 3402d367c928..679552129705 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/client.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -70,7 +67,7 @@ func (client *Client) GetScope(ctx context.Context, scope string, defaultParam D } // getScopeCreateRequest creates the GetScope request. -func (client *Client) getScopeCreateRequest(ctx context.Context, scope string, defaultParam DefaultName, options *ClientGetScopeOptions) (*policy.Request, error) { +func (client *Client) getScopeCreateRequest(ctx context.Context, scope string, defaultParam DefaultName, _ *ClientGetScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/dataBoundaries/{default}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if defaultParam == "" { @@ -126,7 +123,7 @@ func (client *Client) GetTenant(ctx context.Context, defaultParam DefaultName, o } // getTenantCreateRequest creates the GetTenant request. -func (client *Client) getTenantCreateRequest(ctx context.Context, defaultParam DefaultName, options *ClientGetTenantOptions) (*policy.Request, error) { +func (client *Client) getTenantCreateRequest(ctx context.Context, defaultParam DefaultName, _ *ClientGetTenantOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/dataBoundaries/{default}" if defaultParam == "" { return nil, errors.New("parameter defaultParam cannot be empty") @@ -182,7 +179,7 @@ func (client *Client) Put(ctx context.Context, defaultParam DefaultName, dataBou } // putCreateRequest creates the Put request. -func (client *Client) putCreateRequest(ctx context.Context, defaultParam DefaultName, dataBoundaryDefinition DataBoundaryDefinition, options *ClientPutOptions) (*policy.Request, error) { +func (client *Client) putCreateRequest(ctx context.Context, defaultParam DefaultName, dataBoundaryDefinition DataBoundaryDefinition, _ *ClientPutOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/dataBoundaries/{default}" if defaultParam == "" { return nil, errors.New("parameter defaultParam cannot be empty") diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/client_example_test.go b/sdk/resourcemanager/databoundaries/armdataboundaries/client_example_test.go deleted file mode 100644 index e702cac12b62..000000000000 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/client_example_test.go +++ /dev/null @@ -1,107 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataboundaries_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/databoundaries/armdataboundaries" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json -func ExampleClient_Put() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataboundaries.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Put(ctx, armdataboundaries.DefaultNameDefault, armdataboundaries.DataBoundaryDefinition{ - Properties: &armdataboundaries.DataBoundaryProperties{ - DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - }, - }, 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.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"), - // Properties: &armdataboundaries.DataBoundaryProperties{ - // DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - // ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json -func ExampleClient_GetTenant() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataboundaries.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetTenant(ctx, armdataboundaries.DefaultNameDefault, 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.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"), - // Properties: &armdataboundaries.DataBoundaryProperties{ - // DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - // ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json -func ExampleClient_GetScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataboundaries.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetScope(ctx, "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group", armdataboundaries.DefaultNameDefault, 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.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"), - // Properties: &armdataboundaries.DataBoundaryProperties{ - // DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - // ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded), - // }, - // } -} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go b/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go index e4a53e320d26..42a2b3258190 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -39,3 +36,10 @@ func (c *ClientFactory) NewClient() *Client { internal: c.internal, } } + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go b/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go index 61798902032e..43fa3ac9ba99 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,7 +7,7 @@ package armdataboundaries const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries" - moduleVersion = "v0.1.0" + moduleVersion = "v1.0.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/internal.go b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/internal.go index be04ff43d678..e3def49261ba 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/internal.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -14,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/operations_server.go b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/operations_server.go new file mode 100644 index 000000000000..20f239521e99 --- /dev/null +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/operations_server.go @@ -0,0 +1,118 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries" + "net/http" +) + +// OperationsServer is a fake server for instances of the armdataboundaries.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armdataboundaries.OperationsClientListOptions) (resp azfake.PagerResponder[armdataboundaries.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armdataboundaries.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataboundaries.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armdataboundaries.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armdataboundaries.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataboundaries.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server.go b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server.go index 39000ba657d1..b971306d11ae 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -57,25 +54,44 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "Client.GetScope": - resp, err = s.dispatchGetScope(req) - case "Client.GetTenant": - resp, err = s.dispatchGetTenant(req) - case "Client.Put": - resp, err = s.dispatchPut(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.GetScope": + res.resp, res.err = s.dispatchGetScope(req) + case "Client.GetTenant": + res.resp, res.err = s.dispatchGetTenant(req) + case "Client.Put": + res.resp, res.err = s.dispatchPut(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServerTransport) dispatchGetScope(req *http.Request) (*http.Response, error) { @@ -190,3 +206,9 @@ func (s *ServerTransport) dispatchPut(req *http.Request) (*http.Response, error) } return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go index b324dbd1c1c9..37b3d13d05ee 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,7 +16,11 @@ import ( // ServerFactory is a fake server for instances of the armdataboundaries.ClientFactory type. type ServerFactory struct { + // Server contains the fakes for client Client Server Server + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -34,9 +35,10 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armdataboundaries.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trServer *ServerTransport + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trOperationsServer *OperationsServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -55,6 +57,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "Client": initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) resp, err = s.trServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod b/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod index 6a03ff09e5b1..ce2fe05824d8 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armd go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum b/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -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-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/models.go b/sdk/resourcemanager/databoundaries/armdataboundaries/models.go index f1453e79d12d..2c74e95a26a6 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/models.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/models_serde.go b/sdk/resourcemanager/databoundaries/armdataboundaries/models_serde.go index 96ddbb453cff..d608b4d4febf 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/models_serde.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/operations_client.go b/sdk/resourcemanager/databoundaries/armdataboundaries/operations_client.go new file mode 100644 index 000000000000..02d8beb7d8d0 --- /dev/null +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/operations_client.go @@ -0,0 +1,85 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdataboundaries + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - Lists all of the available Microsoft.Resources REST API operations. +// +// Generated from API version 2024-08-01 +// - 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 { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Resources/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/options.go b/sdk/resourcemanager/databoundaries/armdataboundaries/options.go index e5b89d5b02a6..adaa74714930 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/options.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/responses.go b/sdk/resourcemanager/databoundaries/armdataboundaries/responses.go index 9b7cbbc5c160..d758aeece98d 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/responses.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/time_rfc3339.go b/sdk/resourcemanager/databoundaries/armdataboundaries/time_rfc3339.go index ce6e2dfaa23f..10628c0ed15b 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/time_rfc3339.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -60,6 +57,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } tzOffset := tzOffsetRegex.Match(data) hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") var layout string diff --git a/sdk/resourcemanager/deployments/bicep/CHANGELOG.md b/sdk/resourcemanager/deployments/bicep/CHANGELOG.md new file mode 100644 index 000000000000..631c67588d85 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-04-28) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/bicep` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/bicep/LICENSE.txt b/sdk/resourcemanager/deployments/bicep/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/bicep/README.md b/sdk/resourcemanager/deployments/bicep/README.md new file mode 100644 index 000000000000..93a969e2b579 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/README.md @@ -0,0 +1,90 @@ +# Azure Deployments Module for Go + +The `bicep` module provides operations for working with Azure Deployments. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/deployments/bicep) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Deployments module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/bicep +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Deployments. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +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). + +## Client Factory + +Azure Deployments module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := bicep.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 { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := bicep.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.NewDecompileClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Deployments` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/bicep/autorest.md b/sdk/resourcemanager/deployments/bicep/autorest.md new file mode 100644 index 000000000000..2cd27cc762d3 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/bicep/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/bicep/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/bicep/build.go b/sdk/resourcemanager/deployments/bicep/build.go new file mode 100644 index 000000000000..a983fd3c9984 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/deployments/bicep + +package bicep diff --git a/sdk/resourcemanager/deployments/bicep/ci.yml b/sdk/resourcemanager/deployments/bicep/ci.yml new file mode 100644 index 000000000000..649a694dcb77 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/bicep/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/bicep/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/deployments/bicep' diff --git a/sdk/resourcemanager/deployments/bicep/client_factory.go b/sdk/resourcemanager/deployments/bicep/client_factory.go new file mode 100644 index 000000000000..4ae2c5338806 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/client_factory.go @@ -0,0 +1,42 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package bicep + +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 + internal *arm.Client +} + +// 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. The value must be an UUID. +// - 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) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewDecompileClient creates a new instance of DecompileClient. +func (c *ClientFactory) NewDecompileClient() *DecompileClient { + return &DecompileClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/deployments/bicep/constants.go b/sdk/resourcemanager/deployments/bicep/constants.go new file mode 100644 index 000000000000..b1dac5c4ee4b --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/constants.go @@ -0,0 +1,11 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package bicep + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/bicep" + moduleVersion = "v0.1.0" +) diff --git a/sdk/resourcemanager/deployments/bicep/decompile_client.go b/sdk/resourcemanager/deployments/bicep/decompile_client.go new file mode 100644 index 000000000000..d527a7fe7518 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/decompile_client.go @@ -0,0 +1,99 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package bicep + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DecompileClient contains the methods for the Decompile group. +// Don't use this type directly, use NewDecompileClient() instead. +type DecompileClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDecompileClient creates a new instance of DecompileClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDecompileClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DecompileClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DecompileClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Bicep - Decompiles an ARM json template into a Bicep template +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - decompileOperationRequest - Decompile operation request supplied to the operation. +// - options - DecompileClientBicepOptions contains the optional parameters for the DecompileClient.Bicep method. +func (client *DecompileClient) Bicep(ctx context.Context, decompileOperationRequest DecompileOperationRequest, options *DecompileClientBicepOptions) (DecompileClientBicepResponse, error) { + var err error + const operationName = "DecompileClient.Bicep" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.bicepCreateRequest(ctx, decompileOperationRequest, options) + if err != nil { + return DecompileClientBicepResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DecompileClientBicepResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DecompileClientBicepResponse{}, err + } + resp, err := client.bicepHandleResponse(httpResp) + return resp, err +} + +// bicepCreateRequest creates the Bicep request. +func (client *DecompileClient) bicepCreateRequest(ctx context.Context, decompileOperationRequest DecompileOperationRequest, _ *DecompileClientBicepOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/decompileBicep" + if client.subscriptionID == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, decompileOperationRequest); err != nil { + return nil, err + } + return req, nil +} + +// bicepHandleResponse handles the Bicep response. +func (client *DecompileClient) bicepHandleResponse(resp *http.Response) (DecompileClientBicepResponse, error) { + result := DecompileClientBicepResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DecompileOperationSuccessResponse); err != nil { + return DecompileClientBicepResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/deployments/bicep/fake/decompile_server.go b/sdk/resourcemanager/deployments/bicep/fake/decompile_server.go new file mode 100644 index 000000000000..3bcfa224726b --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/fake/decompile_server.go @@ -0,0 +1,117 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/bicep" + "net/http" + "regexp" +) + +// DecompileServer is a fake server for instances of the bicep.DecompileClient type. +type DecompileServer struct { + // Bicep is the fake for method DecompileClient.Bicep + // HTTP status codes to indicate success: http.StatusOK + Bicep func(ctx context.Context, decompileOperationRequest bicep.DecompileOperationRequest, options *bicep.DecompileClientBicepOptions) (resp azfake.Responder[bicep.DecompileClientBicepResponse], errResp azfake.ErrorResponder) +} + +// NewDecompileServerTransport creates a new instance of DecompileServerTransport with the provided implementation. +// The returned DecompileServerTransport instance is connected to an instance of bicep.DecompileClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDecompileServerTransport(srv *DecompileServer) *DecompileServerTransport { + return &DecompileServerTransport{srv: srv} +} + +// DecompileServerTransport connects instances of bicep.DecompileClient to instances of DecompileServer. +// Don't use this type directly, use NewDecompileServerTransport instead. +type DecompileServerTransport struct { + srv *DecompileServer +} + +// Do implements the policy.Transporter interface for DecompileServerTransport. +func (d *DecompileServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return d.dispatchToMethodFake(req, method) +} + +func (d *DecompileServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if decompileServerTransportInterceptor != nil { + res.resp, res.err, intercepted = decompileServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DecompileClient.Bicep": + res.resp, res.err = d.dispatchBicep(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (d *DecompileServerTransport) dispatchBicep(req *http.Request) (*http.Response, error) { + if d.srv.Bicep == nil { + return nil, &nonRetriableError{errors.New("fake for method Bicep not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/decompileBicep` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[bicep.DecompileOperationRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Bicep(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DecompileOperationSuccessResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to DecompileServerTransport +var decompileServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/deployments/bicep/fake/internal.go b/sdk/resourcemanager/deployments/bicep/fake/internal.go new file mode 100644 index 000000000000..9fc4ea581dca --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/fake/internal.go @@ -0,0 +1,30 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import "net/http" + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} diff --git a/sdk/resourcemanager/deployments/bicep/fake/server_factory.go b/sdk/resourcemanager/deployments/bicep/fake/server_factory.go new file mode 100644 index 000000000000..4c0e7da09c56 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/fake/server_factory.go @@ -0,0 +1,73 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the bicep.ClientFactory type. +type ServerFactory struct { + // DecompileServer contains the fakes for client DecompileClient + DecompileServer DecompileServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of bicep.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of bicep.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trDecompileServer *DecompileServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "DecompileClient": + initServer(s, &s.trDecompileServer, func() *DecompileServerTransport { return NewDecompileServerTransport(&s.srv.DecompileServer) }) + resp, err = s.trDecompileServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/deployments/bicep/go.mod b/sdk/resourcemanager/deployments/bicep/go.mod new file mode 100644 index 000000000000..841c11a5a8ec --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/bicep + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/deployments/bicep/go.sum b/sdk/resourcemanager/deployments/bicep/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/deployments/bicep/models.go b/sdk/resourcemanager/deployments/bicep/models.go new file mode 100644 index 000000000000..facaaa8c4dae --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/models.go @@ -0,0 +1,28 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package bicep + +// DecompileOperationRequest - The body of the request for the decompileBicep operation +type DecompileOperationRequest struct { + // REQUIRED; The ARM json template to be decompiled into a Bicep file + Template *string +} + +// DecompileOperationSuccessResponse - The response of the decompileBicep operation +type DecompileOperationSuccessResponse struct { + // REQUIRED; The file path to the main Bicep file generated from the decompiled ARM json template. + EntryPoint *string + + // REQUIRED; An array of key-value pairs containing the entryPoint string as the key for the Bicep file decompiled from the + // ARM json template + Files []*FileDefinition +} + +// FileDefinition - The definition of a file along with its contents +type FileDefinition struct { + Contents *string + Path *string +} diff --git a/sdk/resourcemanager/deployments/bicep/models_serde.go b/sdk/resourcemanager/deployments/bicep/models_serde.go new file mode 100644 index 000000000000..8a7a63be1522 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/models_serde.go @@ -0,0 +1,122 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package bicep + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type DecompileOperationRequest. +func (d DecompileOperationRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "template", d.Template) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DecompileOperationRequest. +func (d *DecompileOperationRequest) 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 "template": + err = unpopulate(val, "Template", &d.Template) + 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 DecompileOperationSuccessResponse. +func (d DecompileOperationSuccessResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "entryPoint", d.EntryPoint) + populate(objectMap, "files", d.Files) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DecompileOperationSuccessResponse. +func (d *DecompileOperationSuccessResponse) 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 "entryPoint": + err = unpopulate(val, "EntryPoint", &d.EntryPoint) + delete(rawMsg, key) + case "files": + err = unpopulate(val, "Files", &d.Files) + 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 FileDefinition. +func (f FileDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contents", f.Contents) + populate(objectMap, "path", f.Path) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileDefinition. +func (f *FileDefinition) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contents": + err = unpopulate(val, "Contents", &f.Contents) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &f.Path) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, 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 || string(data) == "null" { + 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/deployments/bicep/options.go b/sdk/resourcemanager/deployments/bicep/options.go new file mode 100644 index 000000000000..5d83a6223179 --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/options.go @@ -0,0 +1,11 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package bicep + +// DecompileClientBicepOptions contains the optional parameters for the DecompileClient.Bicep method. +type DecompileClientBicepOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/deployments/bicep/responses.go b/sdk/resourcemanager/deployments/bicep/responses.go new file mode 100644 index 000000000000..41b1e9ce17bf --- /dev/null +++ b/sdk/resourcemanager/deployments/bicep/responses.go @@ -0,0 +1,12 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package bicep + +// DecompileClientBicepResponse contains the response from method DecompileClient.Bicep. +type DecompileClientBicepResponse struct { + // The response of the decompileBicep operation + DecompileOperationSuccessResponse +} diff --git a/sdk/resourcemanager/deployments/deployments/CHANGELOG.md b/sdk/resourcemanager/deployments/deployments/CHANGELOG.md new file mode 100644 index 000000000000..c30e2756b6cd --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-04-28) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deployments` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deployments/LICENSE.txt b/sdk/resourcemanager/deployments/deployments/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deployments/README.md b/sdk/resourcemanager/deployments/deployments/README.md new file mode 100644 index 000000000000..9d43c0ad46b8 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/README.md @@ -0,0 +1,90 @@ +# Azure Deployments Module for Go + +The `deployments` module provides operations for working with Azure Deployments. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/deployments/deployments) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Deployments module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deployments +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Deployments. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +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). + +## Client Factory + +Azure Deployments module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := deployments.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 { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := deployments.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() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Deployments` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deployments/autorest.md b/sdk/resourcemanager/deployments/deployments/autorest.md new file mode 100644 index 000000000000..a486e1308a8a --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/deployments/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/deployments/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deployments/build.go b/sdk/resourcemanager/deployments/deployments/build.go new file mode 100644 index 000000000000..df93cddedf0d --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/deployments/deployments + +package deployments diff --git a/sdk/resourcemanager/deployments/deployments/ci.yml b/sdk/resourcemanager/deployments/deployments/ci.yml new file mode 100644 index 000000000000..40c3e27b227c --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/deployments/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/deployments/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/deployments/deployments' diff --git a/sdk/resourcemanager/resources/armresources/deployments_client.go b/sdk/resourcemanager/deployments/deployments/client.go similarity index 66% rename from sdk/resourcemanager/resources/armresources/deployments_client.go rename to sdk/resourcemanager/deployments/deployments/client.go index 3ccd0a813314..8fc8c93f3103 100644 --- a/sdk/resourcemanager/resources/armresources/deployments_client.go +++ b/sdk/resourcemanager/deployments/deployments/client.go @@ -1,12 +1,9 @@ -//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. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package armresources +package deployments import ( "context" @@ -21,23 +18,23 @@ import ( "strings" ) -// DeploymentsClient contains the methods for the Deployments group. -// Don't use this type directly, use NewDeploymentsClient() instead. -type DeploymentsClient struct { +// Client contains the methods for the Deployments group. +// Don't use this type directly, use NewClient() instead. +type Client struct { internal *arm.Client subscriptionID string } -// NewDeploymentsClient creates a new instance of DeploymentsClient with the specified values. +// NewClient creates a new instance of Client with the specified values. // - subscriptionID - The Microsoft Azure subscription ID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentsClient, error) { +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } - client := &DeploymentsClient{ + client := &Client{ subscriptionID: subscriptionID, internal: cl, } @@ -47,41 +44,40 @@ func NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredenti // CalculateTemplateHash - Calculate the hash of the given template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - templateParam - The template provided to calculate hash. -// - options - DeploymentsClientCalculateTemplateHashOptions contains the optional parameters for the DeploymentsClient.CalculateTemplateHash -// method. -func (client *DeploymentsClient) CalculateTemplateHash(ctx context.Context, templateParam any, options *DeploymentsClientCalculateTemplateHashOptions) (DeploymentsClientCalculateTemplateHashResponse, error) { +// - options - ClientCalculateTemplateHashOptions contains the optional parameters for the Client.CalculateTemplateHash method. +func (client *Client) CalculateTemplateHash(ctx context.Context, templateParam any, options *ClientCalculateTemplateHashOptions) (ClientCalculateTemplateHashResponse, error) { var err error - const operationName = "DeploymentsClient.CalculateTemplateHash" + const operationName = "Client.CalculateTemplateHash" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.calculateTemplateHashCreateRequest(ctx, templateParam, options) if err != nil { - return DeploymentsClientCalculateTemplateHashResponse{}, err + return ClientCalculateTemplateHashResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCalculateTemplateHashResponse{}, err + return ClientCalculateTemplateHashResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCalculateTemplateHashResponse{}, err + return ClientCalculateTemplateHashResponse{}, err } resp, err := client.calculateTemplateHashHandleResponse(httpResp) return resp, err } // calculateTemplateHashCreateRequest creates the CalculateTemplateHash request. -func (client *DeploymentsClient) calculateTemplateHashCreateRequest(ctx context.Context, templateParam any, options *DeploymentsClientCalculateTemplateHashOptions) (*policy.Request, error) { +func (client *Client) calculateTemplateHashCreateRequest(ctx context.Context, templateParam any, _ *ClientCalculateTemplateHashOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/calculateTemplateHash" req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, templateParam); err != nil { @@ -91,10 +87,10 @@ func (client *DeploymentsClient) calculateTemplateHashCreateRequest(ctx context. } // calculateTemplateHashHandleResponse handles the CalculateTemplateHash response. -func (client *DeploymentsClient) calculateTemplateHashHandleResponse(resp *http.Response) (DeploymentsClientCalculateTemplateHashResponse, error) { - result := DeploymentsClientCalculateTemplateHashResponse{} +func (client *Client) calculateTemplateHashHandleResponse(resp *http.Response) (ClientCalculateTemplateHashResponse, error) { + result := ClientCalculateTemplateHashResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.TemplateHashResult); err != nil { - return DeploymentsClientCalculateTemplateHashResponse{}, err + return ClientCalculateTemplateHashResponse{}, err } return result, nil } @@ -104,33 +100,33 @@ func (client *DeploymentsClient) calculateTemplateHashHandleResponse(resp *http. // currently running template deployment and leaves the resource group partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCancelOptions contains the optional parameters for the DeploymentsClient.Cancel method. -func (client *DeploymentsClient) Cancel(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientCancelOptions) (DeploymentsClientCancelResponse, error) { +// - options - ClientCancelOptions contains the optional parameters for the Client.Cancel method. +func (client *Client) Cancel(ctx context.Context, resourceGroupName string, deploymentName string, options *ClientCancelOptions) (ClientCancelResponse, error) { var err error - const operationName = "DeploymentsClient.Cancel" + const operationName = "Client.Cancel" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.cancelCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { - return DeploymentsClientCancelResponse{}, err + return ClientCancelResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCancelResponse{}, err + return ClientCancelResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCancelResponse{}, err + return ClientCancelResponse{}, err } - return DeploymentsClientCancelResponse{}, nil + return ClientCancelResponse{}, nil } // cancelCreateRequest creates the Cancel request. -func (client *DeploymentsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientCancelOptions) (*policy.Request, error) { +func (client *Client) cancelCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *ClientCancelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -149,7 +145,7 @@ func (client *DeploymentsClient) cancelCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -160,34 +156,34 @@ func (client *DeploymentsClient) cancelCreateRequest(ctx context.Context, resour // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCancelAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtManagementGroupScope +// - options - ClientCancelAtManagementGroupScopeOptions contains the optional parameters for the Client.CancelAtManagementGroupScope // method. -func (client *DeploymentsClient) CancelAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientCancelAtManagementGroupScopeOptions) (DeploymentsClientCancelAtManagementGroupScopeResponse, error) { +func (client *Client) CancelAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *ClientCancelAtManagementGroupScopeOptions) (ClientCancelAtManagementGroupScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CancelAtManagementGroupScope" + const operationName = "Client.CancelAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.cancelAtManagementGroupScopeCreateRequest(ctx, groupID, deploymentName, options) if err != nil { - return DeploymentsClientCancelAtManagementGroupScopeResponse{}, err + return ClientCancelAtManagementGroupScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCancelAtManagementGroupScopeResponse{}, err + return ClientCancelAtManagementGroupScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCancelAtManagementGroupScopeResponse{}, err + return ClientCancelAtManagementGroupScopeResponse{}, err } - return DeploymentsClientCancelAtManagementGroupScopeResponse{}, nil + return ClientCancelAtManagementGroupScopeResponse{}, nil } // cancelAtManagementGroupScopeCreateRequest creates the CancelAtManagementGroupScope request. -func (client *DeploymentsClient) cancelAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientCancelAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) cancelAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, _ *ClientCancelAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -202,7 +198,7 @@ func (client *DeploymentsClient) cancelAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -213,34 +209,33 @@ func (client *DeploymentsClient) cancelAtManagementGroupScopeCreateRequest(ctx c // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCancelAtScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtScope -// method. -func (client *DeploymentsClient) CancelAtScope(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientCancelAtScopeOptions) (DeploymentsClientCancelAtScopeResponse, error) { +// - options - ClientCancelAtScopeOptions contains the optional parameters for the Client.CancelAtScope method. +func (client *Client) CancelAtScope(ctx context.Context, scope string, deploymentName string, options *ClientCancelAtScopeOptions) (ClientCancelAtScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CancelAtScope" + const operationName = "Client.CancelAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.cancelAtScopeCreateRequest(ctx, scope, deploymentName, options) if err != nil { - return DeploymentsClientCancelAtScopeResponse{}, err + return ClientCancelAtScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCancelAtScopeResponse{}, err + return ClientCancelAtScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCancelAtScopeResponse{}, err + return ClientCancelAtScopeResponse{}, err } - return DeploymentsClientCancelAtScopeResponse{}, nil + return ClientCancelAtScopeResponse{}, nil } // cancelAtScopeCreateRequest creates the CancelAtScope request. -func (client *DeploymentsClient) cancelAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientCancelAtScopeOptions) (*policy.Request, error) { +func (client *Client) cancelAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, _ *ClientCancelAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -252,7 +247,7 @@ func (client *DeploymentsClient) cancelAtScopeCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -263,33 +258,33 @@ func (client *DeploymentsClient) cancelAtScopeCreateRequest(ctx context.Context, // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCancelAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtSubscriptionScope +// - options - ClientCancelAtSubscriptionScopeOptions contains the optional parameters for the Client.CancelAtSubscriptionScope // method. -func (client *DeploymentsClient) CancelAtSubscriptionScope(ctx context.Context, deploymentName string, options *DeploymentsClientCancelAtSubscriptionScopeOptions) (DeploymentsClientCancelAtSubscriptionScopeResponse, error) { +func (client *Client) CancelAtSubscriptionScope(ctx context.Context, deploymentName string, options *ClientCancelAtSubscriptionScopeOptions) (ClientCancelAtSubscriptionScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CancelAtSubscriptionScope" + const operationName = "Client.CancelAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.cancelAtSubscriptionScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientCancelAtSubscriptionScopeResponse{}, err + return ClientCancelAtSubscriptionScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCancelAtSubscriptionScopeResponse{}, err + return ClientCancelAtSubscriptionScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCancelAtSubscriptionScopeResponse{}, err + return ClientCancelAtSubscriptionScopeResponse{}, err } - return DeploymentsClientCancelAtSubscriptionScopeResponse{}, nil + return ClientCancelAtSubscriptionScopeResponse{}, nil } // cancelAtSubscriptionScopeCreateRequest creates the CancelAtSubscriptionScope request. -func (client *DeploymentsClient) cancelAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientCancelAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) cancelAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientCancelAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -304,7 +299,7 @@ func (client *DeploymentsClient) cancelAtSubscriptionScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -315,33 +310,32 @@ func (client *DeploymentsClient) cancelAtSubscriptionScopeCreateRequest(ctx cont // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCancelAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtTenantScope -// method. -func (client *DeploymentsClient) CancelAtTenantScope(ctx context.Context, deploymentName string, options *DeploymentsClientCancelAtTenantScopeOptions) (DeploymentsClientCancelAtTenantScopeResponse, error) { +// - options - ClientCancelAtTenantScopeOptions contains the optional parameters for the Client.CancelAtTenantScope method. +func (client *Client) CancelAtTenantScope(ctx context.Context, deploymentName string, options *ClientCancelAtTenantScopeOptions) (ClientCancelAtTenantScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CancelAtTenantScope" + const operationName = "Client.CancelAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.cancelAtTenantScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientCancelAtTenantScopeResponse{}, err + return ClientCancelAtTenantScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCancelAtTenantScopeResponse{}, err + return ClientCancelAtTenantScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCancelAtTenantScopeResponse{}, err + return ClientCancelAtTenantScopeResponse{}, err } - return DeploymentsClientCancelAtTenantScopeResponse{}, nil + return ClientCancelAtTenantScopeResponse{}, nil } // cancelAtTenantScopeCreateRequest creates the CancelAtTenantScope request. -func (client *DeploymentsClient) cancelAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientCancelAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) cancelAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientCancelAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}/cancel" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -352,7 +346,7 @@ func (client *DeploymentsClient) cancelAtTenantScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -360,34 +354,33 @@ func (client *DeploymentsClient) cancelAtTenantScopeCreateRequest(ctx context.Co // CheckExistence - Checks whether the deployment exists. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group with the deployment to check. The name is case insensitive. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCheckExistenceOptions contains the optional parameters for the DeploymentsClient.CheckExistence -// method. -func (client *DeploymentsClient) CheckExistence(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientCheckExistenceOptions) (DeploymentsClientCheckExistenceResponse, error) { +// - options - ClientCheckExistenceOptions contains the optional parameters for the Client.CheckExistence method. +func (client *Client) CheckExistence(ctx context.Context, resourceGroupName string, deploymentName string, options *ClientCheckExistenceOptions) (ClientCheckExistenceResponse, error) { var err error - const operationName = "DeploymentsClient.CheckExistence" + const operationName = "Client.CheckExistence" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.checkExistenceCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { - return DeploymentsClientCheckExistenceResponse{}, err + return ClientCheckExistenceResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCheckExistenceResponse{}, err + return ClientCheckExistenceResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCheckExistenceResponse{}, err + return ClientCheckExistenceResponse{}, err } - return DeploymentsClientCheckExistenceResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil + return ClientCheckExistenceResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil } // checkExistenceCreateRequest creates the CheckExistence request. -func (client *DeploymentsClient) checkExistenceCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientCheckExistenceOptions) (*policy.Request, error) { +func (client *Client) checkExistenceCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *ClientCheckExistenceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -406,7 +399,7 @@ func (client *DeploymentsClient) checkExistenceCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -414,34 +407,34 @@ func (client *DeploymentsClient) checkExistenceCreateRequest(ctx context.Context // CheckExistenceAtManagementGroupScope - Checks whether the deployment exists. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCheckExistenceAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtManagementGroupScope +// - options - ClientCheckExistenceAtManagementGroupScopeOptions contains the optional parameters for the Client.CheckExistenceAtManagementGroupScope // method. -func (client *DeploymentsClient) CheckExistenceAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientCheckExistenceAtManagementGroupScopeOptions) (DeploymentsClientCheckExistenceAtManagementGroupScopeResponse, error) { +func (client *Client) CheckExistenceAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *ClientCheckExistenceAtManagementGroupScopeOptions) (ClientCheckExistenceAtManagementGroupScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CheckExistenceAtManagementGroupScope" + const operationName = "Client.CheckExistenceAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.checkExistenceAtManagementGroupScopeCreateRequest(ctx, groupID, deploymentName, options) if err != nil { - return DeploymentsClientCheckExistenceAtManagementGroupScopeResponse{}, err + return ClientCheckExistenceAtManagementGroupScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCheckExistenceAtManagementGroupScopeResponse{}, err + return ClientCheckExistenceAtManagementGroupScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCheckExistenceAtManagementGroupScopeResponse{}, err + return ClientCheckExistenceAtManagementGroupScopeResponse{}, err } - return DeploymentsClientCheckExistenceAtManagementGroupScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil + return ClientCheckExistenceAtManagementGroupScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil } // checkExistenceAtManagementGroupScopeCreateRequest creates the CheckExistenceAtManagementGroupScope request. -func (client *DeploymentsClient) checkExistenceAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientCheckExistenceAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) checkExistenceAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, _ *ClientCheckExistenceAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -456,7 +449,7 @@ func (client *DeploymentsClient) checkExistenceAtManagementGroupScopeCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -464,34 +457,33 @@ func (client *DeploymentsClient) checkExistenceAtManagementGroupScopeCreateReque // CheckExistenceAtScope - Checks whether the deployment exists. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCheckExistenceAtScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtScope -// method. -func (client *DeploymentsClient) CheckExistenceAtScope(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientCheckExistenceAtScopeOptions) (DeploymentsClientCheckExistenceAtScopeResponse, error) { +// - options - ClientCheckExistenceAtScopeOptions contains the optional parameters for the Client.CheckExistenceAtScope method. +func (client *Client) CheckExistenceAtScope(ctx context.Context, scope string, deploymentName string, options *ClientCheckExistenceAtScopeOptions) (ClientCheckExistenceAtScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CheckExistenceAtScope" + const operationName = "Client.CheckExistenceAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.checkExistenceAtScopeCreateRequest(ctx, scope, deploymentName, options) if err != nil { - return DeploymentsClientCheckExistenceAtScopeResponse{}, err + return ClientCheckExistenceAtScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCheckExistenceAtScopeResponse{}, err + return ClientCheckExistenceAtScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCheckExistenceAtScopeResponse{}, err + return ClientCheckExistenceAtScopeResponse{}, err } - return DeploymentsClientCheckExistenceAtScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil + return ClientCheckExistenceAtScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil } // checkExistenceAtScopeCreateRequest creates the CheckExistenceAtScope request. -func (client *DeploymentsClient) checkExistenceAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientCheckExistenceAtScopeOptions) (*policy.Request, error) { +func (client *Client) checkExistenceAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, _ *ClientCheckExistenceAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -503,7 +495,7 @@ func (client *DeploymentsClient) checkExistenceAtScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -511,33 +503,33 @@ func (client *DeploymentsClient) checkExistenceAtScopeCreateRequest(ctx context. // CheckExistenceAtSubscriptionScope - Checks whether the deployment exists. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCheckExistenceAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtSubscriptionScope +// - options - ClientCheckExistenceAtSubscriptionScopeOptions contains the optional parameters for the Client.CheckExistenceAtSubscriptionScope // method. -func (client *DeploymentsClient) CheckExistenceAtSubscriptionScope(ctx context.Context, deploymentName string, options *DeploymentsClientCheckExistenceAtSubscriptionScopeOptions) (DeploymentsClientCheckExistenceAtSubscriptionScopeResponse, error) { +func (client *Client) CheckExistenceAtSubscriptionScope(ctx context.Context, deploymentName string, options *ClientCheckExistenceAtSubscriptionScopeOptions) (ClientCheckExistenceAtSubscriptionScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CheckExistenceAtSubscriptionScope" + const operationName = "Client.CheckExistenceAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.checkExistenceAtSubscriptionScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientCheckExistenceAtSubscriptionScopeResponse{}, err + return ClientCheckExistenceAtSubscriptionScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCheckExistenceAtSubscriptionScopeResponse{}, err + return ClientCheckExistenceAtSubscriptionScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCheckExistenceAtSubscriptionScopeResponse{}, err + return ClientCheckExistenceAtSubscriptionScopeResponse{}, err } - return DeploymentsClientCheckExistenceAtSubscriptionScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil + return ClientCheckExistenceAtSubscriptionScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil } // checkExistenceAtSubscriptionScopeCreateRequest creates the CheckExistenceAtSubscriptionScope request. -func (client *DeploymentsClient) checkExistenceAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientCheckExistenceAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) checkExistenceAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientCheckExistenceAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -552,7 +544,7 @@ func (client *DeploymentsClient) checkExistenceAtSubscriptionScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -560,33 +552,33 @@ func (client *DeploymentsClient) checkExistenceAtSubscriptionScopeCreateRequest( // CheckExistenceAtTenantScope - Checks whether the deployment exists. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientCheckExistenceAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtTenantScope +// - options - ClientCheckExistenceAtTenantScopeOptions contains the optional parameters for the Client.CheckExistenceAtTenantScope // method. -func (client *DeploymentsClient) CheckExistenceAtTenantScope(ctx context.Context, deploymentName string, options *DeploymentsClientCheckExistenceAtTenantScopeOptions) (DeploymentsClientCheckExistenceAtTenantScopeResponse, error) { +func (client *Client) CheckExistenceAtTenantScope(ctx context.Context, deploymentName string, options *ClientCheckExistenceAtTenantScopeOptions) (ClientCheckExistenceAtTenantScopeResponse, error) { var err error - const operationName = "DeploymentsClient.CheckExistenceAtTenantScope" + const operationName = "Client.CheckExistenceAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.checkExistenceAtTenantScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientCheckExistenceAtTenantScopeResponse{}, err + return ClientCheckExistenceAtTenantScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientCheckExistenceAtTenantScopeResponse{}, err + return ClientCheckExistenceAtTenantScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusNoContent, http.StatusNotFound) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientCheckExistenceAtTenantScopeResponse{}, err + return ClientCheckExistenceAtTenantScopeResponse{}, err } - return DeploymentsClientCheckExistenceAtTenantScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil + return ClientCheckExistenceAtTenantScopeResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil } // checkExistenceAtTenantScopeCreateRequest creates the CheckExistenceAtTenantScope request. -func (client *DeploymentsClient) checkExistenceAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientCheckExistenceAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) checkExistenceAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientCheckExistenceAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -597,7 +589,7 @@ func (client *DeploymentsClient) checkExistenceAtTenantScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -606,25 +598,24 @@ func (client *DeploymentsClient) checkExistenceAtTenantScopeCreateRequest(ctx co // BeginCreateOrUpdate - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group to deploy the resources to. The name is case insensitive. The resource // group must already exist. // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. -// - options - DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate -// method. -func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateResponse], error) { +// - options - ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. +func (client *Client) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *ClientBeginCreateOrUpdateOptions) (*runtime.Poller[ClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientCreateOrUpdateResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateResponse]{ Tracer: client.internal.Tracer(), }) } @@ -633,10 +624,10 @@ func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resour // CreateOrUpdate - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *ClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginCreateOrUpdate" + const operationName = "Client.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -656,7 +647,7 @@ func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGro } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, _ *ClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -675,7 +666,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -688,24 +679,24 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context // to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. -// - options - DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope +// - options - ClientBeginCreateOrUpdateAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtManagementGroupScope // method. -func (client *DeploymentsClient) BeginCreateOrUpdateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse], error) { +func (client *Client) BeginCreateOrUpdateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *ClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (*runtime.Poller[ClientCreateOrUpdateAtManagementGroupScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdateAtManagementGroupScope(ctx, groupID, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtManagementGroupScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateAtManagementGroupScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -715,10 +706,10 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtManagementGroupScope(ctx c // files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) createOrUpdateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) createOrUpdateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *ClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope" + const operationName = "Client.BeginCreateOrUpdateAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -738,7 +729,7 @@ func (client *DeploymentsClient) createOrUpdateAtManagementGroupScope(ctx contex } // createOrUpdateAtManagementGroupScopeCreateRequest creates the CreateOrUpdateAtManagementGroupScope request. -func (client *DeploymentsClient) createOrUpdateAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) createOrUpdateAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, _ *ClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -753,7 +744,7 @@ func (client *DeploymentsClient) createOrUpdateAtManagementGroupScopeCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -765,24 +756,24 @@ func (client *DeploymentsClient) createOrUpdateAtManagementGroupScopeCreateReque // BeginCreateOrUpdateAtScope - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. -// - options - DeploymentsClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtScope +// - options - ClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtScope // method. -func (client *DeploymentsClient) BeginCreateOrUpdateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtScopeOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateAtScopeResponse], error) { +func (client *Client) BeginCreateOrUpdateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *ClientBeginCreateOrUpdateAtScopeOptions) (*runtime.Poller[ClientCreateOrUpdateAtScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdateAtScope(ctx, scope, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateAtScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientCreateOrUpdateAtScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateAtScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -791,10 +782,10 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtScope(ctx context.Context, // CreateOrUpdateAtScope - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) createOrUpdateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) createOrUpdateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *ClientBeginCreateOrUpdateAtScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginCreateOrUpdateAtScope" + const operationName = "Client.BeginCreateOrUpdateAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -814,7 +805,7 @@ func (client *DeploymentsClient) createOrUpdateAtScope(ctx context.Context, scop } // createOrUpdateAtScopeCreateRequest creates the CreateOrUpdateAtScope request. -func (client *DeploymentsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtScopeOptions) (*policy.Request, error) { +func (client *Client) createOrUpdateAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, parameters Deployment, _ *ClientBeginCreateOrUpdateAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -826,7 +817,7 @@ func (client *DeploymentsClient) createOrUpdateAtScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -839,23 +830,23 @@ func (client *DeploymentsClient) createOrUpdateAtScopeCreateRequest(ctx context. // JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. -// - options - DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope +// - options - ClientBeginCreateOrUpdateAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtSubscriptionScope // method. -func (client *DeploymentsClient) BeginCreateOrUpdateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse], error) { +func (client *Client) BeginCreateOrUpdateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *ClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (*runtime.Poller[ClientCreateOrUpdateAtSubscriptionScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdateAtSubscriptionScope(ctx, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtSubscriptionScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateAtSubscriptionScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -865,10 +856,10 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtSubscriptionScope(ctx cont // files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) createOrUpdateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) createOrUpdateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *ClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope" + const operationName = "Client.BeginCreateOrUpdateAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -888,7 +879,7 @@ func (client *DeploymentsClient) createOrUpdateAtSubscriptionScope(ctx context.C } // createOrUpdateAtSubscriptionScopeCreateRequest creates the CreateOrUpdateAtSubscriptionScope request. -func (client *DeploymentsClient) createOrUpdateAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) createOrUpdateAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, parameters Deployment, _ *ClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -903,7 +894,7 @@ func (client *DeploymentsClient) createOrUpdateAtSubscriptionScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -916,23 +907,23 @@ func (client *DeploymentsClient) createOrUpdateAtSubscriptionScopeCreateRequest( // files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. -// - options - DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtTenantScope +// - options - ClientBeginCreateOrUpdateAtTenantScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtTenantScope // method. -func (client *DeploymentsClient) BeginCreateOrUpdateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions) (*runtime.Poller[DeploymentsClientCreateOrUpdateAtTenantScopeResponse], error) { +func (client *Client) BeginCreateOrUpdateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *ClientBeginCreateOrUpdateAtTenantScopeOptions) (*runtime.Poller[ClientCreateOrUpdateAtTenantScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdateAtTenantScope(ctx, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientCreateOrUpdateAtTenantScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtTenantScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientCreateOrUpdateAtTenantScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateAtTenantScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -941,10 +932,10 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtTenantScope(ctx context.Co // CreateOrUpdateAtTenantScope - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) createOrUpdateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) createOrUpdateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *ClientBeginCreateOrUpdateAtTenantScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginCreateOrUpdateAtTenantScope" + const operationName = "Client.BeginCreateOrUpdateAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -964,7 +955,7 @@ func (client *DeploymentsClient) createOrUpdateAtTenantScope(ctx context.Context } // createOrUpdateAtTenantScopeCreateRequest creates the CreateOrUpdateAtTenantScope request. -func (client *DeploymentsClient) createOrUpdateAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) createOrUpdateAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, parameters ScopedDeployment, _ *ClientBeginCreateOrUpdateAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -975,7 +966,7 @@ func (client *DeploymentsClient) createOrUpdateAtTenantScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -994,22 +985,22 @@ func (client *DeploymentsClient) createOrUpdateAtTenantScopeCreateRequest(ctx co // code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group with the deployment to delete. The name is case insensitive. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. -func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*runtime.Poller[DeploymentsClientDeleteResponse], error) { +// - options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, deploymentName string, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, deploymentName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientDeleteResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteResponse]{ Tracer: client.internal.Tracer(), }) } @@ -1025,10 +1016,10 @@ func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupN // code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, options *ClientBeginDeleteOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginDelete" + const operationName = "Client.BeginDelete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -1048,7 +1039,7 @@ func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGr } // deleteCreateRequest creates the Delete request. -func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *ClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1067,7 +1058,7 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1082,23 +1073,23 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientBeginDeleteAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtManagementGroupScope +// - options - ClientBeginDeleteAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginDeleteAtManagementGroupScope // method. -func (client *DeploymentsClient) BeginDeleteAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientBeginDeleteAtManagementGroupScopeOptions) (*runtime.Poller[DeploymentsClientDeleteAtManagementGroupScopeResponse], error) { +func (client *Client) BeginDeleteAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *ClientBeginDeleteAtManagementGroupScopeOptions) (*runtime.Poller[ClientDeleteAtManagementGroupScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteAtManagementGroupScope(ctx, groupID, deploymentName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientDeleteAtManagementGroupScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtManagementGroupScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientDeleteAtManagementGroupScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAtManagementGroupScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -1113,10 +1104,10 @@ func (client *DeploymentsClient) BeginDeleteAtManagementGroupScope(ctx context.C // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) deleteAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientBeginDeleteAtManagementGroupScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) deleteAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *ClientBeginDeleteAtManagementGroupScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginDeleteAtManagementGroupScope" + const operationName = "Client.BeginDeleteAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -1136,7 +1127,7 @@ func (client *DeploymentsClient) deleteAtManagementGroupScope(ctx context.Contex } // deleteAtManagementGroupScopeCreateRequest creates the DeleteAtManagementGroupScope request. -func (client *DeploymentsClient) deleteAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientBeginDeleteAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) deleteAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, _ *ClientBeginDeleteAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -1151,7 +1142,7 @@ func (client *DeploymentsClient) deleteAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1166,23 +1157,22 @@ func (client *DeploymentsClient) deleteAtManagementGroupScopeCreateRequest(ctx c // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientBeginDeleteAtScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtScope -// method. -func (client *DeploymentsClient) BeginDeleteAtScope(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientBeginDeleteAtScopeOptions) (*runtime.Poller[DeploymentsClientDeleteAtScopeResponse], error) { +// - options - ClientBeginDeleteAtScopeOptions contains the optional parameters for the Client.BeginDeleteAtScope method. +func (client *Client) BeginDeleteAtScope(ctx context.Context, scope string, deploymentName string, options *ClientBeginDeleteAtScopeOptions) (*runtime.Poller[ClientDeleteAtScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteAtScope(ctx, scope, deploymentName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientDeleteAtScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientDeleteAtScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAtScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -1197,10 +1187,10 @@ func (client *DeploymentsClient) BeginDeleteAtScope(ctx context.Context, scope s // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) deleteAtScope(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientBeginDeleteAtScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) deleteAtScope(ctx context.Context, scope string, deploymentName string, options *ClientBeginDeleteAtScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginDeleteAtScope" + const operationName = "Client.BeginDeleteAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -1220,7 +1210,7 @@ func (client *DeploymentsClient) deleteAtScope(ctx context.Context, scope string } // deleteAtScopeCreateRequest creates the DeleteAtScope request. -func (client *DeploymentsClient) deleteAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientBeginDeleteAtScopeOptions) (*policy.Request, error) { +func (client *Client) deleteAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, _ *ClientBeginDeleteAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -1232,7 +1222,7 @@ func (client *DeploymentsClient) deleteAtScopeCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1247,22 +1237,22 @@ func (client *DeploymentsClient) deleteAtScopeCreateRequest(ctx context.Context, // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientBeginDeleteAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtSubscriptionScope +// - options - ClientBeginDeleteAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginDeleteAtSubscriptionScope // method. -func (client *DeploymentsClient) BeginDeleteAtSubscriptionScope(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtSubscriptionScopeOptions) (*runtime.Poller[DeploymentsClientDeleteAtSubscriptionScopeResponse], error) { +func (client *Client) BeginDeleteAtSubscriptionScope(ctx context.Context, deploymentName string, options *ClientBeginDeleteAtSubscriptionScopeOptions) (*runtime.Poller[ClientDeleteAtSubscriptionScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteAtSubscriptionScope(ctx, deploymentName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientDeleteAtSubscriptionScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtSubscriptionScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientDeleteAtSubscriptionScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAtSubscriptionScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -1277,10 +1267,10 @@ func (client *DeploymentsClient) BeginDeleteAtSubscriptionScope(ctx context.Cont // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) deleteAtSubscriptionScope(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtSubscriptionScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) deleteAtSubscriptionScope(ctx context.Context, deploymentName string, options *ClientBeginDeleteAtSubscriptionScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginDeleteAtSubscriptionScope" + const operationName = "Client.BeginDeleteAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -1300,7 +1290,7 @@ func (client *DeploymentsClient) deleteAtSubscriptionScope(ctx context.Context, } // deleteAtSubscriptionScopeCreateRequest creates the DeleteAtSubscriptionScope request. -func (client *DeploymentsClient) deleteAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) deleteAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientBeginDeleteAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -1315,7 +1305,7 @@ func (client *DeploymentsClient) deleteAtSubscriptionScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1330,22 +1320,22 @@ func (client *DeploymentsClient) deleteAtSubscriptionScopeCreateRequest(ctx cont // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientBeginDeleteAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtTenantScope +// - options - ClientBeginDeleteAtTenantScopeOptions contains the optional parameters for the Client.BeginDeleteAtTenantScope // method. -func (client *DeploymentsClient) BeginDeleteAtTenantScope(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtTenantScopeOptions) (*runtime.Poller[DeploymentsClientDeleteAtTenantScopeResponse], error) { +func (client *Client) BeginDeleteAtTenantScope(ctx context.Context, deploymentName string, options *ClientBeginDeleteAtTenantScopeOptions) (*runtime.Poller[ClientDeleteAtTenantScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteAtTenantScope(ctx, deploymentName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientDeleteAtTenantScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtTenantScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientDeleteAtTenantScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAtTenantScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -1360,10 +1350,10 @@ func (client *DeploymentsClient) BeginDeleteAtTenantScope(ctx context.Context, d // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) deleteAtTenantScope(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtTenantScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) deleteAtTenantScope(ctx context.Context, deploymentName string, options *ClientBeginDeleteAtTenantScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginDeleteAtTenantScope" + const operationName = "Client.BeginDeleteAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -1383,7 +1373,7 @@ func (client *DeploymentsClient) deleteAtTenantScope(ctx context.Context, deploy } // deleteAtTenantScopeCreateRequest creates the DeleteAtTenantScope request. -func (client *DeploymentsClient) deleteAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) deleteAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientBeginDeleteAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -1394,7 +1384,7 @@ func (client *DeploymentsClient) deleteAtTenantScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1403,35 +1393,34 @@ func (client *DeploymentsClient) deleteAtTenantScopeCreateRequest(ctx context.Co // ExportTemplate - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientExportTemplateOptions contains the optional parameters for the DeploymentsClient.ExportTemplate -// method. -func (client *DeploymentsClient) ExportTemplate(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientExportTemplateOptions) (DeploymentsClientExportTemplateResponse, error) { +// - options - ClientExportTemplateOptions contains the optional parameters for the Client.ExportTemplate method. +func (client *Client) ExportTemplate(ctx context.Context, resourceGroupName string, deploymentName string, options *ClientExportTemplateOptions) (ClientExportTemplateResponse, error) { var err error - const operationName = "DeploymentsClient.ExportTemplate" + const operationName = "Client.ExportTemplate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.exportTemplateCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { - return DeploymentsClientExportTemplateResponse{}, err + return ClientExportTemplateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientExportTemplateResponse{}, err + return ClientExportTemplateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientExportTemplateResponse{}, err + return ClientExportTemplateResponse{}, err } resp, err := client.exportTemplateHandleResponse(httpResp) return resp, err } // exportTemplateCreateRequest creates the ExportTemplate request. -func (client *DeploymentsClient) exportTemplateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientExportTemplateOptions) (*policy.Request, error) { +func (client *Client) exportTemplateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *ClientExportTemplateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1450,17 +1439,17 @@ func (client *DeploymentsClient) exportTemplateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // exportTemplateHandleResponse handles the ExportTemplate response. -func (client *DeploymentsClient) exportTemplateHandleResponse(resp *http.Response) (DeploymentsClientExportTemplateResponse, error) { - result := DeploymentsClientExportTemplateResponse{} +func (client *Client) exportTemplateHandleResponse(resp *http.Response) (ClientExportTemplateResponse, error) { + result := ClientExportTemplateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExportResult); err != nil { - return DeploymentsClientExportTemplateResponse{}, err + return ClientExportTemplateResponse{}, err } return result, nil } @@ -1468,35 +1457,35 @@ func (client *DeploymentsClient) exportTemplateHandleResponse(resp *http.Respons // ExportTemplateAtManagementGroupScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientExportTemplateAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtManagementGroupScope +// - options - ClientExportTemplateAtManagementGroupScopeOptions contains the optional parameters for the Client.ExportTemplateAtManagementGroupScope // method. -func (client *DeploymentsClient) ExportTemplateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientExportTemplateAtManagementGroupScopeOptions) (DeploymentsClientExportTemplateAtManagementGroupScopeResponse, error) { +func (client *Client) ExportTemplateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *ClientExportTemplateAtManagementGroupScopeOptions) (ClientExportTemplateAtManagementGroupScopeResponse, error) { var err error - const operationName = "DeploymentsClient.ExportTemplateAtManagementGroupScope" + const operationName = "Client.ExportTemplateAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.exportTemplateAtManagementGroupScopeCreateRequest(ctx, groupID, deploymentName, options) if err != nil { - return DeploymentsClientExportTemplateAtManagementGroupScopeResponse{}, err + return ClientExportTemplateAtManagementGroupScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientExportTemplateAtManagementGroupScopeResponse{}, err + return ClientExportTemplateAtManagementGroupScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientExportTemplateAtManagementGroupScopeResponse{}, err + return ClientExportTemplateAtManagementGroupScopeResponse{}, err } resp, err := client.exportTemplateAtManagementGroupScopeHandleResponse(httpResp) return resp, err } // exportTemplateAtManagementGroupScopeCreateRequest creates the ExportTemplateAtManagementGroupScope request. -func (client *DeploymentsClient) exportTemplateAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientExportTemplateAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) exportTemplateAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, _ *ClientExportTemplateAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -1511,17 +1500,17 @@ func (client *DeploymentsClient) exportTemplateAtManagementGroupScopeCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // exportTemplateAtManagementGroupScopeHandleResponse handles the ExportTemplateAtManagementGroupScope response. -func (client *DeploymentsClient) exportTemplateAtManagementGroupScopeHandleResponse(resp *http.Response) (DeploymentsClientExportTemplateAtManagementGroupScopeResponse, error) { - result := DeploymentsClientExportTemplateAtManagementGroupScopeResponse{} +func (client *Client) exportTemplateAtManagementGroupScopeHandleResponse(resp *http.Response) (ClientExportTemplateAtManagementGroupScopeResponse, error) { + result := ClientExportTemplateAtManagementGroupScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExportResult); err != nil { - return DeploymentsClientExportTemplateAtManagementGroupScopeResponse{}, err + return ClientExportTemplateAtManagementGroupScopeResponse{}, err } return result, nil } @@ -1529,35 +1518,34 @@ func (client *DeploymentsClient) exportTemplateAtManagementGroupScopeHandleRespo // ExportTemplateAtScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientExportTemplateAtScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtScope -// method. -func (client *DeploymentsClient) ExportTemplateAtScope(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientExportTemplateAtScopeOptions) (DeploymentsClientExportTemplateAtScopeResponse, error) { +// - options - ClientExportTemplateAtScopeOptions contains the optional parameters for the Client.ExportTemplateAtScope method. +func (client *Client) ExportTemplateAtScope(ctx context.Context, scope string, deploymentName string, options *ClientExportTemplateAtScopeOptions) (ClientExportTemplateAtScopeResponse, error) { var err error - const operationName = "DeploymentsClient.ExportTemplateAtScope" + const operationName = "Client.ExportTemplateAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.exportTemplateAtScopeCreateRequest(ctx, scope, deploymentName, options) if err != nil { - return DeploymentsClientExportTemplateAtScopeResponse{}, err + return ClientExportTemplateAtScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientExportTemplateAtScopeResponse{}, err + return ClientExportTemplateAtScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientExportTemplateAtScopeResponse{}, err + return ClientExportTemplateAtScopeResponse{}, err } resp, err := client.exportTemplateAtScopeHandleResponse(httpResp) return resp, err } // exportTemplateAtScopeCreateRequest creates the ExportTemplateAtScope request. -func (client *DeploymentsClient) exportTemplateAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientExportTemplateAtScopeOptions) (*policy.Request, error) { +func (client *Client) exportTemplateAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, _ *ClientExportTemplateAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -1569,17 +1557,17 @@ func (client *DeploymentsClient) exportTemplateAtScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // exportTemplateAtScopeHandleResponse handles the ExportTemplateAtScope response. -func (client *DeploymentsClient) exportTemplateAtScopeHandleResponse(resp *http.Response) (DeploymentsClientExportTemplateAtScopeResponse, error) { - result := DeploymentsClientExportTemplateAtScopeResponse{} +func (client *Client) exportTemplateAtScopeHandleResponse(resp *http.Response) (ClientExportTemplateAtScopeResponse, error) { + result := ClientExportTemplateAtScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExportResult); err != nil { - return DeploymentsClientExportTemplateAtScopeResponse{}, err + return ClientExportTemplateAtScopeResponse{}, err } return result, nil } @@ -1587,34 +1575,34 @@ func (client *DeploymentsClient) exportTemplateAtScopeHandleResponse(resp *http. // ExportTemplateAtSubscriptionScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientExportTemplateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtSubscriptionScope +// - options - ClientExportTemplateAtSubscriptionScopeOptions contains the optional parameters for the Client.ExportTemplateAtSubscriptionScope // method. -func (client *DeploymentsClient) ExportTemplateAtSubscriptionScope(ctx context.Context, deploymentName string, options *DeploymentsClientExportTemplateAtSubscriptionScopeOptions) (DeploymentsClientExportTemplateAtSubscriptionScopeResponse, error) { +func (client *Client) ExportTemplateAtSubscriptionScope(ctx context.Context, deploymentName string, options *ClientExportTemplateAtSubscriptionScopeOptions) (ClientExportTemplateAtSubscriptionScopeResponse, error) { var err error - const operationName = "DeploymentsClient.ExportTemplateAtSubscriptionScope" + const operationName = "Client.ExportTemplateAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.exportTemplateAtSubscriptionScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientExportTemplateAtSubscriptionScopeResponse{}, err + return ClientExportTemplateAtSubscriptionScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientExportTemplateAtSubscriptionScopeResponse{}, err + return ClientExportTemplateAtSubscriptionScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientExportTemplateAtSubscriptionScopeResponse{}, err + return ClientExportTemplateAtSubscriptionScopeResponse{}, err } resp, err := client.exportTemplateAtSubscriptionScopeHandleResponse(httpResp) return resp, err } // exportTemplateAtSubscriptionScopeCreateRequest creates the ExportTemplateAtSubscriptionScope request. -func (client *DeploymentsClient) exportTemplateAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientExportTemplateAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) exportTemplateAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientExportTemplateAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -1629,17 +1617,17 @@ func (client *DeploymentsClient) exportTemplateAtSubscriptionScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // exportTemplateAtSubscriptionScopeHandleResponse handles the ExportTemplateAtSubscriptionScope response. -func (client *DeploymentsClient) exportTemplateAtSubscriptionScopeHandleResponse(resp *http.Response) (DeploymentsClientExportTemplateAtSubscriptionScopeResponse, error) { - result := DeploymentsClientExportTemplateAtSubscriptionScopeResponse{} +func (client *Client) exportTemplateAtSubscriptionScopeHandleResponse(resp *http.Response) (ClientExportTemplateAtSubscriptionScopeResponse, error) { + result := ClientExportTemplateAtSubscriptionScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExportResult); err != nil { - return DeploymentsClientExportTemplateAtSubscriptionScopeResponse{}, err + return ClientExportTemplateAtSubscriptionScopeResponse{}, err } return result, nil } @@ -1647,34 +1635,34 @@ func (client *DeploymentsClient) exportTemplateAtSubscriptionScopeHandleResponse // ExportTemplateAtTenantScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientExportTemplateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtTenantScope +// - options - ClientExportTemplateAtTenantScopeOptions contains the optional parameters for the Client.ExportTemplateAtTenantScope // method. -func (client *DeploymentsClient) ExportTemplateAtTenantScope(ctx context.Context, deploymentName string, options *DeploymentsClientExportTemplateAtTenantScopeOptions) (DeploymentsClientExportTemplateAtTenantScopeResponse, error) { +func (client *Client) ExportTemplateAtTenantScope(ctx context.Context, deploymentName string, options *ClientExportTemplateAtTenantScopeOptions) (ClientExportTemplateAtTenantScopeResponse, error) { var err error - const operationName = "DeploymentsClient.ExportTemplateAtTenantScope" + const operationName = "Client.ExportTemplateAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.exportTemplateAtTenantScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientExportTemplateAtTenantScopeResponse{}, err + return ClientExportTemplateAtTenantScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientExportTemplateAtTenantScopeResponse{}, err + return ClientExportTemplateAtTenantScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientExportTemplateAtTenantScopeResponse{}, err + return ClientExportTemplateAtTenantScopeResponse{}, err } resp, err := client.exportTemplateAtTenantScopeHandleResponse(httpResp) return resp, err } // exportTemplateAtTenantScopeCreateRequest creates the ExportTemplateAtTenantScope request. -func (client *DeploymentsClient) exportTemplateAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientExportTemplateAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) exportTemplateAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientExportTemplateAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -1685,17 +1673,17 @@ func (client *DeploymentsClient) exportTemplateAtTenantScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // exportTemplateAtTenantScopeHandleResponse handles the ExportTemplateAtTenantScope response. -func (client *DeploymentsClient) exportTemplateAtTenantScopeHandleResponse(resp *http.Response) (DeploymentsClientExportTemplateAtTenantScopeResponse, error) { - result := DeploymentsClientExportTemplateAtTenantScopeResponse{} +func (client *Client) exportTemplateAtTenantScopeHandleResponse(resp *http.Response) (ClientExportTemplateAtTenantScopeResponse, error) { + result := ClientExportTemplateAtTenantScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExportResult); err != nil { - return DeploymentsClientExportTemplateAtTenantScopeResponse{}, err + return ClientExportTemplateAtTenantScopeResponse{}, err } return result, nil } @@ -1703,34 +1691,34 @@ func (client *DeploymentsClient) exportTemplateAtTenantScopeHandleResponse(resp // Get - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. -func (client *DeploymentsClient) Get(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientGetOptions) (DeploymentsClientGetResponse, error) { +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, deploymentName string, options *ClientGetOptions) (ClientGetResponse, error) { var err error - const operationName = "DeploymentsClient.Get" + const operationName = "Client.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, deploymentName, options) if err != nil { - return DeploymentsClientGetResponse{}, err + return ClientGetResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientGetResponse{}, err + return ClientGetResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientGetResponse{}, err + return ClientGetResponse{}, err } resp, err := client.getHandleResponse(httpResp) return resp, err } // getCreateRequest creates the Get request. -func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientGetOptions) (*policy.Request, error) { +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, _ *ClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1749,17 +1737,17 @@ func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getHandleResponse handles the Get response. -func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (DeploymentsClientGetResponse, error) { - result := DeploymentsClientGetResponse{} +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExtended); err != nil { - return DeploymentsClientGetResponse{}, err + return ClientGetResponse{}, err } return result, nil } @@ -1767,35 +1755,35 @@ func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (Deploym // GetAtManagementGroupScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientGetAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.GetAtManagementGroupScope +// - options - ClientGetAtManagementGroupScopeOptions contains the optional parameters for the Client.GetAtManagementGroupScope // method. -func (client *DeploymentsClient) GetAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientGetAtManagementGroupScopeOptions) (DeploymentsClientGetAtManagementGroupScopeResponse, error) { +func (client *Client) GetAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *ClientGetAtManagementGroupScopeOptions) (ClientGetAtManagementGroupScopeResponse, error) { var err error - const operationName = "DeploymentsClient.GetAtManagementGroupScope" + const operationName = "Client.GetAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getAtManagementGroupScopeCreateRequest(ctx, groupID, deploymentName, options) if err != nil { - return DeploymentsClientGetAtManagementGroupScopeResponse{}, err + return ClientGetAtManagementGroupScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientGetAtManagementGroupScopeResponse{}, err + return ClientGetAtManagementGroupScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientGetAtManagementGroupScopeResponse{}, err + return ClientGetAtManagementGroupScopeResponse{}, err } resp, err := client.getAtManagementGroupScopeHandleResponse(httpResp) return resp, err } // getAtManagementGroupScopeCreateRequest creates the GetAtManagementGroupScope request. -func (client *DeploymentsClient) getAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientGetAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) getAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, _ *ClientGetAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -1810,17 +1798,17 @@ func (client *DeploymentsClient) getAtManagementGroupScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getAtManagementGroupScopeHandleResponse handles the GetAtManagementGroupScope response. -func (client *DeploymentsClient) getAtManagementGroupScopeHandleResponse(resp *http.Response) (DeploymentsClientGetAtManagementGroupScopeResponse, error) { - result := DeploymentsClientGetAtManagementGroupScopeResponse{} +func (client *Client) getAtManagementGroupScopeHandleResponse(resp *http.Response) (ClientGetAtManagementGroupScopeResponse, error) { + result := ClientGetAtManagementGroupScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExtended); err != nil { - return DeploymentsClientGetAtManagementGroupScopeResponse{}, err + return ClientGetAtManagementGroupScopeResponse{}, err } return result, nil } @@ -1828,34 +1816,34 @@ func (client *DeploymentsClient) getAtManagementGroupScopeHandleResponse(resp *h // GetAtScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. -// - options - DeploymentsClientGetAtScopeOptions contains the optional parameters for the DeploymentsClient.GetAtScope method. -func (client *DeploymentsClient) GetAtScope(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientGetAtScopeOptions) (DeploymentsClientGetAtScopeResponse, error) { +// - options - ClientGetAtScopeOptions contains the optional parameters for the Client.GetAtScope method. +func (client *Client) GetAtScope(ctx context.Context, scope string, deploymentName string, options *ClientGetAtScopeOptions) (ClientGetAtScopeResponse, error) { var err error - const operationName = "DeploymentsClient.GetAtScope" + const operationName = "Client.GetAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getAtScopeCreateRequest(ctx, scope, deploymentName, options) if err != nil { - return DeploymentsClientGetAtScopeResponse{}, err + return ClientGetAtScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientGetAtScopeResponse{}, err + return ClientGetAtScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientGetAtScopeResponse{}, err + return ClientGetAtScopeResponse{}, err } resp, err := client.getAtScopeHandleResponse(httpResp) return resp, err } // getAtScopeCreateRequest creates the GetAtScope request. -func (client *DeploymentsClient) getAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientGetAtScopeOptions) (*policy.Request, error) { +func (client *Client) getAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, _ *ClientGetAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -1867,17 +1855,17 @@ func (client *DeploymentsClient) getAtScopeCreateRequest(ctx context.Context, sc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getAtScopeHandleResponse handles the GetAtScope response. -func (client *DeploymentsClient) getAtScopeHandleResponse(resp *http.Response) (DeploymentsClientGetAtScopeResponse, error) { - result := DeploymentsClientGetAtScopeResponse{} +func (client *Client) getAtScopeHandleResponse(resp *http.Response) (ClientGetAtScopeResponse, error) { + result := ClientGetAtScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExtended); err != nil { - return DeploymentsClientGetAtScopeResponse{}, err + return ClientGetAtScopeResponse{}, err } return result, nil } @@ -1885,34 +1873,33 @@ func (client *DeploymentsClient) getAtScopeHandleResponse(resp *http.Response) ( // GetAtSubscriptionScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientGetAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.GetAtSubscriptionScope -// method. -func (client *DeploymentsClient) GetAtSubscriptionScope(ctx context.Context, deploymentName string, options *DeploymentsClientGetAtSubscriptionScopeOptions) (DeploymentsClientGetAtSubscriptionScopeResponse, error) { +// - options - ClientGetAtSubscriptionScopeOptions contains the optional parameters for the Client.GetAtSubscriptionScope method. +func (client *Client) GetAtSubscriptionScope(ctx context.Context, deploymentName string, options *ClientGetAtSubscriptionScopeOptions) (ClientGetAtSubscriptionScopeResponse, error) { var err error - const operationName = "DeploymentsClient.GetAtSubscriptionScope" + const operationName = "Client.GetAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getAtSubscriptionScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientGetAtSubscriptionScopeResponse{}, err + return ClientGetAtSubscriptionScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientGetAtSubscriptionScopeResponse{}, err + return ClientGetAtSubscriptionScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientGetAtSubscriptionScopeResponse{}, err + return ClientGetAtSubscriptionScopeResponse{}, err } resp, err := client.getAtSubscriptionScopeHandleResponse(httpResp) return resp, err } // getAtSubscriptionScopeCreateRequest creates the GetAtSubscriptionScope request. -func (client *DeploymentsClient) getAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientGetAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) getAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientGetAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -1927,17 +1914,17 @@ func (client *DeploymentsClient) getAtSubscriptionScopeCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getAtSubscriptionScopeHandleResponse handles the GetAtSubscriptionScope response. -func (client *DeploymentsClient) getAtSubscriptionScopeHandleResponse(resp *http.Response) (DeploymentsClientGetAtSubscriptionScopeResponse, error) { - result := DeploymentsClientGetAtSubscriptionScopeResponse{} +func (client *Client) getAtSubscriptionScopeHandleResponse(resp *http.Response) (ClientGetAtSubscriptionScopeResponse, error) { + result := ClientGetAtSubscriptionScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExtended); err != nil { - return DeploymentsClientGetAtSubscriptionScopeResponse{}, err + return ClientGetAtSubscriptionScopeResponse{}, err } return result, nil } @@ -1945,34 +1932,33 @@ func (client *DeploymentsClient) getAtSubscriptionScopeHandleResponse(resp *http // GetAtTenantScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. -// - options - DeploymentsClientGetAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.GetAtTenantScope -// method. -func (client *DeploymentsClient) GetAtTenantScope(ctx context.Context, deploymentName string, options *DeploymentsClientGetAtTenantScopeOptions) (DeploymentsClientGetAtTenantScopeResponse, error) { +// - options - ClientGetAtTenantScopeOptions contains the optional parameters for the Client.GetAtTenantScope method. +func (client *Client) GetAtTenantScope(ctx context.Context, deploymentName string, options *ClientGetAtTenantScopeOptions) (ClientGetAtTenantScopeResponse, error) { var err error - const operationName = "DeploymentsClient.GetAtTenantScope" + const operationName = "Client.GetAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.getAtTenantScopeCreateRequest(ctx, deploymentName, options) if err != nil { - return DeploymentsClientGetAtTenantScopeResponse{}, err + return ClientGetAtTenantScopeResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return DeploymentsClientGetAtTenantScopeResponse{}, err + return ClientGetAtTenantScopeResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return DeploymentsClientGetAtTenantScopeResponse{}, err + return ClientGetAtTenantScopeResponse{}, err } resp, err := client.getAtTenantScopeHandleResponse(httpResp) return resp, err } // getAtTenantScopeCreateRequest creates the GetAtTenantScope request. -func (client *DeploymentsClient) getAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, options *DeploymentsClientGetAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) getAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, _ *ClientGetAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -1983,34 +1969,34 @@ func (client *DeploymentsClient) getAtTenantScopeCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // getAtTenantScopeHandleResponse handles the GetAtTenantScope response. -func (client *DeploymentsClient) getAtTenantScopeHandleResponse(resp *http.Response) (DeploymentsClientGetAtTenantScopeResponse, error) { - result := DeploymentsClientGetAtTenantScopeResponse{} +func (client *Client) getAtTenantScopeHandleResponse(resp *http.Response) (ClientGetAtTenantScopeResponse, error) { + result := ClientGetAtTenantScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentExtended); err != nil { - return DeploymentsClientGetAtTenantScopeResponse{}, err + return ClientGetAtTenantScopeResponse{}, err } return result, nil } // NewListAtManagementGroupScopePager - Get all the deployments for a management group. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. -// - options - DeploymentsClientListAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtManagementGroupScopePager +// - options - ClientListAtManagementGroupScopeOptions contains the optional parameters for the Client.NewListAtManagementGroupScopePager // method. -func (client *DeploymentsClient) NewListAtManagementGroupScopePager(groupID string, options *DeploymentsClientListAtManagementGroupScopeOptions) *runtime.Pager[DeploymentsClientListAtManagementGroupScopeResponse] { - return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListAtManagementGroupScopeResponse]{ - More: func(page DeploymentsClientListAtManagementGroupScopeResponse) bool { +func (client *Client) NewListAtManagementGroupScopePager(groupID string, options *ClientListAtManagementGroupScopeOptions) *runtime.Pager[ClientListAtManagementGroupScopeResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtManagementGroupScopeResponse]{ + More: func(page ClientListAtManagementGroupScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *DeploymentsClientListAtManagementGroupScopeResponse) (DeploymentsClientListAtManagementGroupScopeResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeploymentsClient.NewListAtManagementGroupScopePager") + Fetcher: func(ctx context.Context, page *ClientListAtManagementGroupScopeResponse) (ClientListAtManagementGroupScopeResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListAtManagementGroupScopePager") nextLink := "" if page != nil { nextLink = *page.NextLink @@ -2019,7 +2005,7 @@ func (client *DeploymentsClient) NewListAtManagementGroupScopePager(groupID stri return client.listAtManagementGroupScopeCreateRequest(ctx, groupID, options) }, nil) if err != nil { - return DeploymentsClientListAtManagementGroupScopeResponse{}, err + return ClientListAtManagementGroupScopeResponse{}, err } return client.listAtManagementGroupScopeHandleResponse(resp) }, @@ -2028,7 +2014,7 @@ func (client *DeploymentsClient) NewListAtManagementGroupScopePager(groupID stri } // listAtManagementGroupScopeCreateRequest creates the ListAtManagementGroupScope request. -func (client *DeploymentsClient) listAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, options *DeploymentsClientListAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) listAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, options *ClientListAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -2045,34 +2031,33 @@ func (client *DeploymentsClient) listAtManagementGroupScopeCreateRequest(ctx con if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listAtManagementGroupScopeHandleResponse handles the ListAtManagementGroupScope response. -func (client *DeploymentsClient) listAtManagementGroupScopeHandleResponse(resp *http.Response) (DeploymentsClientListAtManagementGroupScopeResponse, error) { - result := DeploymentsClientListAtManagementGroupScopeResponse{} +func (client *Client) listAtManagementGroupScopeHandleResponse(resp *http.Response) (ClientListAtManagementGroupScopeResponse, error) { + result := ClientListAtManagementGroupScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentListResult); err != nil { - return DeploymentsClientListAtManagementGroupScopeResponse{}, err + return ClientListAtManagementGroupScopeResponse{}, err } return result, nil } // NewListAtScopePager - Get all the deployments at the given scope. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. -// - options - DeploymentsClientListAtScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtScopePager -// method. -func (client *DeploymentsClient) NewListAtScopePager(scope string, options *DeploymentsClientListAtScopeOptions) *runtime.Pager[DeploymentsClientListAtScopeResponse] { - return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListAtScopeResponse]{ - More: func(page DeploymentsClientListAtScopeResponse) bool { +// - options - ClientListAtScopeOptions contains the optional parameters for the Client.NewListAtScopePager method. +func (client *Client) NewListAtScopePager(scope string, options *ClientListAtScopeOptions) *runtime.Pager[ClientListAtScopeResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtScopeResponse]{ + More: func(page ClientListAtScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *DeploymentsClientListAtScopeResponse) (DeploymentsClientListAtScopeResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeploymentsClient.NewListAtScopePager") + Fetcher: func(ctx context.Context, page *ClientListAtScopeResponse) (ClientListAtScopeResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListAtScopePager") nextLink := "" if page != nil { nextLink = *page.NextLink @@ -2081,7 +2066,7 @@ func (client *DeploymentsClient) NewListAtScopePager(scope string, options *Depl return client.listAtScopeCreateRequest(ctx, scope, options) }, nil) if err != nil { - return DeploymentsClientListAtScopeResponse{}, err + return ClientListAtScopeResponse{}, err } return client.listAtScopeHandleResponse(resp) }, @@ -2090,7 +2075,7 @@ func (client *DeploymentsClient) NewListAtScopePager(scope string, options *Depl } // listAtScopeCreateRequest creates the ListAtScope request. -func (client *DeploymentsClient) listAtScopeCreateRequest(ctx context.Context, scope string, options *DeploymentsClientListAtScopeOptions) (*policy.Request, error) { +func (client *Client) listAtScopeCreateRequest(ctx context.Context, scope string, options *ClientListAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -2104,33 +2089,33 @@ func (client *DeploymentsClient) listAtScopeCreateRequest(ctx context.Context, s if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listAtScopeHandleResponse handles the ListAtScope response. -func (client *DeploymentsClient) listAtScopeHandleResponse(resp *http.Response) (DeploymentsClientListAtScopeResponse, error) { - result := DeploymentsClientListAtScopeResponse{} +func (client *Client) listAtScopeHandleResponse(resp *http.Response) (ClientListAtScopeResponse, error) { + result := ClientListAtScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentListResult); err != nil { - return DeploymentsClientListAtScopeResponse{}, err + return ClientListAtScopeResponse{}, err } return result, nil } // NewListAtSubscriptionScopePager - Get all the deployments for a subscription. // -// Generated from API version 2024-11-01 -// - options - DeploymentsClientListAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtSubscriptionScopePager +// Generated from API version 2025-04-01 +// - options - ClientListAtSubscriptionScopeOptions contains the optional parameters for the Client.NewListAtSubscriptionScopePager // method. -func (client *DeploymentsClient) NewListAtSubscriptionScopePager(options *DeploymentsClientListAtSubscriptionScopeOptions) *runtime.Pager[DeploymentsClientListAtSubscriptionScopeResponse] { - return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListAtSubscriptionScopeResponse]{ - More: func(page DeploymentsClientListAtSubscriptionScopeResponse) bool { +func (client *Client) NewListAtSubscriptionScopePager(options *ClientListAtSubscriptionScopeOptions) *runtime.Pager[ClientListAtSubscriptionScopeResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtSubscriptionScopeResponse]{ + More: func(page ClientListAtSubscriptionScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *DeploymentsClientListAtSubscriptionScopeResponse) (DeploymentsClientListAtSubscriptionScopeResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeploymentsClient.NewListAtSubscriptionScopePager") + Fetcher: func(ctx context.Context, page *ClientListAtSubscriptionScopeResponse) (ClientListAtSubscriptionScopeResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListAtSubscriptionScopePager") nextLink := "" if page != nil { nextLink = *page.NextLink @@ -2139,7 +2124,7 @@ func (client *DeploymentsClient) NewListAtSubscriptionScopePager(options *Deploy return client.listAtSubscriptionScopeCreateRequest(ctx, options) }, nil) if err != nil { - return DeploymentsClientListAtSubscriptionScopeResponse{}, err + return ClientListAtSubscriptionScopeResponse{}, err } return client.listAtSubscriptionScopeHandleResponse(resp) }, @@ -2148,7 +2133,7 @@ func (client *DeploymentsClient) NewListAtSubscriptionScopePager(options *Deploy } // listAtSubscriptionScopeCreateRequest creates the ListAtSubscriptionScope request. -func (client *DeploymentsClient) listAtSubscriptionScopeCreateRequest(ctx context.Context, options *DeploymentsClientListAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) listAtSubscriptionScopeCreateRequest(ctx context.Context, options *ClientListAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -2165,33 +2150,32 @@ func (client *DeploymentsClient) listAtSubscriptionScopeCreateRequest(ctx contex if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listAtSubscriptionScopeHandleResponse handles the ListAtSubscriptionScope response. -func (client *DeploymentsClient) listAtSubscriptionScopeHandleResponse(resp *http.Response) (DeploymentsClientListAtSubscriptionScopeResponse, error) { - result := DeploymentsClientListAtSubscriptionScopeResponse{} +func (client *Client) listAtSubscriptionScopeHandleResponse(resp *http.Response) (ClientListAtSubscriptionScopeResponse, error) { + result := ClientListAtSubscriptionScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentListResult); err != nil { - return DeploymentsClientListAtSubscriptionScopeResponse{}, err + return ClientListAtSubscriptionScopeResponse{}, err } return result, nil } // NewListAtTenantScopePager - Get all the deployments at the tenant scope. // -// Generated from API version 2024-11-01 -// - options - DeploymentsClientListAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtTenantScopePager -// method. -func (client *DeploymentsClient) NewListAtTenantScopePager(options *DeploymentsClientListAtTenantScopeOptions) *runtime.Pager[DeploymentsClientListAtTenantScopeResponse] { - return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListAtTenantScopeResponse]{ - More: func(page DeploymentsClientListAtTenantScopeResponse) bool { +// Generated from API version 2025-04-01 +// - options - ClientListAtTenantScopeOptions contains the optional parameters for the Client.NewListAtTenantScopePager method. +func (client *Client) NewListAtTenantScopePager(options *ClientListAtTenantScopeOptions) *runtime.Pager[ClientListAtTenantScopeResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtTenantScopeResponse]{ + More: func(page ClientListAtTenantScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *DeploymentsClientListAtTenantScopeResponse) (DeploymentsClientListAtTenantScopeResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeploymentsClient.NewListAtTenantScopePager") + Fetcher: func(ctx context.Context, page *ClientListAtTenantScopeResponse) (ClientListAtTenantScopeResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListAtTenantScopePager") nextLink := "" if page != nil { nextLink = *page.NextLink @@ -2200,7 +2184,7 @@ func (client *DeploymentsClient) NewListAtTenantScopePager(options *DeploymentsC return client.listAtTenantScopeCreateRequest(ctx, options) }, nil) if err != nil { - return DeploymentsClientListAtTenantScopeResponse{}, err + return ClientListAtTenantScopeResponse{}, err } return client.listAtTenantScopeHandleResponse(resp) }, @@ -2209,7 +2193,7 @@ func (client *DeploymentsClient) NewListAtTenantScopePager(options *DeploymentsC } // listAtTenantScopeCreateRequest creates the ListAtTenantScope request. -func (client *DeploymentsClient) listAtTenantScopeCreateRequest(ctx context.Context, options *DeploymentsClientListAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) listAtTenantScopeCreateRequest(ctx context.Context, options *ClientListAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { @@ -2222,34 +2206,34 @@ func (client *DeploymentsClient) listAtTenantScopeCreateRequest(ctx context.Cont if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listAtTenantScopeHandleResponse handles the ListAtTenantScope response. -func (client *DeploymentsClient) listAtTenantScopeHandleResponse(resp *http.Response) (DeploymentsClientListAtTenantScopeResponse, error) { - result := DeploymentsClientListAtTenantScopeResponse{} +func (client *Client) listAtTenantScopeHandleResponse(resp *http.Response) (ClientListAtTenantScopeResponse, error) { + result := ClientListAtTenantScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentListResult); err != nil { - return DeploymentsClientListAtTenantScopeResponse{}, err + return ClientListAtTenantScopeResponse{}, err } return result, nil } // NewListByResourceGroupPager - Get all the deployments for a resource group. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group with the deployments to get. The name is case insensitive. -// - options - DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByResourceGroupPager +// - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager // method. -func (client *DeploymentsClient) NewListByResourceGroupPager(resourceGroupName string, options *DeploymentsClientListByResourceGroupOptions) *runtime.Pager[DeploymentsClientListByResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListByResourceGroupResponse]{ - More: func(page DeploymentsClientListByResourceGroupResponse) bool { +func (client *Client) NewListByResourceGroupPager(resourceGroupName string, options *ClientListByResourceGroupOptions) *runtime.Pager[ClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListByResourceGroupResponse]{ + More: func(page ClientListByResourceGroupResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *DeploymentsClientListByResourceGroupResponse) (DeploymentsClientListByResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeploymentsClient.NewListByResourceGroupPager") + Fetcher: func(ctx context.Context, page *ClientListByResourceGroupResponse) (ClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListByResourceGroupPager") nextLink := "" if page != nil { nextLink = *page.NextLink @@ -2258,7 +2242,7 @@ func (client *DeploymentsClient) NewListByResourceGroupPager(resourceGroupName s return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) }, nil) if err != nil { - return DeploymentsClientListByResourceGroupResponse{}, err + return ClientListByResourceGroupResponse{}, err } return client.listByResourceGroupHandleResponse(resp) }, @@ -2267,7 +2251,7 @@ func (client *DeploymentsClient) NewListByResourceGroupPager(resourceGroupName s } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *DeploymentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DeploymentsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -2288,17 +2272,17 @@ func (client *DeploymentsClient) listByResourceGroupCreateRequest(ctx context.Co if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // listByResourceGroupHandleResponse handles the ListByResourceGroup response. -func (client *DeploymentsClient) listByResourceGroupHandleResponse(resp *http.Response) (DeploymentsClientListByResourceGroupResponse, error) { - result := DeploymentsClientListByResourceGroupResponse{} +func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (ClientListByResourceGroupResponse, error) { + result := ClientListByResourceGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentListResult); err != nil { - return DeploymentsClientListByResourceGroupResponse{}, err + return ClientListByResourceGroupResponse{}, err } return result, nil } @@ -2307,24 +2291,23 @@ func (client *DeploymentsClient) listByResourceGroupHandleResponse(resp *http.Re // Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group the template will be deployed to. The name is case insensitive. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginValidateOptions contains the optional parameters for the DeploymentsClient.BeginValidate -// method. -func (client *DeploymentsClient) BeginValidate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateOptions) (*runtime.Poller[DeploymentsClientValidateResponse], error) { +// - options - ClientBeginValidateOptions contains the optional parameters for the Client.BeginValidate method. +func (client *Client) BeginValidate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *ClientBeginValidateOptions) (*runtime.Poller[ClientValidateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.validate(ctx, resourceGroupName, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientValidateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientValidateResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2333,10 +2316,10 @@ func (client *DeploymentsClient) BeginValidate(ctx context.Context, resourceGrou // Validate - Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) validate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) validate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *ClientBeginValidateOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginValidate" + const operationName = "Client.BeginValidate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2356,7 +2339,7 @@ func (client *DeploymentsClient) validate(ctx context.Context, resourceGroupName } // validateCreateRequest creates the Validate request. -func (client *DeploymentsClient) validateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateOptions) (*policy.Request, error) { +func (client *Client) validateCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, _ *ClientBeginValidateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -2375,7 +2358,7 @@ func (client *DeploymentsClient) validateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2388,24 +2371,24 @@ func (client *DeploymentsClient) validateCreateRequest(ctx context.Context, reso // by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginValidateAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtManagementGroupScope +// - options - ClientBeginValidateAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginValidateAtManagementGroupScope // method. -func (client *DeploymentsClient) BeginValidateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtManagementGroupScopeOptions) (*runtime.Poller[DeploymentsClientValidateAtManagementGroupScopeResponse], error) { +func (client *Client) BeginValidateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *ClientBeginValidateAtManagementGroupScopeOptions) (*runtime.Poller[ClientValidateAtManagementGroupScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.validateAtManagementGroupScope(ctx, groupID, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientValidateAtManagementGroupScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateAtManagementGroupScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientValidateAtManagementGroupScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateAtManagementGroupScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2415,10 +2398,10 @@ func (client *DeploymentsClient) BeginValidateAtManagementGroupScope(ctx context // by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) validateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtManagementGroupScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) validateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *ClientBeginValidateAtManagementGroupScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginValidateAtManagementGroupScope" + const operationName = "Client.BeginValidateAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2438,7 +2421,7 @@ func (client *DeploymentsClient) validateAtManagementGroupScope(ctx context.Cont } // validateAtManagementGroupScopeCreateRequest creates the ValidateAtManagementGroupScope request. -func (client *DeploymentsClient) validateAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) validateAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, _ *ClientBeginValidateAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -2453,7 +2436,7 @@ func (client *DeploymentsClient) validateAtManagementGroupScopeCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2466,24 +2449,23 @@ func (client *DeploymentsClient) validateAtManagementGroupScopeCreateRequest(ctx // Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginValidateAtScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtScope -// method. -func (client *DeploymentsClient) BeginValidateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtScopeOptions) (*runtime.Poller[DeploymentsClientValidateAtScopeResponse], error) { +// - options - ClientBeginValidateAtScopeOptions contains the optional parameters for the Client.BeginValidateAtScope method. +func (client *Client) BeginValidateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *ClientBeginValidateAtScopeOptions) (*runtime.Poller[ClientValidateAtScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.validateAtScope(ctx, scope, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientValidateAtScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateAtScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientValidateAtScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateAtScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2493,10 +2475,10 @@ func (client *DeploymentsClient) BeginValidateAtScope(ctx context.Context, scope // Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) validateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) validateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *ClientBeginValidateAtScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginValidateAtScope" + const operationName = "Client.BeginValidateAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2516,7 +2498,7 @@ func (client *DeploymentsClient) validateAtScope(ctx context.Context, scope stri } // validateAtScopeCreateRequest creates the ValidateAtScope request. -func (client *DeploymentsClient) validateAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtScopeOptions) (*policy.Request, error) { +func (client *Client) validateAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, parameters Deployment, _ *ClientBeginValidateAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -2528,7 +2510,7 @@ func (client *DeploymentsClient) validateAtScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2541,23 +2523,23 @@ func (client *DeploymentsClient) validateAtScopeCreateRequest(ctx context.Contex // by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginValidateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtSubscriptionScope +// - options - ClientBeginValidateAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginValidateAtSubscriptionScope // method. -func (client *DeploymentsClient) BeginValidateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtSubscriptionScopeOptions) (*runtime.Poller[DeploymentsClientValidateAtSubscriptionScopeResponse], error) { +func (client *Client) BeginValidateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *ClientBeginValidateAtSubscriptionScopeOptions) (*runtime.Poller[ClientValidateAtSubscriptionScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.validateAtSubscriptionScope(ctx, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientValidateAtSubscriptionScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateAtSubscriptionScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientValidateAtSubscriptionScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateAtSubscriptionScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2567,10 +2549,10 @@ func (client *DeploymentsClient) BeginValidateAtSubscriptionScope(ctx context.Co // Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) validateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtSubscriptionScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) validateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *ClientBeginValidateAtSubscriptionScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginValidateAtSubscriptionScope" + const operationName = "Client.BeginValidateAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2590,7 +2572,7 @@ func (client *DeploymentsClient) validateAtSubscriptionScope(ctx context.Context } // validateAtSubscriptionScopeCreateRequest creates the ValidateAtSubscriptionScope request. -func (client *DeploymentsClient) validateAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) validateAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, parameters Deployment, _ *ClientBeginValidateAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -2605,7 +2587,7 @@ func (client *DeploymentsClient) validateAtSubscriptionScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2618,23 +2600,23 @@ func (client *DeploymentsClient) validateAtSubscriptionScopeCreateRequest(ctx co // Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginValidateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtTenantScope +// - options - ClientBeginValidateAtTenantScopeOptions contains the optional parameters for the Client.BeginValidateAtTenantScope // method. -func (client *DeploymentsClient) BeginValidateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtTenantScopeOptions) (*runtime.Poller[DeploymentsClientValidateAtTenantScopeResponse], error) { +func (client *Client) BeginValidateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *ClientBeginValidateAtTenantScopeOptions) (*runtime.Poller[ClientValidateAtTenantScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.validateAtTenantScope(ctx, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientValidateAtTenantScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateAtTenantScopeResponse]{ Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientValidateAtTenantScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateAtTenantScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2644,10 +2626,10 @@ func (client *DeploymentsClient) BeginValidateAtTenantScope(ctx context.Context, // Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) validateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtTenantScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) validateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *ClientBeginValidateAtTenantScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginValidateAtTenantScope" + const operationName = "Client.BeginValidateAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2667,7 +2649,7 @@ func (client *DeploymentsClient) validateAtTenantScope(ctx context.Context, depl } // validateAtTenantScopeCreateRequest creates the ValidateAtTenantScope request. -func (client *DeploymentsClient) validateAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) validateAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, parameters ScopedDeployment, _ *ClientBeginValidateAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}/validate" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -2678,7 +2660,7 @@ func (client *DeploymentsClient) validateAtTenantScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2690,24 +2672,24 @@ func (client *DeploymentsClient) validateAtTenantScopeCreateRequest(ctx context. // BeginWhatIf - Returns changes that will be made by the deployment if executed at the scope of the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group the template will be deployed to. The name is case insensitive. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginWhatIfOptions contains the optional parameters for the DeploymentsClient.BeginWhatIf method. -func (client *DeploymentsClient) BeginWhatIf(ctx context.Context, resourceGroupName string, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfOptions) (*runtime.Poller[DeploymentsClientWhatIfResponse], error) { +// - options - ClientBeginWhatIfOptions contains the optional parameters for the Client.BeginWhatIf method. +func (client *Client) BeginWhatIf(ctx context.Context, resourceGroupName string, deploymentName string, parameters DeploymentWhatIf, options *ClientBeginWhatIfOptions) (*runtime.Poller[ClientWhatIfResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.whatIf(ctx, resourceGroupName, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientWhatIfResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientWhatIfResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientWhatIfResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientWhatIfResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2716,10 +2698,10 @@ func (client *DeploymentsClient) BeginWhatIf(ctx context.Context, resourceGroupN // WhatIf - Returns changes that will be made by the deployment if executed at the scope of the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) whatIf(ctx context.Context, resourceGroupName string, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) whatIf(ctx context.Context, resourceGroupName string, deploymentName string, parameters DeploymentWhatIf, options *ClientBeginWhatIfOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginWhatIf" + const operationName = "Client.BeginWhatIf" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2739,7 +2721,7 @@ func (client *DeploymentsClient) whatIf(ctx context.Context, resourceGroupName s } // whatIfCreateRequest creates the WhatIf request. -func (client *DeploymentsClient) whatIfCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfOptions) (*policy.Request, error) { +func (client *Client) whatIfCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, parameters DeploymentWhatIf, _ *ClientBeginWhatIfOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -2758,7 +2740,7 @@ func (client *DeploymentsClient) whatIfCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2771,25 +2753,25 @@ func (client *DeploymentsClient) whatIfCreateRequest(ctx context.Context, resour // management group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtManagementGroupScope +// - options - ClientBeginWhatIfAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginWhatIfAtManagementGroupScope // method. -func (client *DeploymentsClient) BeginWhatIfAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions) (*runtime.Poller[DeploymentsClientWhatIfAtManagementGroupScopeResponse], error) { +func (client *Client) BeginWhatIfAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeploymentWhatIf, options *ClientBeginWhatIfAtManagementGroupScopeOptions) (*runtime.Poller[ClientWhatIfAtManagementGroupScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.whatIfAtManagementGroupScope(ctx, groupID, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientWhatIfAtManagementGroupScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientWhatIfAtManagementGroupScopeResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientWhatIfAtManagementGroupScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientWhatIfAtManagementGroupScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2799,10 +2781,10 @@ func (client *DeploymentsClient) BeginWhatIfAtManagementGroupScope(ctx context.C // group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) whatIfAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) whatIfAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeploymentWhatIf, options *ClientBeginWhatIfAtManagementGroupScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginWhatIfAtManagementGroupScope" + const operationName = "Client.BeginWhatIfAtManagementGroupScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2822,7 +2804,7 @@ func (client *DeploymentsClient) whatIfAtManagementGroupScope(ctx context.Contex } // whatIfAtManagementGroupScopeCreateRequest creates the WhatIfAtManagementGroupScope request. -func (client *DeploymentsClient) whatIfAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *Client) whatIfAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeploymentWhatIf, _ *ClientBeginWhatIfAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -2837,7 +2819,7 @@ func (client *DeploymentsClient) whatIfAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2849,24 +2831,24 @@ func (client *DeploymentsClient) whatIfAtManagementGroupScopeCreateRequest(ctx c // BeginWhatIfAtSubscriptionScope - Returns changes that will be made by the deployment if executed at the scope of the subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to What If. -// - options - DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtSubscriptionScope +// - options - ClientBeginWhatIfAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginWhatIfAtSubscriptionScope // method. -func (client *DeploymentsClient) BeginWhatIfAtSubscriptionScope(ctx context.Context, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions) (*runtime.Poller[DeploymentsClientWhatIfAtSubscriptionScopeResponse], error) { +func (client *Client) BeginWhatIfAtSubscriptionScope(ctx context.Context, deploymentName string, parameters DeploymentWhatIf, options *ClientBeginWhatIfAtSubscriptionScopeOptions) (*runtime.Poller[ClientWhatIfAtSubscriptionScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.whatIfAtSubscriptionScope(ctx, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientWhatIfAtSubscriptionScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientWhatIfAtSubscriptionScopeResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientWhatIfAtSubscriptionScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientWhatIfAtSubscriptionScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2875,10 +2857,10 @@ func (client *DeploymentsClient) BeginWhatIfAtSubscriptionScope(ctx context.Cont // WhatIfAtSubscriptionScope - Returns changes that will be made by the deployment if executed at the scope of the subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) whatIfAtSubscriptionScope(ctx context.Context, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) whatIfAtSubscriptionScope(ctx context.Context, deploymentName string, parameters DeploymentWhatIf, options *ClientBeginWhatIfAtSubscriptionScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginWhatIfAtSubscriptionScope" + const operationName = "Client.BeginWhatIfAtSubscriptionScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2898,7 +2880,7 @@ func (client *DeploymentsClient) whatIfAtSubscriptionScope(ctx context.Context, } // whatIfAtSubscriptionScopeCreateRequest creates the WhatIfAtSubscriptionScope request. -func (client *DeploymentsClient) whatIfAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *Client) whatIfAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, parameters DeploymentWhatIf, _ *ClientBeginWhatIfAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -2913,7 +2895,7 @@ func (client *DeploymentsClient) whatIfAtSubscriptionScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2925,24 +2907,24 @@ func (client *DeploymentsClient) whatIfAtSubscriptionScopeCreateRequest(ctx cont // BeginWhatIfAtTenantScope - Returns changes that will be made by the deployment if executed at the scope of the tenant group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. -// - options - DeploymentsClientBeginWhatIfAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtTenantScope +// - options - ClientBeginWhatIfAtTenantScopeOptions contains the optional parameters for the Client.BeginWhatIfAtTenantScope // method. -func (client *DeploymentsClient) BeginWhatIfAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtTenantScopeOptions) (*runtime.Poller[DeploymentsClientWhatIfAtTenantScopeResponse], error) { +func (client *Client) BeginWhatIfAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeploymentWhatIf, options *ClientBeginWhatIfAtTenantScopeOptions) (*runtime.Poller[ClientWhatIfAtTenantScopeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.whatIfAtTenantScope(ctx, deploymentName, parameters, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeploymentsClientWhatIfAtTenantScopeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientWhatIfAtTenantScopeResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeploymentsClientWhatIfAtTenantScopeResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientWhatIfAtTenantScopeResponse]{ Tracer: client.internal.Tracer(), }) } @@ -2951,10 +2933,10 @@ func (client *DeploymentsClient) BeginWhatIfAtTenantScope(ctx context.Context, d // WhatIfAtTenantScope - Returns changes that will be made by the deployment if executed at the scope of the tenant group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 -func (client *DeploymentsClient) whatIfAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtTenantScopeOptions) (*http.Response, error) { +// Generated from API version 2025-04-01 +func (client *Client) whatIfAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeploymentWhatIf, options *ClientBeginWhatIfAtTenantScopeOptions) (*http.Response, error) { var err error - const operationName = "DeploymentsClient.BeginWhatIfAtTenantScope" + const operationName = "Client.BeginWhatIfAtTenantScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() @@ -2974,7 +2956,7 @@ func (client *DeploymentsClient) whatIfAtTenantScope(ctx context.Context, deploy } // whatIfAtTenantScopeCreateRequest creates the WhatIfAtTenantScope request. -func (client *DeploymentsClient) whatIfAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtTenantScopeOptions) (*policy.Request, error) { +func (client *Client) whatIfAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, parameters ScopedDeploymentWhatIf, _ *ClientBeginWhatIfAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -2985,7 +2967,7 @@ func (client *DeploymentsClient) whatIfAtTenantScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/deployments/deployments/client_factory.go b/sdk/resourcemanager/deployments/deployments/client_factory.go new file mode 100644 index 000000000000..cb16da41fec5 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/client_factory.go @@ -0,0 +1,50 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deployments + +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 + internal *arm.Client +} + +// 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 Microsoft 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) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewDeploymentOperationsClient creates a new instance of DeploymentOperationsClient. +func (c *ClientFactory) NewDeploymentOperationsClient() *DeploymentOperationsClient { + return &DeploymentOperationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/deployments/deployments/constants.go b/sdk/resourcemanager/deployments/deployments/constants.go new file mode 100644 index 000000000000..f8181861c34e --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/constants.go @@ -0,0 +1,432 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deployments + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deployments" + moduleVersion = "v0.1.0" +) + +// AliasPathAttributes - The attributes of the token that the alias path is referring to. +type AliasPathAttributes string + +const ( + // AliasPathAttributesModifiable - The token that the alias path is referring to is modifiable by policies with 'modify' effect. + AliasPathAttributesModifiable AliasPathAttributes = "Modifiable" + // AliasPathAttributesNone - The token that the alias path is referring to has no attributes. + AliasPathAttributesNone AliasPathAttributes = "None" +) + +// PossibleAliasPathAttributesValues returns the possible values for the AliasPathAttributes const type. +func PossibleAliasPathAttributesValues() []AliasPathAttributes { + return []AliasPathAttributes{ + AliasPathAttributesModifiable, + AliasPathAttributesNone, + } +} + +// AliasPathTokenType - The type of the token that the alias path is referring to. +type AliasPathTokenType string + +const ( + // AliasPathTokenTypeAny - The token type can be anything. + AliasPathTokenTypeAny AliasPathTokenType = "Any" + // AliasPathTokenTypeArray - The token type is array. + AliasPathTokenTypeArray AliasPathTokenType = "Array" + // AliasPathTokenTypeBoolean - The token type is boolean. + AliasPathTokenTypeBoolean AliasPathTokenType = "Boolean" + // AliasPathTokenTypeInteger - The token type is integer. + AliasPathTokenTypeInteger AliasPathTokenType = "Integer" + // AliasPathTokenTypeNotSpecified - The token type is not specified. + AliasPathTokenTypeNotSpecified AliasPathTokenType = "NotSpecified" + // AliasPathTokenTypeNumber - The token type is number. + AliasPathTokenTypeNumber AliasPathTokenType = "Number" + // AliasPathTokenTypeObject - The token type is object. + AliasPathTokenTypeObject AliasPathTokenType = "Object" + // AliasPathTokenTypeString - The token type is string. + AliasPathTokenTypeString AliasPathTokenType = "String" +) + +// PossibleAliasPathTokenTypeValues returns the possible values for the AliasPathTokenType const type. +func PossibleAliasPathTokenTypeValues() []AliasPathTokenType { + return []AliasPathTokenType{ + AliasPathTokenTypeAny, + AliasPathTokenTypeArray, + AliasPathTokenTypeBoolean, + AliasPathTokenTypeInteger, + AliasPathTokenTypeNotSpecified, + AliasPathTokenTypeNumber, + AliasPathTokenTypeObject, + AliasPathTokenTypeString, + } +} + +// AliasPatternType - The type of alias pattern +type AliasPatternType string + +const ( + // AliasPatternTypeExtract - Extract is the only allowed value. + AliasPatternTypeExtract AliasPatternType = "Extract" + // AliasPatternTypeNotSpecified - NotSpecified is not allowed. + AliasPatternTypeNotSpecified AliasPatternType = "NotSpecified" +) + +// PossibleAliasPatternTypeValues returns the possible values for the AliasPatternType const type. +func PossibleAliasPatternTypeValues() []AliasPatternType { + return []AliasPatternType{ + AliasPatternTypeExtract, + AliasPatternTypeNotSpecified, + } +} + +// AliasType - The type of the alias. +type AliasType string + +const ( + // AliasTypeMask - Alias value is secret. + AliasTypeMask AliasType = "Mask" + // AliasTypeNotSpecified - Alias type is unknown (same as not providing alias type). + AliasTypeNotSpecified AliasType = "NotSpecified" + // AliasTypePlainText - Alias value is not secret. + AliasTypePlainText AliasType = "PlainText" +) + +// PossibleAliasTypeValues returns the possible values for the AliasType const type. +func PossibleAliasTypeValues() []AliasType { + return []AliasType{ + AliasTypeMask, + AliasTypeNotSpecified, + AliasTypePlainText, + } +} + +// ChangeType - Type of change that will be made to the resource when the deployment is executed. +type ChangeType string + +const ( + // ChangeTypeCreate - The resource does not exist in the current state but is present in the desired state. The resource will + // be created when the deployment is executed. + ChangeTypeCreate ChangeType = "Create" + // ChangeTypeDelete - The resource exists in the current state and is missing from the desired state. The resource will be + // deleted when the deployment is executed. + ChangeTypeDelete ChangeType = "Delete" + // ChangeTypeDeploy - The resource exists in the current state and the desired state and will be redeployed when the deployment + // is executed. The properties of the resource may or may not change. + ChangeTypeDeploy ChangeType = "Deploy" + // ChangeTypeIgnore - The resource exists in the current state and is missing from the desired state. The resource will not + // be deployed or modified when the deployment is executed. + ChangeTypeIgnore ChangeType = "Ignore" + // ChangeTypeModify - The resource exists in the current state and the desired state and will be redeployed when the deployment + // is executed. The properties of the resource will change. + ChangeTypeModify ChangeType = "Modify" + // ChangeTypeNoChange - The resource exists in the current state and the desired state and will be redeployed when the deployment + // is executed. The properties of the resource will not change. + ChangeTypeNoChange ChangeType = "NoChange" + // ChangeTypeUnsupported - The resource is not supported by What-If. + ChangeTypeUnsupported ChangeType = "Unsupported" +) + +// PossibleChangeTypeValues returns the possible values for the ChangeType const type. +func PossibleChangeTypeValues() []ChangeType { + return []ChangeType{ + ChangeTypeCreate, + ChangeTypeDelete, + ChangeTypeDeploy, + ChangeTypeIgnore, + ChangeTypeModify, + ChangeTypeNoChange, + ChangeTypeUnsupported, + } +} + +// DeploymentIdentityType - The identity type. +type DeploymentIdentityType string + +const ( + DeploymentIdentityTypeNone DeploymentIdentityType = "None" + DeploymentIdentityTypeUserAssigned DeploymentIdentityType = "UserAssigned" +) + +// PossibleDeploymentIdentityTypeValues returns the possible values for the DeploymentIdentityType const type. +func PossibleDeploymentIdentityTypeValues() []DeploymentIdentityType { + return []DeploymentIdentityType{ + DeploymentIdentityTypeNone, + DeploymentIdentityTypeUserAssigned, + } +} + +// DeploymentMode - The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental +// mode, resources are deployed without deleting existing resources that are not included in +// the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included +// in the template are deleted. Be careful when using Complete mode as you may +// unintentionally delete resources. +type DeploymentMode string + +const ( + DeploymentModeComplete DeploymentMode = "Complete" + DeploymentModeIncremental DeploymentMode = "Incremental" +) + +// PossibleDeploymentModeValues returns the possible values for the DeploymentMode const type. +func PossibleDeploymentModeValues() []DeploymentMode { + return []DeploymentMode{ + DeploymentModeComplete, + DeploymentModeIncremental, + } +} + +// ExpressionEvaluationOptionsScopeType - The scope to be used for evaluation of parameters, variables and functions in a +// nested template. +type ExpressionEvaluationOptionsScopeType string + +const ( + ExpressionEvaluationOptionsScopeTypeInner ExpressionEvaluationOptionsScopeType = "Inner" + ExpressionEvaluationOptionsScopeTypeNotSpecified ExpressionEvaluationOptionsScopeType = "NotSpecified" + ExpressionEvaluationOptionsScopeTypeOuter ExpressionEvaluationOptionsScopeType = "Outer" +) + +// PossibleExpressionEvaluationOptionsScopeTypeValues returns the possible values for the ExpressionEvaluationOptionsScopeType const type. +func PossibleExpressionEvaluationOptionsScopeTypeValues() []ExpressionEvaluationOptionsScopeType { + return []ExpressionEvaluationOptionsScopeType{ + ExpressionEvaluationOptionsScopeTypeInner, + ExpressionEvaluationOptionsScopeTypeNotSpecified, + ExpressionEvaluationOptionsScopeTypeOuter, + } +} + +type ExtensionConfigPropertyType string + +const ( + // ExtensionConfigPropertyTypeArray - Property type representing an array value. + ExtensionConfigPropertyTypeArray ExtensionConfigPropertyType = "Array" + // ExtensionConfigPropertyTypeBool - Property type representing a boolean value. + ExtensionConfigPropertyTypeBool ExtensionConfigPropertyType = "Bool" + // ExtensionConfigPropertyTypeInt - Property type representing an integer value. + ExtensionConfigPropertyTypeInt ExtensionConfigPropertyType = "Int" + // ExtensionConfigPropertyTypeObject - Property type representing an object value. + ExtensionConfigPropertyTypeObject ExtensionConfigPropertyType = "Object" + // ExtensionConfigPropertyTypeSecureObject - Property type representing a secure object value. + ExtensionConfigPropertyTypeSecureObject ExtensionConfigPropertyType = "SecureObject" + // ExtensionConfigPropertyTypeSecureString - Property type representing a secure string value. + ExtensionConfigPropertyTypeSecureString ExtensionConfigPropertyType = "SecureString" + // ExtensionConfigPropertyTypeString - Property type representing a string value. + ExtensionConfigPropertyTypeString ExtensionConfigPropertyType = "String" +) + +// PossibleExtensionConfigPropertyTypeValues returns the possible values for the ExtensionConfigPropertyType const type. +func PossibleExtensionConfigPropertyTypeValues() []ExtensionConfigPropertyType { + return []ExtensionConfigPropertyType{ + ExtensionConfigPropertyTypeArray, + ExtensionConfigPropertyTypeBool, + ExtensionConfigPropertyTypeInt, + ExtensionConfigPropertyTypeObject, + ExtensionConfigPropertyTypeSecureObject, + ExtensionConfigPropertyTypeSecureString, + ExtensionConfigPropertyTypeString, + } +} + +// Level - Denotes the additional response level. +type Level string + +const ( + LevelError Level = "Error" + LevelInfo Level = "Info" + LevelWarning Level = "Warning" +) + +// PossibleLevelValues returns the possible values for the Level const type. +func PossibleLevelValues() []Level { + return []Level{ + LevelError, + LevelInfo, + LevelWarning, + } +} + +// OnErrorDeploymentType - The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. +type OnErrorDeploymentType string + +const ( + OnErrorDeploymentTypeLastSuccessful OnErrorDeploymentType = "LastSuccessful" + OnErrorDeploymentTypeSpecificDeployment OnErrorDeploymentType = "SpecificDeployment" +) + +// PossibleOnErrorDeploymentTypeValues returns the possible values for the OnErrorDeploymentType const type. +func PossibleOnErrorDeploymentTypeValues() []OnErrorDeploymentType { + return []OnErrorDeploymentType{ + OnErrorDeploymentTypeLastSuccessful, + OnErrorDeploymentTypeSpecificDeployment, + } +} + +// PropertyChangeType - The type of property change. +type PropertyChangeType string + +const ( + // PropertyChangeTypeArray - The property is an array and contains nested changes. + PropertyChangeTypeArray PropertyChangeType = "Array" + // PropertyChangeTypeCreate - The property does not exist in the current state but is present in the desired state. The property + // will be created when the deployment is executed. + PropertyChangeTypeCreate PropertyChangeType = "Create" + // PropertyChangeTypeDelete - The property exists in the current state and is missing from the desired state. It will be deleted + // when the deployment is executed. + PropertyChangeTypeDelete PropertyChangeType = "Delete" + // PropertyChangeTypeModify - The property exists in both current and desired state and is different. The value of the property + // will change when the deployment is executed. + PropertyChangeTypeModify PropertyChangeType = "Modify" + // PropertyChangeTypeNoEffect - The property will not be set or updated. + PropertyChangeTypeNoEffect PropertyChangeType = "NoEffect" +) + +// PossiblePropertyChangeTypeValues returns the possible values for the PropertyChangeType const type. +func PossiblePropertyChangeTypeValues() []PropertyChangeType { + return []PropertyChangeType{ + PropertyChangeTypeArray, + PropertyChangeTypeCreate, + PropertyChangeTypeDelete, + PropertyChangeTypeModify, + PropertyChangeTypeNoEffect, + } +} + +// ProviderAuthorizationConsentState - The provider authorization consent state. +type ProviderAuthorizationConsentState string + +const ( + ProviderAuthorizationConsentStateConsented ProviderAuthorizationConsentState = "Consented" + ProviderAuthorizationConsentStateNotRequired ProviderAuthorizationConsentState = "NotRequired" + ProviderAuthorizationConsentStateNotSpecified ProviderAuthorizationConsentState = "NotSpecified" + ProviderAuthorizationConsentStateRequired ProviderAuthorizationConsentState = "Required" +) + +// PossibleProviderAuthorizationConsentStateValues returns the possible values for the ProviderAuthorizationConsentState const type. +func PossibleProviderAuthorizationConsentStateValues() []ProviderAuthorizationConsentState { + return []ProviderAuthorizationConsentState{ + ProviderAuthorizationConsentStateConsented, + ProviderAuthorizationConsentStateNotRequired, + ProviderAuthorizationConsentStateNotSpecified, + ProviderAuthorizationConsentStateRequired, + } +} + +// ProvisioningOperation - The name of the current provisioning operation. +type ProvisioningOperation string + +const ( + // ProvisioningOperationAction - The provisioning operation is action. + ProvisioningOperationAction ProvisioningOperation = "Action" + // ProvisioningOperationAzureAsyncOperationWaiting - The provisioning operation is waiting Azure async operation. + ProvisioningOperationAzureAsyncOperationWaiting ProvisioningOperation = "AzureAsyncOperationWaiting" + // ProvisioningOperationCreate - The provisioning operation is create. + ProvisioningOperationCreate ProvisioningOperation = "Create" + // ProvisioningOperationDelete - The provisioning operation is delete. + ProvisioningOperationDelete ProvisioningOperation = "Delete" + // ProvisioningOperationDeploymentCleanup - The provisioning operation is cleanup. This operation is part of the 'complete' + // mode deployment. + ProvisioningOperationDeploymentCleanup ProvisioningOperation = "DeploymentCleanup" + // ProvisioningOperationEvaluateDeploymentOutput - The provisioning operation is evaluate output. + ProvisioningOperationEvaluateDeploymentOutput ProvisioningOperation = "EvaluateDeploymentOutput" + // ProvisioningOperationNotSpecified - The provisioning operation is not specified. + ProvisioningOperationNotSpecified ProvisioningOperation = "NotSpecified" + // ProvisioningOperationRead - The provisioning operation is read. + ProvisioningOperationRead ProvisioningOperation = "Read" + // ProvisioningOperationResourceCacheWaiting - The provisioning operation is waiting for resource cache. + ProvisioningOperationResourceCacheWaiting ProvisioningOperation = "ResourceCacheWaiting" + // ProvisioningOperationWaiting - The provisioning operation is waiting. + ProvisioningOperationWaiting ProvisioningOperation = "Waiting" +) + +// PossibleProvisioningOperationValues returns the possible values for the ProvisioningOperation const type. +func PossibleProvisioningOperationValues() []ProvisioningOperation { + return []ProvisioningOperation{ + ProvisioningOperationAction, + ProvisioningOperationAzureAsyncOperationWaiting, + ProvisioningOperationCreate, + ProvisioningOperationDelete, + ProvisioningOperationDeploymentCleanup, + ProvisioningOperationEvaluateDeploymentOutput, + ProvisioningOperationNotSpecified, + ProvisioningOperationRead, + ProvisioningOperationResourceCacheWaiting, + ProvisioningOperationWaiting, + } +} + +// ProvisioningState - Denotes the state of provisioning. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateReady ProvisioningState = "Ready" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreated, + ProvisioningStateCreating, + ProvisioningStateDeleted, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateNotSpecified, + ProvisioningStateReady, + ProvisioningStateRunning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ValidationLevel - The level of validation performed on the deployment. +type ValidationLevel string + +const ( + // ValidationLevelProvider - Static analysis of the template is performed and resource declarations are sent to resource providers + // for semantic validation. Validates that the caller has RBAC write permissions on each resource. + ValidationLevelProvider ValidationLevel = "Provider" + // ValidationLevelProviderNoRbac - Static analysis of the template is performed and resource declarations are sent to resource + // providers for semantic validation. Skips validating that the caller has RBAC write permissions on each resource. + ValidationLevelProviderNoRbac ValidationLevel = "ProviderNoRbac" + // ValidationLevelTemplate - Static analysis of the template is performed. + ValidationLevelTemplate ValidationLevel = "Template" +) + +// PossibleValidationLevelValues returns the possible values for the ValidationLevel const type. +func PossibleValidationLevelValues() []ValidationLevel { + return []ValidationLevel{ + ValidationLevelProvider, + ValidationLevelProviderNoRbac, + ValidationLevelTemplate, + } +} + +// WhatIfResultFormat - The format of the What-If results +type WhatIfResultFormat string + +const ( + WhatIfResultFormatFullResourcePayloads WhatIfResultFormat = "FullResourcePayloads" + WhatIfResultFormatResourceIDOnly WhatIfResultFormat = "ResourceIdOnly" +) + +// PossibleWhatIfResultFormatValues returns the possible values for the WhatIfResultFormat const type. +func PossibleWhatIfResultFormatValues() []WhatIfResultFormat { + return []WhatIfResultFormat{ + WhatIfResultFormatFullResourcePayloads, + WhatIfResultFormatResourceIDOnly, + } +} diff --git a/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go b/sdk/resourcemanager/deployments/deployments/deploymentoperations_client.go similarity index 96% rename from sdk/resourcemanager/resources/armresources/deploymentoperations_client.go rename to sdk/resourcemanager/deployments/deployments/deploymentoperations_client.go index cda048d8fc4a..6bc91e51bbaa 100644 --- a/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go +++ b/sdk/resourcemanager/deployments/deployments/deploymentoperations_client.go @@ -1,12 +1,9 @@ -//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. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package armresources +package deployments import ( "context" @@ -47,7 +44,7 @@ func NewDeploymentOperationsClient(subscriptionID string, credential azcore.Toke // Get - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. @@ -76,7 +73,7 @@ func (client *DeploymentOperationsClient) Get(ctx context.Context, resourceGroup } // getCreateRequest creates the Get request. -func (client *DeploymentOperationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, operationID string, options *DeploymentOperationsClientGetOptions) (*policy.Request, error) { +func (client *DeploymentOperationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, deploymentName string, operationID string, _ *DeploymentOperationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -99,7 +96,7 @@ func (client *DeploymentOperationsClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -117,7 +114,7 @@ func (client *DeploymentOperationsClient) getHandleResponse(resp *http.Response) // GetAtManagementGroupScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. @@ -146,7 +143,7 @@ func (client *DeploymentOperationsClient) GetAtManagementGroupScope(ctx context. } // getAtManagementGroupScopeCreateRequest creates the GetAtManagementGroupScope request. -func (client *DeploymentOperationsClient) getAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, operationID string, options *DeploymentOperationsClientGetAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *DeploymentOperationsClient) getAtManagementGroupScopeCreateRequest(ctx context.Context, groupID string, deploymentName string, operationID string, _ *DeploymentOperationsClientGetAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -165,7 +162,7 @@ func (client *DeploymentOperationsClient) getAtManagementGroupScopeCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -183,7 +180,7 @@ func (client *DeploymentOperationsClient) getAtManagementGroupScopeHandleRespons // GetAtScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. @@ -212,7 +209,7 @@ func (client *DeploymentOperationsClient) GetAtScope(ctx context.Context, scope } // getAtScopeCreateRequest creates the GetAtScope request. -func (client *DeploymentOperationsClient) getAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, operationID string, options *DeploymentOperationsClientGetAtScopeOptions) (*policy.Request, error) { +func (client *DeploymentOperationsClient) getAtScopeCreateRequest(ctx context.Context, scope string, deploymentName string, operationID string, _ *DeploymentOperationsClientGetAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if deploymentName == "" { @@ -228,7 +225,7 @@ func (client *DeploymentOperationsClient) getAtScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,7 +243,7 @@ func (client *DeploymentOperationsClient) getAtScopeHandleResponse(resp *http.Re // GetAtSubscriptionScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. // - options - DeploymentOperationsClientGetAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtSubscriptionScope @@ -274,7 +271,7 @@ func (client *DeploymentOperationsClient) GetAtSubscriptionScope(ctx context.Con } // getAtSubscriptionScopeCreateRequest creates the GetAtSubscriptionScope request. -func (client *DeploymentOperationsClient) getAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, operationID string, options *DeploymentOperationsClientGetAtSubscriptionScopeOptions) (*policy.Request, error) { +func (client *DeploymentOperationsClient) getAtSubscriptionScopeCreateRequest(ctx context.Context, deploymentName string, operationID string, _ *DeploymentOperationsClientGetAtSubscriptionScopeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -293,7 +290,7 @@ func (client *DeploymentOperationsClient) getAtSubscriptionScopeCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -311,7 +308,7 @@ func (client *DeploymentOperationsClient) getAtSubscriptionScopeHandleResponse(r // GetAtTenantScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. // - options - DeploymentOperationsClientGetAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtTenantScope @@ -339,7 +336,7 @@ func (client *DeploymentOperationsClient) GetAtTenantScope(ctx context.Context, } // getAtTenantScopeCreateRequest creates the GetAtTenantScope request. -func (client *DeploymentOperationsClient) getAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, operationID string, options *DeploymentOperationsClientGetAtTenantScopeOptions) (*policy.Request, error) { +func (client *DeploymentOperationsClient) getAtTenantScopeCreateRequest(ctx context.Context, deploymentName string, operationID string, _ *DeploymentOperationsClientGetAtTenantScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}" if deploymentName == "" { return nil, errors.New("parameter deploymentName cannot be empty") @@ -354,7 +351,7 @@ func (client *DeploymentOperationsClient) getAtTenantScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,7 +368,7 @@ func (client *DeploymentOperationsClient) getAtTenantScopeHandleResponse(resp *h // NewListPager - Gets all deployments operations for a deployment. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListOptions contains the optional parameters for the DeploymentOperationsClient.NewListPager @@ -422,7 +419,7 @@ func (client *DeploymentOperationsClient) listCreateRequest(ctx context.Context, if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -439,7 +436,7 @@ func (client *DeploymentOperationsClient) listHandleResponse(resp *http.Response // NewListAtManagementGroupScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtManagementGroupScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtManagementGroupScopePager @@ -486,7 +483,7 @@ func (client *DeploymentOperationsClient) listAtManagementGroupScopeCreateReques if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -503,7 +500,7 @@ func (client *DeploymentOperationsClient) listAtManagementGroupScopeHandleRespon // NewListAtScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtScopePager @@ -547,7 +544,7 @@ func (client *DeploymentOperationsClient) listAtScopeCreateRequest(ctx context.C if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -564,7 +561,7 @@ func (client *DeploymentOperationsClient) listAtScopeHandleResponse(resp *http.R // NewListAtSubscriptionScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtSubscriptionScopePager // method. @@ -610,7 +607,7 @@ func (client *DeploymentOperationsClient) listAtSubscriptionScopeCreateRequest(c if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -627,7 +624,7 @@ func (client *DeploymentOperationsClient) listAtSubscriptionScopeHandleResponse( // NewListAtTenantScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtTenantScopePager // method. @@ -669,7 +666,7 @@ func (client *DeploymentOperationsClient) listAtTenantScopeCreateRequest(ctx con if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/fake/deploymentoperations_server.go b/sdk/resourcemanager/deployments/deployments/fake/deploymentoperations_server.go similarity index 78% rename from sdk/resourcemanager/resources/armresources/fake/deploymentoperations_server.go rename to sdk/resourcemanager/deployments/deployments/fake/deploymentoperations_server.go index 0cc2e911e84f..13db27da5013 100644 --- a/sdk/resourcemanager/resources/armresources/fake/deploymentoperations_server.go +++ b/sdk/resourcemanager/deployments/deployments/fake/deploymentoperations_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -16,79 +13,79 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deployments" "net/http" "net/url" "regexp" "strconv" ) -// DeploymentOperationsServer is a fake server for instances of the armresources.DeploymentOperationsClient type. +// DeploymentOperationsServer is a fake server for instances of the deployments.DeploymentOperationsClient type. type DeploymentOperationsServer struct { // Get is the fake for method DeploymentOperationsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, deploymentName string, operationID string, options *armresources.DeploymentOperationsClientGetOptions) (resp azfake.Responder[armresources.DeploymentOperationsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, deploymentName string, operationID string, options *deployments.DeploymentOperationsClientGetOptions) (resp azfake.Responder[deployments.DeploymentOperationsClientGetResponse], errResp azfake.ErrorResponder) // GetAtManagementGroupScope is the fake for method DeploymentOperationsClient.GetAtManagementGroupScope // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, operationID string, options *armresources.DeploymentOperationsClientGetAtManagementGroupScopeOptions) (resp azfake.Responder[armresources.DeploymentOperationsClientGetAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + GetAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, operationID string, options *deployments.DeploymentOperationsClientGetAtManagementGroupScopeOptions) (resp azfake.Responder[deployments.DeploymentOperationsClientGetAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) // GetAtScope is the fake for method DeploymentOperationsClient.GetAtScope // HTTP status codes to indicate success: http.StatusOK - GetAtScope func(ctx context.Context, scope string, deploymentName string, operationID string, options *armresources.DeploymentOperationsClientGetAtScopeOptions) (resp azfake.Responder[armresources.DeploymentOperationsClientGetAtScopeResponse], errResp azfake.ErrorResponder) + GetAtScope func(ctx context.Context, scope string, deploymentName string, operationID string, options *deployments.DeploymentOperationsClientGetAtScopeOptions) (resp azfake.Responder[deployments.DeploymentOperationsClientGetAtScopeResponse], errResp azfake.ErrorResponder) // GetAtSubscriptionScope is the fake for method DeploymentOperationsClient.GetAtSubscriptionScope // HTTP status codes to indicate success: http.StatusOK - GetAtSubscriptionScope func(ctx context.Context, deploymentName string, operationID string, options *armresources.DeploymentOperationsClientGetAtSubscriptionScopeOptions) (resp azfake.Responder[armresources.DeploymentOperationsClientGetAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + GetAtSubscriptionScope func(ctx context.Context, deploymentName string, operationID string, options *deployments.DeploymentOperationsClientGetAtSubscriptionScopeOptions) (resp azfake.Responder[deployments.DeploymentOperationsClientGetAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) // GetAtTenantScope is the fake for method DeploymentOperationsClient.GetAtTenantScope // HTTP status codes to indicate success: http.StatusOK - GetAtTenantScope func(ctx context.Context, deploymentName string, operationID string, options *armresources.DeploymentOperationsClientGetAtTenantScopeOptions) (resp azfake.Responder[armresources.DeploymentOperationsClientGetAtTenantScopeResponse], errResp azfake.ErrorResponder) + GetAtTenantScope func(ctx context.Context, deploymentName string, operationID string, options *deployments.DeploymentOperationsClientGetAtTenantScopeOptions) (resp azfake.Responder[deployments.DeploymentOperationsClientGetAtTenantScopeResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method DeploymentOperationsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(resourceGroupName string, deploymentName string, options *armresources.DeploymentOperationsClientListOptions) (resp azfake.PagerResponder[armresources.DeploymentOperationsClientListResponse]) + NewListPager func(resourceGroupName string, deploymentName string, options *deployments.DeploymentOperationsClientListOptions) (resp azfake.PagerResponder[deployments.DeploymentOperationsClientListResponse]) // NewListAtManagementGroupScopePager is the fake for method DeploymentOperationsClient.NewListAtManagementGroupScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtManagementGroupScopePager func(groupID string, deploymentName string, options *armresources.DeploymentOperationsClientListAtManagementGroupScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentOperationsClientListAtManagementGroupScopeResponse]) + NewListAtManagementGroupScopePager func(groupID string, deploymentName string, options *deployments.DeploymentOperationsClientListAtManagementGroupScopeOptions) (resp azfake.PagerResponder[deployments.DeploymentOperationsClientListAtManagementGroupScopeResponse]) // NewListAtScopePager is the fake for method DeploymentOperationsClient.NewListAtScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtScopePager func(scope string, deploymentName string, options *armresources.DeploymentOperationsClientListAtScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentOperationsClientListAtScopeResponse]) + NewListAtScopePager func(scope string, deploymentName string, options *deployments.DeploymentOperationsClientListAtScopeOptions) (resp azfake.PagerResponder[deployments.DeploymentOperationsClientListAtScopeResponse]) // NewListAtSubscriptionScopePager is the fake for method DeploymentOperationsClient.NewListAtSubscriptionScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtSubscriptionScopePager func(deploymentName string, options *armresources.DeploymentOperationsClientListAtSubscriptionScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentOperationsClientListAtSubscriptionScopeResponse]) + NewListAtSubscriptionScopePager func(deploymentName string, options *deployments.DeploymentOperationsClientListAtSubscriptionScopeOptions) (resp azfake.PagerResponder[deployments.DeploymentOperationsClientListAtSubscriptionScopeResponse]) // NewListAtTenantScopePager is the fake for method DeploymentOperationsClient.NewListAtTenantScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtTenantScopePager func(deploymentName string, options *armresources.DeploymentOperationsClientListAtTenantScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentOperationsClientListAtTenantScopeResponse]) + NewListAtTenantScopePager func(deploymentName string, options *deployments.DeploymentOperationsClientListAtTenantScopeOptions) (resp azfake.PagerResponder[deployments.DeploymentOperationsClientListAtTenantScopeResponse]) } // NewDeploymentOperationsServerTransport creates a new instance of DeploymentOperationsServerTransport with the provided implementation. -// The returned DeploymentOperationsServerTransport instance is connected to an instance of armresources.DeploymentOperationsClient via the +// The returned DeploymentOperationsServerTransport instance is connected to an instance of deployments.DeploymentOperationsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewDeploymentOperationsServerTransport(srv *DeploymentOperationsServer) *DeploymentOperationsServerTransport { return &DeploymentOperationsServerTransport{ srv: srv, - newListPager: newTracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListResponse]](), - newListAtManagementGroupScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtManagementGroupScopeResponse]](), - newListAtScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtScopeResponse]](), - newListAtSubscriptionScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtSubscriptionScopeResponse]](), - newListAtTenantScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtTenantScopeResponse]](), + newListPager: newTracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListResponse]](), + newListAtManagementGroupScopePager: newTracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtManagementGroupScopeResponse]](), + newListAtScopePager: newTracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtScopeResponse]](), + newListAtSubscriptionScopePager: newTracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtSubscriptionScopeResponse]](), + newListAtTenantScopePager: newTracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtTenantScopeResponse]](), } } -// DeploymentOperationsServerTransport connects instances of armresources.DeploymentOperationsClient to instances of DeploymentOperationsServer. +// DeploymentOperationsServerTransport connects instances of deployments.DeploymentOperationsClient to instances of DeploymentOperationsServer. // Don't use this type directly, use NewDeploymentOperationsServerTransport instead. type DeploymentOperationsServerTransport struct { srv *DeploymentOperationsServer - newListPager *tracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListResponse]] - newListAtManagementGroupScopePager *tracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtManagementGroupScopeResponse]] - newListAtScopePager *tracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtScopeResponse]] - newListAtSubscriptionScopePager *tracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtSubscriptionScopeResponse]] - newListAtTenantScopePager *tracker[azfake.PagerResponder[armresources.DeploymentOperationsClientListAtTenantScopeResponse]] + newListPager *tracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListResponse]] + newListAtManagementGroupScopePager *tracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtManagementGroupScopeResponse]] + newListAtScopePager *tracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtScopeResponse]] + newListAtSubscriptionScopePager *tracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtSubscriptionScopeResponse]] + newListAtTenantScopePager *tracker[azfake.PagerResponder[deployments.DeploymentOperationsClientListAtTenantScopeResponse]] } // Do implements the policy.Transporter interface for DeploymentOperationsServerTransport. @@ -99,39 +96,58 @@ func (d *DeploymentOperationsServerTransport) Do(req *http.Request) (*http.Respo return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return d.dispatchToMethodFake(req, method) +} - switch method { - case "DeploymentOperationsClient.Get": - resp, err = d.dispatchGet(req) - case "DeploymentOperationsClient.GetAtManagementGroupScope": - resp, err = d.dispatchGetAtManagementGroupScope(req) - case "DeploymentOperationsClient.GetAtScope": - resp, err = d.dispatchGetAtScope(req) - case "DeploymentOperationsClient.GetAtSubscriptionScope": - resp, err = d.dispatchGetAtSubscriptionScope(req) - case "DeploymentOperationsClient.GetAtTenantScope": - resp, err = d.dispatchGetAtTenantScope(req) - case "DeploymentOperationsClient.NewListPager": - resp, err = d.dispatchNewListPager(req) - case "DeploymentOperationsClient.NewListAtManagementGroupScopePager": - resp, err = d.dispatchNewListAtManagementGroupScopePager(req) - case "DeploymentOperationsClient.NewListAtScopePager": - resp, err = d.dispatchNewListAtScopePager(req) - case "DeploymentOperationsClient.NewListAtSubscriptionScopePager": - resp, err = d.dispatchNewListAtSubscriptionScopePager(req) - case "DeploymentOperationsClient.NewListAtTenantScopePager": - resp, err = d.dispatchNewListAtTenantScopePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (d *DeploymentOperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if deploymentOperationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = deploymentOperationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DeploymentOperationsClient.Get": + res.resp, res.err = d.dispatchGet(req) + case "DeploymentOperationsClient.GetAtManagementGroupScope": + res.resp, res.err = d.dispatchGetAtManagementGroupScope(req) + case "DeploymentOperationsClient.GetAtScope": + res.resp, res.err = d.dispatchGetAtScope(req) + case "DeploymentOperationsClient.GetAtSubscriptionScope": + res.resp, res.err = d.dispatchGetAtSubscriptionScope(req) + case "DeploymentOperationsClient.GetAtTenantScope": + res.resp, res.err = d.dispatchGetAtTenantScope(req) + case "DeploymentOperationsClient.NewListPager": + res.resp, res.err = d.dispatchNewListPager(req) + case "DeploymentOperationsClient.NewListAtManagementGroupScopePager": + res.resp, res.err = d.dispatchNewListAtManagementGroupScopePager(req) + case "DeploymentOperationsClient.NewListAtScopePager": + res.resp, res.err = d.dispatchNewListAtScopePager(req) + case "DeploymentOperationsClient.NewListAtSubscriptionScopePager": + res.resp, res.err = d.dispatchNewListAtSubscriptionScopePager(req) + case "DeploymentOperationsClient.NewListAtTenantScopePager": + res.resp, res.err = d.dispatchNewListAtTenantScopePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (d *DeploymentOperationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -346,16 +362,16 @@ func (d *DeploymentOperationsServerTransport) dispatchNewListPager(req *http.Req if err != nil { return nil, err } - var options *armresources.DeploymentOperationsClientListOptions + var options *deployments.DeploymentOperationsClientListOptions if topParam != nil { - options = &armresources.DeploymentOperationsClientListOptions{ + options = &deployments.DeploymentOperationsClientListOptions{ Top: topParam, } } resp := d.srv.NewListPager(resourceGroupNameParam, deploymentNameParam, options) newListPager = &resp d.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armresources.DeploymentOperationsClientListResponse, createLink func() string) { + server.PagerResponderInjectNextLinks(newListPager, req, func(page *deployments.DeploymentOperationsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -408,16 +424,16 @@ func (d *DeploymentOperationsServerTransport) dispatchNewListAtManagementGroupSc if err != nil { return nil, err } - var options *armresources.DeploymentOperationsClientListAtManagementGroupScopeOptions + var options *deployments.DeploymentOperationsClientListAtManagementGroupScopeOptions if topParam != nil { - options = &armresources.DeploymentOperationsClientListAtManagementGroupScopeOptions{ + options = &deployments.DeploymentOperationsClientListAtManagementGroupScopeOptions{ Top: topParam, } } resp := d.srv.NewListAtManagementGroupScopePager(groupIDParam, deploymentNameParam, options) newListAtManagementGroupScopePager = &resp d.newListAtManagementGroupScopePager.add(req, newListAtManagementGroupScopePager) - server.PagerResponderInjectNextLinks(newListAtManagementGroupScopePager, req, func(page *armresources.DeploymentOperationsClientListAtManagementGroupScopeResponse, createLink func() string) { + server.PagerResponderInjectNextLinks(newListAtManagementGroupScopePager, req, func(page *deployments.DeploymentOperationsClientListAtManagementGroupScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -470,16 +486,16 @@ func (d *DeploymentOperationsServerTransport) dispatchNewListAtScopePager(req *h if err != nil { return nil, err } - var options *armresources.DeploymentOperationsClientListAtScopeOptions + var options *deployments.DeploymentOperationsClientListAtScopeOptions if topParam != nil { - options = &armresources.DeploymentOperationsClientListAtScopeOptions{ + options = &deployments.DeploymentOperationsClientListAtScopeOptions{ Top: topParam, } } resp := d.srv.NewListAtScopePager(scopeParam, deploymentNameParam, options) newListAtScopePager = &resp d.newListAtScopePager.add(req, newListAtScopePager) - server.PagerResponderInjectNextLinks(newListAtScopePager, req, func(page *armresources.DeploymentOperationsClientListAtScopeResponse, createLink func() string) { + server.PagerResponderInjectNextLinks(newListAtScopePager, req, func(page *deployments.DeploymentOperationsClientListAtScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -528,16 +544,16 @@ func (d *DeploymentOperationsServerTransport) dispatchNewListAtSubscriptionScope if err != nil { return nil, err } - var options *armresources.DeploymentOperationsClientListAtSubscriptionScopeOptions + var options *deployments.DeploymentOperationsClientListAtSubscriptionScopeOptions if topParam != nil { - options = &armresources.DeploymentOperationsClientListAtSubscriptionScopeOptions{ + options = &deployments.DeploymentOperationsClientListAtSubscriptionScopeOptions{ Top: topParam, } } resp := d.srv.NewListAtSubscriptionScopePager(deploymentNameParam, options) newListAtSubscriptionScopePager = &resp d.newListAtSubscriptionScopePager.add(req, newListAtSubscriptionScopePager) - server.PagerResponderInjectNextLinks(newListAtSubscriptionScopePager, req, func(page *armresources.DeploymentOperationsClientListAtSubscriptionScopeResponse, createLink func() string) { + server.PagerResponderInjectNextLinks(newListAtSubscriptionScopePager, req, func(page *deployments.DeploymentOperationsClientListAtSubscriptionScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -586,16 +602,16 @@ func (d *DeploymentOperationsServerTransport) dispatchNewListAtTenantScopePager( if err != nil { return nil, err } - var options *armresources.DeploymentOperationsClientListAtTenantScopeOptions + var options *deployments.DeploymentOperationsClientListAtTenantScopeOptions if topParam != nil { - options = &armresources.DeploymentOperationsClientListAtTenantScopeOptions{ + options = &deployments.DeploymentOperationsClientListAtTenantScopeOptions{ Top: topParam, } } resp := d.srv.NewListAtTenantScopePager(deploymentNameParam, options) newListAtTenantScopePager = &resp d.newListAtTenantScopePager.add(req, newListAtTenantScopePager) - server.PagerResponderInjectNextLinks(newListAtTenantScopePager, req, func(page *armresources.DeploymentOperationsClientListAtTenantScopeResponse, createLink func() string) { + server.PagerResponderInjectNextLinks(newListAtTenantScopePager, req, func(page *deployments.DeploymentOperationsClientListAtTenantScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -612,3 +628,9 @@ func (d *DeploymentOperationsServerTransport) dispatchNewListAtTenantScopePager( } return resp, nil } + +// set this to conditionally intercept incoming requests to DeploymentOperationsServerTransport +var deploymentOperationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/deployments/deployments/fake/internal.go b/sdk/resourcemanager/deployments/deployments/fake/internal.go new file mode 100644 index 000000000000..c614f8d5643a --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/fake/internal.go @@ -0,0 +1,85 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/resources/armresources/fake/deployments_server.go b/sdk/resourcemanager/deployments/deployments/fake/server.go similarity index 63% rename from sdk/resourcemanager/resources/armresources/fake/deployments_server.go rename to sdk/resourcemanager/deployments/deployments/fake/server.go index 1cf2f0a890ad..bef30188c5e5 100644 --- a/sdk/resourcemanager/resources/armresources/fake/deployments_server.go +++ b/sdk/resourcemanager/deployments/deployments/fake/server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -16,381 +13,400 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deployments" "net/http" "net/url" "regexp" "strconv" ) -// DeploymentsServer is a fake server for instances of the armresources.DeploymentsClient type. -type DeploymentsServer struct { - // CalculateTemplateHash is the fake for method DeploymentsClient.CalculateTemplateHash +// Server is a fake server for instances of the deployments.Client type. +type Server struct { + // CalculateTemplateHash is the fake for method Client.CalculateTemplateHash // HTTP status codes to indicate success: http.StatusOK - CalculateTemplateHash func(ctx context.Context, templateParam any, options *armresources.DeploymentsClientCalculateTemplateHashOptions) (resp azfake.Responder[armresources.DeploymentsClientCalculateTemplateHashResponse], errResp azfake.ErrorResponder) + CalculateTemplateHash func(ctx context.Context, templateParam any, options *deployments.ClientCalculateTemplateHashOptions) (resp azfake.Responder[deployments.ClientCalculateTemplateHashResponse], errResp azfake.ErrorResponder) - // Cancel is the fake for method DeploymentsClient.Cancel + // Cancel is the fake for method Client.Cancel // HTTP status codes to indicate success: http.StatusNoContent - Cancel func(ctx context.Context, resourceGroupName string, deploymentName string, options *armresources.DeploymentsClientCancelOptions) (resp azfake.Responder[armresources.DeploymentsClientCancelResponse], errResp azfake.ErrorResponder) + Cancel func(ctx context.Context, resourceGroupName string, deploymentName string, options *deployments.ClientCancelOptions) (resp azfake.Responder[deployments.ClientCancelResponse], errResp azfake.ErrorResponder) - // CancelAtManagementGroupScope is the fake for method DeploymentsClient.CancelAtManagementGroupScope + // CancelAtManagementGroupScope is the fake for method Client.CancelAtManagementGroupScope // HTTP status codes to indicate success: http.StatusNoContent - CancelAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *armresources.DeploymentsClientCancelAtManagementGroupScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCancelAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + CancelAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *deployments.ClientCancelAtManagementGroupScopeOptions) (resp azfake.Responder[deployments.ClientCancelAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // CancelAtScope is the fake for method DeploymentsClient.CancelAtScope + // CancelAtScope is the fake for method Client.CancelAtScope // HTTP status codes to indicate success: http.StatusNoContent - CancelAtScope func(ctx context.Context, scope string, deploymentName string, options *armresources.DeploymentsClientCancelAtScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCancelAtScopeResponse], errResp azfake.ErrorResponder) + CancelAtScope func(ctx context.Context, scope string, deploymentName string, options *deployments.ClientCancelAtScopeOptions) (resp azfake.Responder[deployments.ClientCancelAtScopeResponse], errResp azfake.ErrorResponder) - // CancelAtSubscriptionScope is the fake for method DeploymentsClient.CancelAtSubscriptionScope + // CancelAtSubscriptionScope is the fake for method Client.CancelAtSubscriptionScope // HTTP status codes to indicate success: http.StatusNoContent - CancelAtSubscriptionScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientCancelAtSubscriptionScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCancelAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + CancelAtSubscriptionScope func(ctx context.Context, deploymentName string, options *deployments.ClientCancelAtSubscriptionScopeOptions) (resp azfake.Responder[deployments.ClientCancelAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // CancelAtTenantScope is the fake for method DeploymentsClient.CancelAtTenantScope + // CancelAtTenantScope is the fake for method Client.CancelAtTenantScope // HTTP status codes to indicate success: http.StatusNoContent - CancelAtTenantScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientCancelAtTenantScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCancelAtTenantScopeResponse], errResp azfake.ErrorResponder) + CancelAtTenantScope func(ctx context.Context, deploymentName string, options *deployments.ClientCancelAtTenantScopeOptions) (resp azfake.Responder[deployments.ClientCancelAtTenantScopeResponse], errResp azfake.ErrorResponder) - // CheckExistence is the fake for method DeploymentsClient.CheckExistence + // CheckExistence is the fake for method Client.CheckExistence // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound - CheckExistence func(ctx context.Context, resourceGroupName string, deploymentName string, options *armresources.DeploymentsClientCheckExistenceOptions) (resp azfake.Responder[armresources.DeploymentsClientCheckExistenceResponse], errResp azfake.ErrorResponder) + CheckExistence func(ctx context.Context, resourceGroupName string, deploymentName string, options *deployments.ClientCheckExistenceOptions) (resp azfake.Responder[deployments.ClientCheckExistenceResponse], errResp azfake.ErrorResponder) - // CheckExistenceAtManagementGroupScope is the fake for method DeploymentsClient.CheckExistenceAtManagementGroupScope + // CheckExistenceAtManagementGroupScope is the fake for method Client.CheckExistenceAtManagementGroupScope // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound - CheckExistenceAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *armresources.DeploymentsClientCheckExistenceAtManagementGroupScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCheckExistenceAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + CheckExistenceAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *deployments.ClientCheckExistenceAtManagementGroupScopeOptions) (resp azfake.Responder[deployments.ClientCheckExistenceAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // CheckExistenceAtScope is the fake for method DeploymentsClient.CheckExistenceAtScope + // CheckExistenceAtScope is the fake for method Client.CheckExistenceAtScope // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound - CheckExistenceAtScope func(ctx context.Context, scope string, deploymentName string, options *armresources.DeploymentsClientCheckExistenceAtScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCheckExistenceAtScopeResponse], errResp azfake.ErrorResponder) + CheckExistenceAtScope func(ctx context.Context, scope string, deploymentName string, options *deployments.ClientCheckExistenceAtScopeOptions) (resp azfake.Responder[deployments.ClientCheckExistenceAtScopeResponse], errResp azfake.ErrorResponder) - // CheckExistenceAtSubscriptionScope is the fake for method DeploymentsClient.CheckExistenceAtSubscriptionScope + // CheckExistenceAtSubscriptionScope is the fake for method Client.CheckExistenceAtSubscriptionScope // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound - CheckExistenceAtSubscriptionScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientCheckExistenceAtSubscriptionScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCheckExistenceAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + CheckExistenceAtSubscriptionScope func(ctx context.Context, deploymentName string, options *deployments.ClientCheckExistenceAtSubscriptionScopeOptions) (resp azfake.Responder[deployments.ClientCheckExistenceAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // CheckExistenceAtTenantScope is the fake for method DeploymentsClient.CheckExistenceAtTenantScope + // CheckExistenceAtTenantScope is the fake for method Client.CheckExistenceAtTenantScope // HTTP status codes to indicate success: http.StatusNoContent, http.StatusNotFound - CheckExistenceAtTenantScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientCheckExistenceAtTenantScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientCheckExistenceAtTenantScopeResponse], errResp azfake.ErrorResponder) + CheckExistenceAtTenantScope func(ctx context.Context, deploymentName string, options *deployments.ClientCheckExistenceAtTenantScopeOptions) (resp azfake.Responder[deployments.ClientCheckExistenceAtTenantScopeResponse], errResp azfake.ErrorResponder) - // BeginCreateOrUpdate is the fake for method DeploymentsClient.BeginCreateOrUpdate + // BeginCreateOrUpdate is the fake for method Client.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, parameters armresources.Deployment, options *armresources.DeploymentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, deploymentName string, parameters deployments.Deployment, options *deployments.ClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[deployments.ClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - // BeginCreateOrUpdateAtManagementGroupScope is the fake for method DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope + // BeginCreateOrUpdateAtManagementGroupScope is the fake for method Client.BeginCreateOrUpdateAtManagementGroupScope // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdateAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, parameters armresources.ScopedDeployment, options *armresources.DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdateAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, parameters deployments.ScopedDeployment, options *deployments.ClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (resp azfake.PollerResponder[deployments.ClientCreateOrUpdateAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // BeginCreateOrUpdateAtScope is the fake for method DeploymentsClient.BeginCreateOrUpdateAtScope + // BeginCreateOrUpdateAtScope is the fake for method Client.BeginCreateOrUpdateAtScope // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdateAtScope func(ctx context.Context, scope string, deploymentName string, parameters armresources.Deployment, options *armresources.DeploymentsClientBeginCreateOrUpdateAtScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtScopeResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdateAtScope func(ctx context.Context, scope string, deploymentName string, parameters deployments.Deployment, options *deployments.ClientBeginCreateOrUpdateAtScopeOptions) (resp azfake.PollerResponder[deployments.ClientCreateOrUpdateAtScopeResponse], errResp azfake.ErrorResponder) - // BeginCreateOrUpdateAtSubscriptionScope is the fake for method DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope + // BeginCreateOrUpdateAtSubscriptionScope is the fake for method Client.BeginCreateOrUpdateAtSubscriptionScope // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdateAtSubscriptionScope func(ctx context.Context, deploymentName string, parameters armresources.Deployment, options *armresources.DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdateAtSubscriptionScope func(ctx context.Context, deploymentName string, parameters deployments.Deployment, options *deployments.ClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (resp azfake.PollerResponder[deployments.ClientCreateOrUpdateAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // BeginCreateOrUpdateAtTenantScope is the fake for method DeploymentsClient.BeginCreateOrUpdateAtTenantScope + // BeginCreateOrUpdateAtTenantScope is the fake for method Client.BeginCreateOrUpdateAtTenantScope // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdateAtTenantScope func(ctx context.Context, deploymentName string, parameters armresources.ScopedDeployment, options *armresources.DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtTenantScopeResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdateAtTenantScope func(ctx context.Context, deploymentName string, parameters deployments.ScopedDeployment, options *deployments.ClientBeginCreateOrUpdateAtTenantScopeOptions) (resp azfake.PollerResponder[deployments.ClientCreateOrUpdateAtTenantScopeResponse], errResp azfake.ErrorResponder) - // BeginDelete is the fake for method DeploymentsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, resourceGroupName string, deploymentName string, options *armresources.DeploymentsClientBeginDeleteOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientDeleteResponse], errResp azfake.ErrorResponder) + // BeginDelete is the fake for method Client.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, deploymentName string, options *deployments.ClientBeginDeleteOptions) (resp azfake.PollerResponder[deployments.ClientDeleteResponse], errResp azfake.ErrorResponder) - // BeginDeleteAtManagementGroupScope is the fake for method DeploymentsClient.BeginDeleteAtManagementGroupScope - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent - BeginDeleteAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *armresources.DeploymentsClientBeginDeleteAtManagementGroupScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientDeleteAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + // BeginDeleteAtManagementGroupScope is the fake for method Client.BeginDeleteAtManagementGroupScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *deployments.ClientBeginDeleteAtManagementGroupScopeOptions) (resp azfake.PollerResponder[deployments.ClientDeleteAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // BeginDeleteAtScope is the fake for method DeploymentsClient.BeginDeleteAtScope - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent - BeginDeleteAtScope func(ctx context.Context, scope string, deploymentName string, options *armresources.DeploymentsClientBeginDeleteAtScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientDeleteAtScopeResponse], errResp azfake.ErrorResponder) + // BeginDeleteAtScope is the fake for method Client.BeginDeleteAtScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAtScope func(ctx context.Context, scope string, deploymentName string, options *deployments.ClientBeginDeleteAtScopeOptions) (resp azfake.PollerResponder[deployments.ClientDeleteAtScopeResponse], errResp azfake.ErrorResponder) - // BeginDeleteAtSubscriptionScope is the fake for method DeploymentsClient.BeginDeleteAtSubscriptionScope - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent - BeginDeleteAtSubscriptionScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientBeginDeleteAtSubscriptionScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientDeleteAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + // BeginDeleteAtSubscriptionScope is the fake for method Client.BeginDeleteAtSubscriptionScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAtSubscriptionScope func(ctx context.Context, deploymentName string, options *deployments.ClientBeginDeleteAtSubscriptionScopeOptions) (resp azfake.PollerResponder[deployments.ClientDeleteAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // BeginDeleteAtTenantScope is the fake for method DeploymentsClient.BeginDeleteAtTenantScope - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent - BeginDeleteAtTenantScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientBeginDeleteAtTenantScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientDeleteAtTenantScopeResponse], errResp azfake.ErrorResponder) + // BeginDeleteAtTenantScope is the fake for method Client.BeginDeleteAtTenantScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAtTenantScope func(ctx context.Context, deploymentName string, options *deployments.ClientBeginDeleteAtTenantScopeOptions) (resp azfake.PollerResponder[deployments.ClientDeleteAtTenantScopeResponse], errResp azfake.ErrorResponder) - // ExportTemplate is the fake for method DeploymentsClient.ExportTemplate + // ExportTemplate is the fake for method Client.ExportTemplate // HTTP status codes to indicate success: http.StatusOK - ExportTemplate func(ctx context.Context, resourceGroupName string, deploymentName string, options *armresources.DeploymentsClientExportTemplateOptions) (resp azfake.Responder[armresources.DeploymentsClientExportTemplateResponse], errResp azfake.ErrorResponder) + ExportTemplate func(ctx context.Context, resourceGroupName string, deploymentName string, options *deployments.ClientExportTemplateOptions) (resp azfake.Responder[deployments.ClientExportTemplateResponse], errResp azfake.ErrorResponder) - // ExportTemplateAtManagementGroupScope is the fake for method DeploymentsClient.ExportTemplateAtManagementGroupScope + // ExportTemplateAtManagementGroupScope is the fake for method Client.ExportTemplateAtManagementGroupScope // HTTP status codes to indicate success: http.StatusOK - ExportTemplateAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *armresources.DeploymentsClientExportTemplateAtManagementGroupScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientExportTemplateAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + ExportTemplateAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *deployments.ClientExportTemplateAtManagementGroupScopeOptions) (resp azfake.Responder[deployments.ClientExportTemplateAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // ExportTemplateAtScope is the fake for method DeploymentsClient.ExportTemplateAtScope + // ExportTemplateAtScope is the fake for method Client.ExportTemplateAtScope // HTTP status codes to indicate success: http.StatusOK - ExportTemplateAtScope func(ctx context.Context, scope string, deploymentName string, options *armresources.DeploymentsClientExportTemplateAtScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientExportTemplateAtScopeResponse], errResp azfake.ErrorResponder) + ExportTemplateAtScope func(ctx context.Context, scope string, deploymentName string, options *deployments.ClientExportTemplateAtScopeOptions) (resp azfake.Responder[deployments.ClientExportTemplateAtScopeResponse], errResp azfake.ErrorResponder) - // ExportTemplateAtSubscriptionScope is the fake for method DeploymentsClient.ExportTemplateAtSubscriptionScope + // ExportTemplateAtSubscriptionScope is the fake for method Client.ExportTemplateAtSubscriptionScope // HTTP status codes to indicate success: http.StatusOK - ExportTemplateAtSubscriptionScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientExportTemplateAtSubscriptionScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientExportTemplateAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + ExportTemplateAtSubscriptionScope func(ctx context.Context, deploymentName string, options *deployments.ClientExportTemplateAtSubscriptionScopeOptions) (resp azfake.Responder[deployments.ClientExportTemplateAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // ExportTemplateAtTenantScope is the fake for method DeploymentsClient.ExportTemplateAtTenantScope + // ExportTemplateAtTenantScope is the fake for method Client.ExportTemplateAtTenantScope // HTTP status codes to indicate success: http.StatusOK - ExportTemplateAtTenantScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientExportTemplateAtTenantScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientExportTemplateAtTenantScopeResponse], errResp azfake.ErrorResponder) + ExportTemplateAtTenantScope func(ctx context.Context, deploymentName string, options *deployments.ClientExportTemplateAtTenantScopeOptions) (resp azfake.Responder[deployments.ClientExportTemplateAtTenantScopeResponse], errResp azfake.ErrorResponder) - // Get is the fake for method DeploymentsClient.Get + // Get is the fake for method Client.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, deploymentName string, options *armresources.DeploymentsClientGetOptions) (resp azfake.Responder[armresources.DeploymentsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, deploymentName string, options *deployments.ClientGetOptions) (resp azfake.Responder[deployments.ClientGetResponse], errResp azfake.ErrorResponder) - // GetAtManagementGroupScope is the fake for method DeploymentsClient.GetAtManagementGroupScope + // GetAtManagementGroupScope is the fake for method Client.GetAtManagementGroupScope // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *armresources.DeploymentsClientGetAtManagementGroupScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientGetAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + GetAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, options *deployments.ClientGetAtManagementGroupScopeOptions) (resp azfake.Responder[deployments.ClientGetAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // GetAtScope is the fake for method DeploymentsClient.GetAtScope + // GetAtScope is the fake for method Client.GetAtScope // HTTP status codes to indicate success: http.StatusOK - GetAtScope func(ctx context.Context, scope string, deploymentName string, options *armresources.DeploymentsClientGetAtScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientGetAtScopeResponse], errResp azfake.ErrorResponder) + GetAtScope func(ctx context.Context, scope string, deploymentName string, options *deployments.ClientGetAtScopeOptions) (resp azfake.Responder[deployments.ClientGetAtScopeResponse], errResp azfake.ErrorResponder) - // GetAtSubscriptionScope is the fake for method DeploymentsClient.GetAtSubscriptionScope + // GetAtSubscriptionScope is the fake for method Client.GetAtSubscriptionScope // HTTP status codes to indicate success: http.StatusOK - GetAtSubscriptionScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientGetAtSubscriptionScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientGetAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + GetAtSubscriptionScope func(ctx context.Context, deploymentName string, options *deployments.ClientGetAtSubscriptionScopeOptions) (resp azfake.Responder[deployments.ClientGetAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // GetAtTenantScope is the fake for method DeploymentsClient.GetAtTenantScope + // GetAtTenantScope is the fake for method Client.GetAtTenantScope // HTTP status codes to indicate success: http.StatusOK - GetAtTenantScope func(ctx context.Context, deploymentName string, options *armresources.DeploymentsClientGetAtTenantScopeOptions) (resp azfake.Responder[armresources.DeploymentsClientGetAtTenantScopeResponse], errResp azfake.ErrorResponder) + GetAtTenantScope func(ctx context.Context, deploymentName string, options *deployments.ClientGetAtTenantScopeOptions) (resp azfake.Responder[deployments.ClientGetAtTenantScopeResponse], errResp azfake.ErrorResponder) - // NewListAtManagementGroupScopePager is the fake for method DeploymentsClient.NewListAtManagementGroupScopePager + // NewListAtManagementGroupScopePager is the fake for method Client.NewListAtManagementGroupScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtManagementGroupScopePager func(groupID string, options *armresources.DeploymentsClientListAtManagementGroupScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentsClientListAtManagementGroupScopeResponse]) + NewListAtManagementGroupScopePager func(groupID string, options *deployments.ClientListAtManagementGroupScopeOptions) (resp azfake.PagerResponder[deployments.ClientListAtManagementGroupScopeResponse]) - // NewListAtScopePager is the fake for method DeploymentsClient.NewListAtScopePager + // NewListAtScopePager is the fake for method Client.NewListAtScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtScopePager func(scope string, options *armresources.DeploymentsClientListAtScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentsClientListAtScopeResponse]) + NewListAtScopePager func(scope string, options *deployments.ClientListAtScopeOptions) (resp azfake.PagerResponder[deployments.ClientListAtScopeResponse]) - // NewListAtSubscriptionScopePager is the fake for method DeploymentsClient.NewListAtSubscriptionScopePager + // NewListAtSubscriptionScopePager is the fake for method Client.NewListAtSubscriptionScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtSubscriptionScopePager func(options *armresources.DeploymentsClientListAtSubscriptionScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentsClientListAtSubscriptionScopeResponse]) + NewListAtSubscriptionScopePager func(options *deployments.ClientListAtSubscriptionScopeOptions) (resp azfake.PagerResponder[deployments.ClientListAtSubscriptionScopeResponse]) - // NewListAtTenantScopePager is the fake for method DeploymentsClient.NewListAtTenantScopePager + // NewListAtTenantScopePager is the fake for method Client.NewListAtTenantScopePager // HTTP status codes to indicate success: http.StatusOK - NewListAtTenantScopePager func(options *armresources.DeploymentsClientListAtTenantScopeOptions) (resp azfake.PagerResponder[armresources.DeploymentsClientListAtTenantScopeResponse]) + NewListAtTenantScopePager func(options *deployments.ClientListAtTenantScopeOptions) (resp azfake.PagerResponder[deployments.ClientListAtTenantScopeResponse]) - // NewListByResourceGroupPager is the fake for method DeploymentsClient.NewListByResourceGroupPager + // NewListByResourceGroupPager is the fake for method Client.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK - NewListByResourceGroupPager func(resourceGroupName string, options *armresources.DeploymentsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armresources.DeploymentsClientListByResourceGroupResponse]) + NewListByResourceGroupPager func(resourceGroupName string, options *deployments.ClientListByResourceGroupOptions) (resp azfake.PagerResponder[deployments.ClientListByResourceGroupResponse]) - // BeginValidate is the fake for method DeploymentsClient.BeginValidate + // BeginValidate is the fake for method Client.BeginValidate // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest - BeginValidate func(ctx context.Context, resourceGroupName string, deploymentName string, parameters armresources.Deployment, options *armresources.DeploymentsClientBeginValidateOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientValidateResponse], errResp azfake.ErrorResponder) + BeginValidate func(ctx context.Context, resourceGroupName string, deploymentName string, parameters deployments.Deployment, options *deployments.ClientBeginValidateOptions) (resp azfake.PollerResponder[deployments.ClientValidateResponse], errResp azfake.ErrorResponder) - // BeginValidateAtManagementGroupScope is the fake for method DeploymentsClient.BeginValidateAtManagementGroupScope + // BeginValidateAtManagementGroupScope is the fake for method Client.BeginValidateAtManagementGroupScope // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest - BeginValidateAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, parameters armresources.ScopedDeployment, options *armresources.DeploymentsClientBeginValidateAtManagementGroupScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientValidateAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + BeginValidateAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, parameters deployments.ScopedDeployment, options *deployments.ClientBeginValidateAtManagementGroupScopeOptions) (resp azfake.PollerResponder[deployments.ClientValidateAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // BeginValidateAtScope is the fake for method DeploymentsClient.BeginValidateAtScope + // BeginValidateAtScope is the fake for method Client.BeginValidateAtScope // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest - BeginValidateAtScope func(ctx context.Context, scope string, deploymentName string, parameters armresources.Deployment, options *armresources.DeploymentsClientBeginValidateAtScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientValidateAtScopeResponse], errResp azfake.ErrorResponder) + BeginValidateAtScope func(ctx context.Context, scope string, deploymentName string, parameters deployments.Deployment, options *deployments.ClientBeginValidateAtScopeOptions) (resp azfake.PollerResponder[deployments.ClientValidateAtScopeResponse], errResp azfake.ErrorResponder) - // BeginValidateAtSubscriptionScope is the fake for method DeploymentsClient.BeginValidateAtSubscriptionScope + // BeginValidateAtSubscriptionScope is the fake for method Client.BeginValidateAtSubscriptionScope // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest - BeginValidateAtSubscriptionScope func(ctx context.Context, deploymentName string, parameters armresources.Deployment, options *armresources.DeploymentsClientBeginValidateAtSubscriptionScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientValidateAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + BeginValidateAtSubscriptionScope func(ctx context.Context, deploymentName string, parameters deployments.Deployment, options *deployments.ClientBeginValidateAtSubscriptionScopeOptions) (resp azfake.PollerResponder[deployments.ClientValidateAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // BeginValidateAtTenantScope is the fake for method DeploymentsClient.BeginValidateAtTenantScope + // BeginValidateAtTenantScope is the fake for method Client.BeginValidateAtTenantScope // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest - BeginValidateAtTenantScope func(ctx context.Context, deploymentName string, parameters armresources.ScopedDeployment, options *armresources.DeploymentsClientBeginValidateAtTenantScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientValidateAtTenantScopeResponse], errResp azfake.ErrorResponder) + BeginValidateAtTenantScope func(ctx context.Context, deploymentName string, parameters deployments.ScopedDeployment, options *deployments.ClientBeginValidateAtTenantScopeOptions) (resp azfake.PollerResponder[deployments.ClientValidateAtTenantScopeResponse], errResp azfake.ErrorResponder) - // BeginWhatIf is the fake for method DeploymentsClient.BeginWhatIf + // BeginWhatIf is the fake for method Client.BeginWhatIf // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginWhatIf func(ctx context.Context, resourceGroupName string, deploymentName string, parameters armresources.DeploymentWhatIf, options *armresources.DeploymentsClientBeginWhatIfOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientWhatIfResponse], errResp azfake.ErrorResponder) + BeginWhatIf func(ctx context.Context, resourceGroupName string, deploymentName string, parameters deployments.DeploymentWhatIf, options *deployments.ClientBeginWhatIfOptions) (resp azfake.PollerResponder[deployments.ClientWhatIfResponse], errResp azfake.ErrorResponder) - // BeginWhatIfAtManagementGroupScope is the fake for method DeploymentsClient.BeginWhatIfAtManagementGroupScope + // BeginWhatIfAtManagementGroupScope is the fake for method Client.BeginWhatIfAtManagementGroupScope // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginWhatIfAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, parameters armresources.ScopedDeploymentWhatIf, options *armresources.DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) + BeginWhatIfAtManagementGroupScope func(ctx context.Context, groupID string, deploymentName string, parameters deployments.ScopedDeploymentWhatIf, options *deployments.ClientBeginWhatIfAtManagementGroupScopeOptions) (resp azfake.PollerResponder[deployments.ClientWhatIfAtManagementGroupScopeResponse], errResp azfake.ErrorResponder) - // BeginWhatIfAtSubscriptionScope is the fake for method DeploymentsClient.BeginWhatIfAtSubscriptionScope + // BeginWhatIfAtSubscriptionScope is the fake for method Client.BeginWhatIfAtSubscriptionScope // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginWhatIfAtSubscriptionScope func(ctx context.Context, deploymentName string, parameters armresources.DeploymentWhatIf, options *armresources.DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) + BeginWhatIfAtSubscriptionScope func(ctx context.Context, deploymentName string, parameters deployments.DeploymentWhatIf, options *deployments.ClientBeginWhatIfAtSubscriptionScopeOptions) (resp azfake.PollerResponder[deployments.ClientWhatIfAtSubscriptionScopeResponse], errResp azfake.ErrorResponder) - // BeginWhatIfAtTenantScope is the fake for method DeploymentsClient.BeginWhatIfAtTenantScope + // BeginWhatIfAtTenantScope is the fake for method Client.BeginWhatIfAtTenantScope // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginWhatIfAtTenantScope func(ctx context.Context, deploymentName string, parameters armresources.ScopedDeploymentWhatIf, options *armresources.DeploymentsClientBeginWhatIfAtTenantScopeOptions) (resp azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtTenantScopeResponse], errResp azfake.ErrorResponder) + BeginWhatIfAtTenantScope func(ctx context.Context, deploymentName string, parameters deployments.ScopedDeploymentWhatIf, options *deployments.ClientBeginWhatIfAtTenantScopeOptions) (resp azfake.PollerResponder[deployments.ClientWhatIfAtTenantScopeResponse], errResp azfake.ErrorResponder) } -// NewDeploymentsServerTransport creates a new instance of DeploymentsServerTransport with the provided implementation. -// The returned DeploymentsServerTransport instance is connected to an instance of armresources.DeploymentsClient via the +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of deployments.Client via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewDeploymentsServerTransport(srv *DeploymentsServer) *DeploymentsServerTransport { - return &DeploymentsServerTransport{ +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ srv: srv, - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateResponse]](), - beginCreateOrUpdateAtManagementGroupScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse]](), - beginCreateOrUpdateAtScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtScopeResponse]](), - beginCreateOrUpdateAtSubscriptionScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse]](), - beginCreateOrUpdateAtTenantScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtTenantScopeResponse]](), - beginDelete: newTracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteResponse]](), - beginDeleteAtManagementGroupScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtManagementGroupScopeResponse]](), - beginDeleteAtScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtScopeResponse]](), - beginDeleteAtSubscriptionScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtSubscriptionScopeResponse]](), - beginDeleteAtTenantScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtTenantScopeResponse]](), - newListAtManagementGroupScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentsClientListAtManagementGroupScopeResponse]](), - newListAtScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentsClientListAtScopeResponse]](), - newListAtSubscriptionScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentsClientListAtSubscriptionScopeResponse]](), - newListAtTenantScopePager: newTracker[azfake.PagerResponder[armresources.DeploymentsClientListAtTenantScopeResponse]](), - newListByResourceGroupPager: newTracker[azfake.PagerResponder[armresources.DeploymentsClientListByResourceGroupResponse]](), - beginValidate: newTracker[azfake.PollerResponder[armresources.DeploymentsClientValidateResponse]](), - beginValidateAtManagementGroupScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtManagementGroupScopeResponse]](), - beginValidateAtScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtScopeResponse]](), - beginValidateAtSubscriptionScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtSubscriptionScopeResponse]](), - beginValidateAtTenantScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtTenantScopeResponse]](), - beginWhatIf: newTracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfResponse]](), - beginWhatIfAtManagementGroupScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtManagementGroupScopeResponse]](), - beginWhatIfAtSubscriptionScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtSubscriptionScopeResponse]](), - beginWhatIfAtTenantScope: newTracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtTenantScopeResponse]](), + beginCreateOrUpdate: newTracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateResponse]](), + beginCreateOrUpdateAtManagementGroupScope: newTracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtManagementGroupScopeResponse]](), + beginCreateOrUpdateAtScope: newTracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtScopeResponse]](), + beginCreateOrUpdateAtSubscriptionScope: newTracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtSubscriptionScopeResponse]](), + beginCreateOrUpdateAtTenantScope: newTracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtTenantScopeResponse]](), + beginDelete: newTracker[azfake.PollerResponder[deployments.ClientDeleteResponse]](), + beginDeleteAtManagementGroupScope: newTracker[azfake.PollerResponder[deployments.ClientDeleteAtManagementGroupScopeResponse]](), + beginDeleteAtScope: newTracker[azfake.PollerResponder[deployments.ClientDeleteAtScopeResponse]](), + beginDeleteAtSubscriptionScope: newTracker[azfake.PollerResponder[deployments.ClientDeleteAtSubscriptionScopeResponse]](), + beginDeleteAtTenantScope: newTracker[azfake.PollerResponder[deployments.ClientDeleteAtTenantScopeResponse]](), + newListAtManagementGroupScopePager: newTracker[azfake.PagerResponder[deployments.ClientListAtManagementGroupScopeResponse]](), + newListAtScopePager: newTracker[azfake.PagerResponder[deployments.ClientListAtScopeResponse]](), + newListAtSubscriptionScopePager: newTracker[azfake.PagerResponder[deployments.ClientListAtSubscriptionScopeResponse]](), + newListAtTenantScopePager: newTracker[azfake.PagerResponder[deployments.ClientListAtTenantScopeResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[deployments.ClientListByResourceGroupResponse]](), + beginValidate: newTracker[azfake.PollerResponder[deployments.ClientValidateResponse]](), + beginValidateAtManagementGroupScope: newTracker[azfake.PollerResponder[deployments.ClientValidateAtManagementGroupScopeResponse]](), + beginValidateAtScope: newTracker[azfake.PollerResponder[deployments.ClientValidateAtScopeResponse]](), + beginValidateAtSubscriptionScope: newTracker[azfake.PollerResponder[deployments.ClientValidateAtSubscriptionScopeResponse]](), + beginValidateAtTenantScope: newTracker[azfake.PollerResponder[deployments.ClientValidateAtTenantScopeResponse]](), + beginWhatIf: newTracker[azfake.PollerResponder[deployments.ClientWhatIfResponse]](), + beginWhatIfAtManagementGroupScope: newTracker[azfake.PollerResponder[deployments.ClientWhatIfAtManagementGroupScopeResponse]](), + beginWhatIfAtSubscriptionScope: newTracker[azfake.PollerResponder[deployments.ClientWhatIfAtSubscriptionScopeResponse]](), + beginWhatIfAtTenantScope: newTracker[azfake.PollerResponder[deployments.ClientWhatIfAtTenantScopeResponse]](), } } -// DeploymentsServerTransport connects instances of armresources.DeploymentsClient to instances of DeploymentsServer. -// Don't use this type directly, use NewDeploymentsServerTransport instead. -type DeploymentsServerTransport struct { - srv *DeploymentsServer - beginCreateOrUpdate *tracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateResponse]] - beginCreateOrUpdateAtManagementGroupScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse]] - beginCreateOrUpdateAtScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtScopeResponse]] - beginCreateOrUpdateAtSubscriptionScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse]] - beginCreateOrUpdateAtTenantScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientCreateOrUpdateAtTenantScopeResponse]] - beginDelete *tracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteResponse]] - beginDeleteAtManagementGroupScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtManagementGroupScopeResponse]] - beginDeleteAtScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtScopeResponse]] - beginDeleteAtSubscriptionScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtSubscriptionScopeResponse]] - beginDeleteAtTenantScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientDeleteAtTenantScopeResponse]] - newListAtManagementGroupScopePager *tracker[azfake.PagerResponder[armresources.DeploymentsClientListAtManagementGroupScopeResponse]] - newListAtScopePager *tracker[azfake.PagerResponder[armresources.DeploymentsClientListAtScopeResponse]] - newListAtSubscriptionScopePager *tracker[azfake.PagerResponder[armresources.DeploymentsClientListAtSubscriptionScopeResponse]] - newListAtTenantScopePager *tracker[azfake.PagerResponder[armresources.DeploymentsClientListAtTenantScopeResponse]] - newListByResourceGroupPager *tracker[azfake.PagerResponder[armresources.DeploymentsClientListByResourceGroupResponse]] - beginValidate *tracker[azfake.PollerResponder[armresources.DeploymentsClientValidateResponse]] - beginValidateAtManagementGroupScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtManagementGroupScopeResponse]] - beginValidateAtScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtScopeResponse]] - beginValidateAtSubscriptionScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtSubscriptionScopeResponse]] - beginValidateAtTenantScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientValidateAtTenantScopeResponse]] - beginWhatIf *tracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfResponse]] - beginWhatIfAtManagementGroupScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtManagementGroupScopeResponse]] - beginWhatIfAtSubscriptionScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtSubscriptionScopeResponse]] - beginWhatIfAtTenantScope *tracker[azfake.PollerResponder[armresources.DeploymentsClientWhatIfAtTenantScopeResponse]] +// ServerTransport connects instances of deployments.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + beginCreateOrUpdate *tracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateResponse]] + beginCreateOrUpdateAtManagementGroupScope *tracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtManagementGroupScopeResponse]] + beginCreateOrUpdateAtScope *tracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtScopeResponse]] + beginCreateOrUpdateAtSubscriptionScope *tracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtSubscriptionScopeResponse]] + beginCreateOrUpdateAtTenantScope *tracker[azfake.PollerResponder[deployments.ClientCreateOrUpdateAtTenantScopeResponse]] + beginDelete *tracker[azfake.PollerResponder[deployments.ClientDeleteResponse]] + beginDeleteAtManagementGroupScope *tracker[azfake.PollerResponder[deployments.ClientDeleteAtManagementGroupScopeResponse]] + beginDeleteAtScope *tracker[azfake.PollerResponder[deployments.ClientDeleteAtScopeResponse]] + beginDeleteAtSubscriptionScope *tracker[azfake.PollerResponder[deployments.ClientDeleteAtSubscriptionScopeResponse]] + beginDeleteAtTenantScope *tracker[azfake.PollerResponder[deployments.ClientDeleteAtTenantScopeResponse]] + newListAtManagementGroupScopePager *tracker[azfake.PagerResponder[deployments.ClientListAtManagementGroupScopeResponse]] + newListAtScopePager *tracker[azfake.PagerResponder[deployments.ClientListAtScopeResponse]] + newListAtSubscriptionScopePager *tracker[azfake.PagerResponder[deployments.ClientListAtSubscriptionScopeResponse]] + newListAtTenantScopePager *tracker[azfake.PagerResponder[deployments.ClientListAtTenantScopeResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[deployments.ClientListByResourceGroupResponse]] + beginValidate *tracker[azfake.PollerResponder[deployments.ClientValidateResponse]] + beginValidateAtManagementGroupScope *tracker[azfake.PollerResponder[deployments.ClientValidateAtManagementGroupScopeResponse]] + beginValidateAtScope *tracker[azfake.PollerResponder[deployments.ClientValidateAtScopeResponse]] + beginValidateAtSubscriptionScope *tracker[azfake.PollerResponder[deployments.ClientValidateAtSubscriptionScopeResponse]] + beginValidateAtTenantScope *tracker[azfake.PollerResponder[deployments.ClientValidateAtTenantScopeResponse]] + beginWhatIf *tracker[azfake.PollerResponder[deployments.ClientWhatIfResponse]] + beginWhatIfAtManagementGroupScope *tracker[azfake.PollerResponder[deployments.ClientWhatIfAtManagementGroupScopeResponse]] + beginWhatIfAtSubscriptionScope *tracker[azfake.PollerResponder[deployments.ClientWhatIfAtSubscriptionScopeResponse]] + beginWhatIfAtTenantScope *tracker[azfake.PollerResponder[deployments.ClientWhatIfAtTenantScopeResponse]] } -// Do implements the policy.Transporter interface for DeploymentsServerTransport. -func (d *DeploymentsServerTransport) Do(req *http.Request) (*http.Response, error) { +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "DeploymentsClient.CalculateTemplateHash": - resp, err = d.dispatchCalculateTemplateHash(req) - case "DeploymentsClient.Cancel": - resp, err = d.dispatchCancel(req) - case "DeploymentsClient.CancelAtManagementGroupScope": - resp, err = d.dispatchCancelAtManagementGroupScope(req) - case "DeploymentsClient.CancelAtScope": - resp, err = d.dispatchCancelAtScope(req) - case "DeploymentsClient.CancelAtSubscriptionScope": - resp, err = d.dispatchCancelAtSubscriptionScope(req) - case "DeploymentsClient.CancelAtTenantScope": - resp, err = d.dispatchCancelAtTenantScope(req) - case "DeploymentsClient.CheckExistence": - resp, err = d.dispatchCheckExistence(req) - case "DeploymentsClient.CheckExistenceAtManagementGroupScope": - resp, err = d.dispatchCheckExistenceAtManagementGroupScope(req) - case "DeploymentsClient.CheckExistenceAtScope": - resp, err = d.dispatchCheckExistenceAtScope(req) - case "DeploymentsClient.CheckExistenceAtSubscriptionScope": - resp, err = d.dispatchCheckExistenceAtSubscriptionScope(req) - case "DeploymentsClient.CheckExistenceAtTenantScope": - resp, err = d.dispatchCheckExistenceAtTenantScope(req) - case "DeploymentsClient.BeginCreateOrUpdate": - resp, err = d.dispatchBeginCreateOrUpdate(req) - case "DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope": - resp, err = d.dispatchBeginCreateOrUpdateAtManagementGroupScope(req) - case "DeploymentsClient.BeginCreateOrUpdateAtScope": - resp, err = d.dispatchBeginCreateOrUpdateAtScope(req) - case "DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope": - resp, err = d.dispatchBeginCreateOrUpdateAtSubscriptionScope(req) - case "DeploymentsClient.BeginCreateOrUpdateAtTenantScope": - resp, err = d.dispatchBeginCreateOrUpdateAtTenantScope(req) - case "DeploymentsClient.BeginDelete": - resp, err = d.dispatchBeginDelete(req) - case "DeploymentsClient.BeginDeleteAtManagementGroupScope": - resp, err = d.dispatchBeginDeleteAtManagementGroupScope(req) - case "DeploymentsClient.BeginDeleteAtScope": - resp, err = d.dispatchBeginDeleteAtScope(req) - case "DeploymentsClient.BeginDeleteAtSubscriptionScope": - resp, err = d.dispatchBeginDeleteAtSubscriptionScope(req) - case "DeploymentsClient.BeginDeleteAtTenantScope": - resp, err = d.dispatchBeginDeleteAtTenantScope(req) - case "DeploymentsClient.ExportTemplate": - resp, err = d.dispatchExportTemplate(req) - case "DeploymentsClient.ExportTemplateAtManagementGroupScope": - resp, err = d.dispatchExportTemplateAtManagementGroupScope(req) - case "DeploymentsClient.ExportTemplateAtScope": - resp, err = d.dispatchExportTemplateAtScope(req) - case "DeploymentsClient.ExportTemplateAtSubscriptionScope": - resp, err = d.dispatchExportTemplateAtSubscriptionScope(req) - case "DeploymentsClient.ExportTemplateAtTenantScope": - resp, err = d.dispatchExportTemplateAtTenantScope(req) - case "DeploymentsClient.Get": - resp, err = d.dispatchGet(req) - case "DeploymentsClient.GetAtManagementGroupScope": - resp, err = d.dispatchGetAtManagementGroupScope(req) - case "DeploymentsClient.GetAtScope": - resp, err = d.dispatchGetAtScope(req) - case "DeploymentsClient.GetAtSubscriptionScope": - resp, err = d.dispatchGetAtSubscriptionScope(req) - case "DeploymentsClient.GetAtTenantScope": - resp, err = d.dispatchGetAtTenantScope(req) - case "DeploymentsClient.NewListAtManagementGroupScopePager": - resp, err = d.dispatchNewListAtManagementGroupScopePager(req) - case "DeploymentsClient.NewListAtScopePager": - resp, err = d.dispatchNewListAtScopePager(req) - case "DeploymentsClient.NewListAtSubscriptionScopePager": - resp, err = d.dispatchNewListAtSubscriptionScopePager(req) - case "DeploymentsClient.NewListAtTenantScopePager": - resp, err = d.dispatchNewListAtTenantScopePager(req) - case "DeploymentsClient.NewListByResourceGroupPager": - resp, err = d.dispatchNewListByResourceGroupPager(req) - case "DeploymentsClient.BeginValidate": - resp, err = d.dispatchBeginValidate(req) - case "DeploymentsClient.BeginValidateAtManagementGroupScope": - resp, err = d.dispatchBeginValidateAtManagementGroupScope(req) - case "DeploymentsClient.BeginValidateAtScope": - resp, err = d.dispatchBeginValidateAtScope(req) - case "DeploymentsClient.BeginValidateAtSubscriptionScope": - resp, err = d.dispatchBeginValidateAtSubscriptionScope(req) - case "DeploymentsClient.BeginValidateAtTenantScope": - resp, err = d.dispatchBeginValidateAtTenantScope(req) - case "DeploymentsClient.BeginWhatIf": - resp, err = d.dispatchBeginWhatIf(req) - case "DeploymentsClient.BeginWhatIfAtManagementGroupScope": - resp, err = d.dispatchBeginWhatIfAtManagementGroupScope(req) - case "DeploymentsClient.BeginWhatIfAtSubscriptionScope": - resp, err = d.dispatchBeginWhatIfAtSubscriptionScope(req) - case "DeploymentsClient.BeginWhatIfAtTenantScope": - resp, err = d.dispatchBeginWhatIfAtTenantScope(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return s.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.CalculateTemplateHash": + res.resp, res.err = s.dispatchCalculateTemplateHash(req) + case "Client.Cancel": + res.resp, res.err = s.dispatchCancel(req) + case "Client.CancelAtManagementGroupScope": + res.resp, res.err = s.dispatchCancelAtManagementGroupScope(req) + case "Client.CancelAtScope": + res.resp, res.err = s.dispatchCancelAtScope(req) + case "Client.CancelAtSubscriptionScope": + res.resp, res.err = s.dispatchCancelAtSubscriptionScope(req) + case "Client.CancelAtTenantScope": + res.resp, res.err = s.dispatchCancelAtTenantScope(req) + case "Client.CheckExistence": + res.resp, res.err = s.dispatchCheckExistence(req) + case "Client.CheckExistenceAtManagementGroupScope": + res.resp, res.err = s.dispatchCheckExistenceAtManagementGroupScope(req) + case "Client.CheckExistenceAtScope": + res.resp, res.err = s.dispatchCheckExistenceAtScope(req) + case "Client.CheckExistenceAtSubscriptionScope": + res.resp, res.err = s.dispatchCheckExistenceAtSubscriptionScope(req) + case "Client.CheckExistenceAtTenantScope": + res.resp, res.err = s.dispatchCheckExistenceAtTenantScope(req) + case "Client.BeginCreateOrUpdate": + res.resp, res.err = s.dispatchBeginCreateOrUpdate(req) + case "Client.BeginCreateOrUpdateAtManagementGroupScope": + res.resp, res.err = s.dispatchBeginCreateOrUpdateAtManagementGroupScope(req) + case "Client.BeginCreateOrUpdateAtScope": + res.resp, res.err = s.dispatchBeginCreateOrUpdateAtScope(req) + case "Client.BeginCreateOrUpdateAtSubscriptionScope": + res.resp, res.err = s.dispatchBeginCreateOrUpdateAtSubscriptionScope(req) + case "Client.BeginCreateOrUpdateAtTenantScope": + res.resp, res.err = s.dispatchBeginCreateOrUpdateAtTenantScope(req) + case "Client.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "Client.BeginDeleteAtManagementGroupScope": + res.resp, res.err = s.dispatchBeginDeleteAtManagementGroupScope(req) + case "Client.BeginDeleteAtScope": + res.resp, res.err = s.dispatchBeginDeleteAtScope(req) + case "Client.BeginDeleteAtSubscriptionScope": + res.resp, res.err = s.dispatchBeginDeleteAtSubscriptionScope(req) + case "Client.BeginDeleteAtTenantScope": + res.resp, res.err = s.dispatchBeginDeleteAtTenantScope(req) + case "Client.ExportTemplate": + res.resp, res.err = s.dispatchExportTemplate(req) + case "Client.ExportTemplateAtManagementGroupScope": + res.resp, res.err = s.dispatchExportTemplateAtManagementGroupScope(req) + case "Client.ExportTemplateAtScope": + res.resp, res.err = s.dispatchExportTemplateAtScope(req) + case "Client.ExportTemplateAtSubscriptionScope": + res.resp, res.err = s.dispatchExportTemplateAtSubscriptionScope(req) + case "Client.ExportTemplateAtTenantScope": + res.resp, res.err = s.dispatchExportTemplateAtTenantScope(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.GetAtManagementGroupScope": + res.resp, res.err = s.dispatchGetAtManagementGroupScope(req) + case "Client.GetAtScope": + res.resp, res.err = s.dispatchGetAtScope(req) + case "Client.GetAtSubscriptionScope": + res.resp, res.err = s.dispatchGetAtSubscriptionScope(req) + case "Client.GetAtTenantScope": + res.resp, res.err = s.dispatchGetAtTenantScope(req) + case "Client.NewListAtManagementGroupScopePager": + res.resp, res.err = s.dispatchNewListAtManagementGroupScopePager(req) + case "Client.NewListAtScopePager": + res.resp, res.err = s.dispatchNewListAtScopePager(req) + case "Client.NewListAtSubscriptionScopePager": + res.resp, res.err = s.dispatchNewListAtSubscriptionScopePager(req) + case "Client.NewListAtTenantScopePager": + res.resp, res.err = s.dispatchNewListAtTenantScopePager(req) + case "Client.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "Client.BeginValidate": + res.resp, res.err = s.dispatchBeginValidate(req) + case "Client.BeginValidateAtManagementGroupScope": + res.resp, res.err = s.dispatchBeginValidateAtManagementGroupScope(req) + case "Client.BeginValidateAtScope": + res.resp, res.err = s.dispatchBeginValidateAtScope(req) + case "Client.BeginValidateAtSubscriptionScope": + res.resp, res.err = s.dispatchBeginValidateAtSubscriptionScope(req) + case "Client.BeginValidateAtTenantScope": + res.resp, res.err = s.dispatchBeginValidateAtTenantScope(req) + case "Client.BeginWhatIf": + res.resp, res.err = s.dispatchBeginWhatIf(req) + case "Client.BeginWhatIfAtManagementGroupScope": + res.resp, res.err = s.dispatchBeginWhatIfAtManagementGroupScope(req) + case "Client.BeginWhatIfAtSubscriptionScope": + res.resp, res.err = s.dispatchBeginWhatIfAtSubscriptionScope(req) + case "Client.BeginWhatIfAtTenantScope": + res.resp, res.err = s.dispatchBeginWhatIfAtTenantScope(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } -func (d *DeploymentsServerTransport) dispatchCalculateTemplateHash(req *http.Request) (*http.Response, error) { - if d.srv.CalculateTemplateHash == nil { +func (s *ServerTransport) dispatchCalculateTemplateHash(req *http.Request) (*http.Response, error) { + if s.srv.CalculateTemplateHash == nil { return nil, &nonRetriableError{errors.New("fake for method CalculateTemplateHash not implemented")} } body, err := server.UnmarshalRequestAsJSON[any](req) if err != nil { return nil, err } - respr, errRespr := d.srv.CalculateTemplateHash(req.Context(), body, nil) + respr, errRespr := s.srv.CalculateTemplateHash(req.Context(), body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -405,8 +421,8 @@ func (d *DeploymentsServerTransport) dispatchCalculateTemplateHash(req *http.Req return resp, nil } -func (d *DeploymentsServerTransport) dispatchCancel(req *http.Request) (*http.Response, error) { - if d.srv.Cancel == nil { +func (s *ServerTransport) dispatchCancel(req *http.Request) (*http.Response, error) { + if s.srv.Cancel == nil { return nil, &nonRetriableError{errors.New("fake for method Cancel not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` @@ -423,7 +439,7 @@ func (d *DeploymentsServerTransport) dispatchCancel(req *http.Request) (*http.Re if err != nil { return nil, err } - respr, errRespr := d.srv.Cancel(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) + respr, errRespr := s.srv.Cancel(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -438,8 +454,8 @@ func (d *DeploymentsServerTransport) dispatchCancel(req *http.Request) (*http.Re return resp, nil } -func (d *DeploymentsServerTransport) dispatchCancelAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.CancelAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchCancelAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.CancelAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method CancelAtManagementGroupScope not implemented")} } const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` @@ -456,7 +472,7 @@ func (d *DeploymentsServerTransport) dispatchCancelAtManagementGroupScope(req *h if err != nil { return nil, err } - respr, errRespr := d.srv.CancelAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) + respr, errRespr := s.srv.CancelAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -471,8 +487,8 @@ func (d *DeploymentsServerTransport) dispatchCancelAtManagementGroupScope(req *h return resp, nil } -func (d *DeploymentsServerTransport) dispatchCancelAtScope(req *http.Request) (*http.Response, error) { - if d.srv.CancelAtScope == nil { +func (s *ServerTransport) dispatchCancelAtScope(req *http.Request) (*http.Response, error) { + if s.srv.CancelAtScope == nil { return nil, &nonRetriableError{errors.New("fake for method CancelAtScope not implemented")} } const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` @@ -489,7 +505,7 @@ func (d *DeploymentsServerTransport) dispatchCancelAtScope(req *http.Request) (* if err != nil { return nil, err } - respr, errRespr := d.srv.CancelAtScope(req.Context(), scopeParam, deploymentNameParam, nil) + respr, errRespr := s.srv.CancelAtScope(req.Context(), scopeParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -504,8 +520,8 @@ func (d *DeploymentsServerTransport) dispatchCancelAtScope(req *http.Request) (* return resp, nil } -func (d *DeploymentsServerTransport) dispatchCancelAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.CancelAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchCancelAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.CancelAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method CancelAtSubscriptionScope not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` @@ -518,7 +534,7 @@ func (d *DeploymentsServerTransport) dispatchCancelAtSubscriptionScope(req *http if err != nil { return nil, err } - respr, errRespr := d.srv.CancelAtSubscriptionScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.CancelAtSubscriptionScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -533,8 +549,8 @@ func (d *DeploymentsServerTransport) dispatchCancelAtSubscriptionScope(req *http return resp, nil } -func (d *DeploymentsServerTransport) dispatchCancelAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.CancelAtTenantScope == nil { +func (s *ServerTransport) dispatchCancelAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.CancelAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method CancelAtTenantScope not implemented")} } const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` @@ -547,7 +563,7 @@ func (d *DeploymentsServerTransport) dispatchCancelAtTenantScope(req *http.Reque if err != nil { return nil, err } - respr, errRespr := d.srv.CancelAtTenantScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.CancelAtTenantScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -562,8 +578,8 @@ func (d *DeploymentsServerTransport) dispatchCancelAtTenantScope(req *http.Reque return resp, nil } -func (d *DeploymentsServerTransport) dispatchCheckExistence(req *http.Request) (*http.Response, error) { - if d.srv.CheckExistence == nil { +func (s *ServerTransport) dispatchCheckExistence(req *http.Request) (*http.Response, error) { + if s.srv.CheckExistence == nil { return nil, &nonRetriableError{errors.New("fake for method CheckExistence not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -580,7 +596,7 @@ func (d *DeploymentsServerTransport) dispatchCheckExistence(req *http.Request) ( if err != nil { return nil, err } - respr, errRespr := d.srv.CheckExistence(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) + respr, errRespr := s.srv.CheckExistence(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -595,8 +611,8 @@ func (d *DeploymentsServerTransport) dispatchCheckExistence(req *http.Request) ( return resp, nil } -func (d *DeploymentsServerTransport) dispatchCheckExistenceAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.CheckExistenceAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchCheckExistenceAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.CheckExistenceAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method CheckExistenceAtManagementGroupScope not implemented")} } const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -613,7 +629,7 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtManagementGroupScop if err != nil { return nil, err } - respr, errRespr := d.srv.CheckExistenceAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) + respr, errRespr := s.srv.CheckExistenceAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -628,8 +644,8 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtManagementGroupScop return resp, nil } -func (d *DeploymentsServerTransport) dispatchCheckExistenceAtScope(req *http.Request) (*http.Response, error) { - if d.srv.CheckExistenceAtScope == nil { +func (s *ServerTransport) dispatchCheckExistenceAtScope(req *http.Request) (*http.Response, error) { + if s.srv.CheckExistenceAtScope == nil { return nil, &nonRetriableError{errors.New("fake for method CheckExistenceAtScope not implemented")} } const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -646,7 +662,7 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtScope(req *http.Req if err != nil { return nil, err } - respr, errRespr := d.srv.CheckExistenceAtScope(req.Context(), scopeParam, deploymentNameParam, nil) + respr, errRespr := s.srv.CheckExistenceAtScope(req.Context(), scopeParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -661,8 +677,8 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtScope(req *http.Req return resp, nil } -func (d *DeploymentsServerTransport) dispatchCheckExistenceAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.CheckExistenceAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchCheckExistenceAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.CheckExistenceAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method CheckExistenceAtSubscriptionScope not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -675,7 +691,7 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtSubscriptionScope(r if err != nil { return nil, err } - respr, errRespr := d.srv.CheckExistenceAtSubscriptionScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.CheckExistenceAtSubscriptionScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -690,8 +706,8 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtSubscriptionScope(r return resp, nil } -func (d *DeploymentsServerTransport) dispatchCheckExistenceAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.CheckExistenceAtTenantScope == nil { +func (s *ServerTransport) dispatchCheckExistenceAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.CheckExistenceAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method CheckExistenceAtTenantScope not implemented")} } const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -704,7 +720,7 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtTenantScope(req *ht if err != nil { return nil, err } - respr, errRespr := d.srv.CheckExistenceAtTenantScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.CheckExistenceAtTenantScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -719,11 +735,11 @@ func (d *DeploymentsServerTransport) dispatchCheckExistenceAtTenantScope(req *ht return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { - if d.srv.BeginCreateOrUpdate == nil { +func (s *ServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} } - beginCreateOrUpdate := d.beginCreateOrUpdate.get(req) + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) if beginCreateOrUpdate == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -731,7 +747,7 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Reque if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.Deployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.Deployment](req) if err != nil { return nil, err } @@ -743,12 +759,12 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Reque if err != nil { return nil, err } - respr, errRespr := d.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginCreateOrUpdate = &respr - d.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + s.beginCreateOrUpdate.add(req, beginCreateOrUpdate) } resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) @@ -757,21 +773,21 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Reque } if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - d.beginCreateOrUpdate.remove(req) + s.beginCreateOrUpdate.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { - d.beginCreateOrUpdate.remove(req) + s.beginCreateOrUpdate.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginCreateOrUpdateAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchBeginCreateOrUpdateAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdateAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtManagementGroupScope not implemented")} } - beginCreateOrUpdateAtManagementGroupScope := d.beginCreateOrUpdateAtManagementGroupScope.get(req) + beginCreateOrUpdateAtManagementGroupScope := s.beginCreateOrUpdateAtManagementGroupScope.get(req) if beginCreateOrUpdateAtManagementGroupScope == nil { const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -779,7 +795,7 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtManagementGrou if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.ScopedDeployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.ScopedDeployment](req) if err != nil { return nil, err } @@ -791,12 +807,12 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtManagementGrou if err != nil { return nil, err } - respr, errRespr := d.srv.BeginCreateOrUpdateAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginCreateOrUpdateAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginCreateOrUpdateAtManagementGroupScope = &respr - d.beginCreateOrUpdateAtManagementGroupScope.add(req, beginCreateOrUpdateAtManagementGroupScope) + s.beginCreateOrUpdateAtManagementGroupScope.add(req, beginCreateOrUpdateAtManagementGroupScope) } resp, err := server.PollerResponderNext(beginCreateOrUpdateAtManagementGroupScope, req) @@ -805,21 +821,21 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtManagementGrou } if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - d.beginCreateOrUpdateAtManagementGroupScope.remove(req) + s.beginCreateOrUpdateAtManagementGroupScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdateAtManagementGroupScope) { - d.beginCreateOrUpdateAtManagementGroupScope.remove(req) + s.beginCreateOrUpdateAtManagementGroupScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginCreateOrUpdateAtScope == nil { +func (s *ServerTransport) dispatchBeginCreateOrUpdateAtScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdateAtScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtScope not implemented")} } - beginCreateOrUpdateAtScope := d.beginCreateOrUpdateAtScope.get(req) + beginCreateOrUpdateAtScope := s.beginCreateOrUpdateAtScope.get(req) if beginCreateOrUpdateAtScope == nil { const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -827,7 +843,7 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtScope(req *htt if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.Deployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.Deployment](req) if err != nil { return nil, err } @@ -839,12 +855,12 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtScope(req *htt if err != nil { return nil, err } - respr, errRespr := d.srv.BeginCreateOrUpdateAtScope(req.Context(), scopeParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginCreateOrUpdateAtScope(req.Context(), scopeParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginCreateOrUpdateAtScope = &respr - d.beginCreateOrUpdateAtScope.add(req, beginCreateOrUpdateAtScope) + s.beginCreateOrUpdateAtScope.add(req, beginCreateOrUpdateAtScope) } resp, err := server.PollerResponderNext(beginCreateOrUpdateAtScope, req) @@ -853,21 +869,21 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtScope(req *htt } if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - d.beginCreateOrUpdateAtScope.remove(req) + s.beginCreateOrUpdateAtScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdateAtScope) { - d.beginCreateOrUpdateAtScope.remove(req) + s.beginCreateOrUpdateAtScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginCreateOrUpdateAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchBeginCreateOrUpdateAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdateAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtSubscriptionScope not implemented")} } - beginCreateOrUpdateAtSubscriptionScope := d.beginCreateOrUpdateAtSubscriptionScope.get(req) + beginCreateOrUpdateAtSubscriptionScope := s.beginCreateOrUpdateAtSubscriptionScope.get(req) if beginCreateOrUpdateAtSubscriptionScope == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -875,7 +891,7 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtSubscriptionSc if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.Deployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.Deployment](req) if err != nil { return nil, err } @@ -883,12 +899,12 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtSubscriptionSc if err != nil { return nil, err } - respr, errRespr := d.srv.BeginCreateOrUpdateAtSubscriptionScope(req.Context(), deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginCreateOrUpdateAtSubscriptionScope(req.Context(), deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginCreateOrUpdateAtSubscriptionScope = &respr - d.beginCreateOrUpdateAtSubscriptionScope.add(req, beginCreateOrUpdateAtSubscriptionScope) + s.beginCreateOrUpdateAtSubscriptionScope.add(req, beginCreateOrUpdateAtSubscriptionScope) } resp, err := server.PollerResponderNext(beginCreateOrUpdateAtSubscriptionScope, req) @@ -897,21 +913,21 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtSubscriptionSc } if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - d.beginCreateOrUpdateAtSubscriptionScope.remove(req) + s.beginCreateOrUpdateAtSubscriptionScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdateAtSubscriptionScope) { - d.beginCreateOrUpdateAtSubscriptionScope.remove(req) + s.beginCreateOrUpdateAtSubscriptionScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginCreateOrUpdateAtTenantScope == nil { +func (s *ServerTransport) dispatchBeginCreateOrUpdateAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdateAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtTenantScope not implemented")} } - beginCreateOrUpdateAtTenantScope := d.beginCreateOrUpdateAtTenantScope.get(req) + beginCreateOrUpdateAtTenantScope := s.beginCreateOrUpdateAtTenantScope.get(req) if beginCreateOrUpdateAtTenantScope == nil { const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -919,7 +935,7 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtTenantScope(re if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.ScopedDeployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.ScopedDeployment](req) if err != nil { return nil, err } @@ -927,12 +943,12 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtTenantScope(re if err != nil { return nil, err } - respr, errRespr := d.srv.BeginCreateOrUpdateAtTenantScope(req.Context(), deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginCreateOrUpdateAtTenantScope(req.Context(), deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginCreateOrUpdateAtTenantScope = &respr - d.beginCreateOrUpdateAtTenantScope.add(req, beginCreateOrUpdateAtTenantScope) + s.beginCreateOrUpdateAtTenantScope.add(req, beginCreateOrUpdateAtTenantScope) } resp, err := server.PollerResponderNext(beginCreateOrUpdateAtTenantScope, req) @@ -941,21 +957,21 @@ func (d *DeploymentsServerTransport) dispatchBeginCreateOrUpdateAtTenantScope(re } if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - d.beginCreateOrUpdateAtTenantScope.remove(req) + s.beginCreateOrUpdateAtTenantScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdateAtTenantScope) { - d.beginCreateOrUpdateAtTenantScope.remove(req) + s.beginCreateOrUpdateAtTenantScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { - if d.srv.BeginDelete == nil { +func (s *ServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } - beginDelete := d.beginDelete.get(req) + beginDelete := s.beginDelete.get(req) if beginDelete == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -971,12 +987,12 @@ func (d *DeploymentsServerTransport) dispatchBeginDelete(req *http.Request) (*ht if err != nil { return nil, err } - respr, errRespr := d.srv.BeginDelete(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginDelete = &respr - d.beginDelete.add(req, beginDelete) + s.beginDelete.add(req, beginDelete) } resp, err := server.PollerResponderNext(beginDelete, req) @@ -984,22 +1000,22 @@ func (d *DeploymentsServerTransport) dispatchBeginDelete(req *http.Request) (*ht return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - d.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { - d.beginDelete.remove(req) + s.beginDelete.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginDeleteAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginDeleteAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchBeginDeleteAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtManagementGroupScope not implemented")} } - beginDeleteAtManagementGroupScope := d.beginDeleteAtManagementGroupScope.get(req) + beginDeleteAtManagementGroupScope := s.beginDeleteAtManagementGroupScope.get(req) if beginDeleteAtManagementGroupScope == nil { const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -1015,12 +1031,12 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtManagementGroupScope(r if err != nil { return nil, err } - respr, errRespr := d.srv.BeginDeleteAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) + respr, errRespr := s.srv.BeginDeleteAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginDeleteAtManagementGroupScope = &respr - d.beginDeleteAtManagementGroupScope.add(req, beginDeleteAtManagementGroupScope) + s.beginDeleteAtManagementGroupScope.add(req, beginDeleteAtManagementGroupScope) } resp, err := server.PollerResponderNext(beginDeleteAtManagementGroupScope, req) @@ -1028,22 +1044,22 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtManagementGroupScope(r return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - d.beginDeleteAtManagementGroupScope.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAtManagementGroupScope.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDeleteAtManagementGroupScope) { - d.beginDeleteAtManagementGroupScope.remove(req) + s.beginDeleteAtManagementGroupScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginDeleteAtScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginDeleteAtScope == nil { +func (s *ServerTransport) dispatchBeginDeleteAtScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAtScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtScope not implemented")} } - beginDeleteAtScope := d.beginDeleteAtScope.get(req) + beginDeleteAtScope := s.beginDeleteAtScope.get(req) if beginDeleteAtScope == nil { const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -1059,12 +1075,12 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtScope(req *http.Reques if err != nil { return nil, err } - respr, errRespr := d.srv.BeginDeleteAtScope(req.Context(), scopeParam, deploymentNameParam, nil) + respr, errRespr := s.srv.BeginDeleteAtScope(req.Context(), scopeParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginDeleteAtScope = &respr - d.beginDeleteAtScope.add(req, beginDeleteAtScope) + s.beginDeleteAtScope.add(req, beginDeleteAtScope) } resp, err := server.PollerResponderNext(beginDeleteAtScope, req) @@ -1072,22 +1088,22 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtScope(req *http.Reques return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - d.beginDeleteAtScope.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAtScope.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDeleteAtScope) { - d.beginDeleteAtScope.remove(req) + s.beginDeleteAtScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginDeleteAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginDeleteAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchBeginDeleteAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtSubscriptionScope not implemented")} } - beginDeleteAtSubscriptionScope := d.beginDeleteAtSubscriptionScope.get(req) + beginDeleteAtSubscriptionScope := s.beginDeleteAtSubscriptionScope.get(req) if beginDeleteAtSubscriptionScope == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -1099,12 +1115,12 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtSubscriptionScope(req if err != nil { return nil, err } - respr, errRespr := d.srv.BeginDeleteAtSubscriptionScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.BeginDeleteAtSubscriptionScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginDeleteAtSubscriptionScope = &respr - d.beginDeleteAtSubscriptionScope.add(req, beginDeleteAtSubscriptionScope) + s.beginDeleteAtSubscriptionScope.add(req, beginDeleteAtSubscriptionScope) } resp, err := server.PollerResponderNext(beginDeleteAtSubscriptionScope, req) @@ -1112,22 +1128,22 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtSubscriptionScope(req return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - d.beginDeleteAtSubscriptionScope.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAtSubscriptionScope.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDeleteAtSubscriptionScope) { - d.beginDeleteAtSubscriptionScope.remove(req) + s.beginDeleteAtSubscriptionScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginDeleteAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginDeleteAtTenantScope == nil { +func (s *ServerTransport) dispatchBeginDeleteAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtTenantScope not implemented")} } - beginDeleteAtTenantScope := d.beginDeleteAtTenantScope.get(req) + beginDeleteAtTenantScope := s.beginDeleteAtTenantScope.get(req) if beginDeleteAtTenantScope == nil { const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) @@ -1139,12 +1155,12 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtTenantScope(req *http. if err != nil { return nil, err } - respr, errRespr := d.srv.BeginDeleteAtTenantScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.BeginDeleteAtTenantScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginDeleteAtTenantScope = &respr - d.beginDeleteAtTenantScope.add(req, beginDeleteAtTenantScope) + s.beginDeleteAtTenantScope.add(req, beginDeleteAtTenantScope) } resp, err := server.PollerResponderNext(beginDeleteAtTenantScope, req) @@ -1152,19 +1168,19 @@ func (d *DeploymentsServerTransport) dispatchBeginDeleteAtTenantScope(req *http. return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - d.beginDeleteAtTenantScope.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAtTenantScope.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDeleteAtTenantScope) { - d.beginDeleteAtTenantScope.remove(req) + s.beginDeleteAtTenantScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchExportTemplate(req *http.Request) (*http.Response, error) { - if d.srv.ExportTemplate == nil { +func (s *ServerTransport) dispatchExportTemplate(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplate == nil { return nil, &nonRetriableError{errors.New("fake for method ExportTemplate not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` @@ -1181,7 +1197,7 @@ func (d *DeploymentsServerTransport) dispatchExportTemplate(req *http.Request) ( if err != nil { return nil, err } - respr, errRespr := d.srv.ExportTemplate(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) + respr, errRespr := s.srv.ExportTemplate(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1196,8 +1212,8 @@ func (d *DeploymentsServerTransport) dispatchExportTemplate(req *http.Request) ( return resp, nil } -func (d *DeploymentsServerTransport) dispatchExportTemplateAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.ExportTemplateAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchExportTemplateAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplateAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method ExportTemplateAtManagementGroupScope not implemented")} } const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` @@ -1214,7 +1230,7 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtManagementGroupScop if err != nil { return nil, err } - respr, errRespr := d.srv.ExportTemplateAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) + respr, errRespr := s.srv.ExportTemplateAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1229,8 +1245,8 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtManagementGroupScop return resp, nil } -func (d *DeploymentsServerTransport) dispatchExportTemplateAtScope(req *http.Request) (*http.Response, error) { - if d.srv.ExportTemplateAtScope == nil { +func (s *ServerTransport) dispatchExportTemplateAtScope(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplateAtScope == nil { return nil, &nonRetriableError{errors.New("fake for method ExportTemplateAtScope not implemented")} } const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` @@ -1247,7 +1263,7 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtScope(req *http.Req if err != nil { return nil, err } - respr, errRespr := d.srv.ExportTemplateAtScope(req.Context(), scopeParam, deploymentNameParam, nil) + respr, errRespr := s.srv.ExportTemplateAtScope(req.Context(), scopeParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1262,8 +1278,8 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtScope(req *http.Req return resp, nil } -func (d *DeploymentsServerTransport) dispatchExportTemplateAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.ExportTemplateAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchExportTemplateAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplateAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method ExportTemplateAtSubscriptionScope not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` @@ -1276,7 +1292,7 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtSubscriptionScope(r if err != nil { return nil, err } - respr, errRespr := d.srv.ExportTemplateAtSubscriptionScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.ExportTemplateAtSubscriptionScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1291,8 +1307,8 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtSubscriptionScope(r return resp, nil } -func (d *DeploymentsServerTransport) dispatchExportTemplateAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.ExportTemplateAtTenantScope == nil { +func (s *ServerTransport) dispatchExportTemplateAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplateAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method ExportTemplateAtTenantScope not implemented")} } const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` @@ -1305,7 +1321,7 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtTenantScope(req *ht if err != nil { return nil, err } - respr, errRespr := d.srv.ExportTemplateAtTenantScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.ExportTemplateAtTenantScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1320,8 +1336,8 @@ func (d *DeploymentsServerTransport) dispatchExportTemplateAtTenantScope(req *ht return resp, nil } -func (d *DeploymentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if d.srv.Get == nil { +func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -1338,7 +1354,7 @@ func (d *DeploymentsServerTransport) dispatchGet(req *http.Request) (*http.Respo if err != nil { return nil, err } - respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1353,8 +1369,8 @@ func (d *DeploymentsServerTransport) dispatchGet(req *http.Request) (*http.Respo return resp, nil } -func (d *DeploymentsServerTransport) dispatchGetAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.GetAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchGetAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.GetAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroupScope not implemented")} } const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -1371,7 +1387,7 @@ func (d *DeploymentsServerTransport) dispatchGetAtManagementGroupScope(req *http if err != nil { return nil, err } - respr, errRespr := d.srv.GetAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) + respr, errRespr := s.srv.GetAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1386,8 +1402,8 @@ func (d *DeploymentsServerTransport) dispatchGetAtManagementGroupScope(req *http return resp, nil } -func (d *DeploymentsServerTransport) dispatchGetAtScope(req *http.Request) (*http.Response, error) { - if d.srv.GetAtScope == nil { +func (s *ServerTransport) dispatchGetAtScope(req *http.Request) (*http.Response, error) { + if s.srv.GetAtScope == nil { return nil, &nonRetriableError{errors.New("fake for method GetAtScope not implemented")} } const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -1404,7 +1420,7 @@ func (d *DeploymentsServerTransport) dispatchGetAtScope(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := d.srv.GetAtScope(req.Context(), scopeParam, deploymentNameParam, nil) + respr, errRespr := s.srv.GetAtScope(req.Context(), scopeParam, deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1419,8 +1435,8 @@ func (d *DeploymentsServerTransport) dispatchGetAtScope(req *http.Request) (*htt return resp, nil } -func (d *DeploymentsServerTransport) dispatchGetAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.GetAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchGetAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.GetAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method GetAtSubscriptionScope not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -1433,7 +1449,7 @@ func (d *DeploymentsServerTransport) dispatchGetAtSubscriptionScope(req *http.Re if err != nil { return nil, err } - respr, errRespr := d.srv.GetAtSubscriptionScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.GetAtSubscriptionScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1448,8 +1464,8 @@ func (d *DeploymentsServerTransport) dispatchGetAtSubscriptionScope(req *http.Re return resp, nil } -func (d *DeploymentsServerTransport) dispatchGetAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.GetAtTenantScope == nil { +func (s *ServerTransport) dispatchGetAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.GetAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method GetAtTenantScope not implemented")} } const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` @@ -1462,7 +1478,7 @@ func (d *DeploymentsServerTransport) dispatchGetAtTenantScope(req *http.Request) if err != nil { return nil, err } - respr, errRespr := d.srv.GetAtTenantScope(req.Context(), deploymentNameParam, nil) + respr, errRespr := s.srv.GetAtTenantScope(req.Context(), deploymentNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -1477,11 +1493,11 @@ func (d *DeploymentsServerTransport) dispatchGetAtTenantScope(req *http.Request) return resp, nil } -func (d *DeploymentsServerTransport) dispatchNewListAtManagementGroupScopePager(req *http.Request) (*http.Response, error) { - if d.srv.NewListAtManagementGroupScopePager == nil { +func (s *ServerTransport) dispatchNewListAtManagementGroupScopePager(req *http.Request) (*http.Response, error) { + if s.srv.NewListAtManagementGroupScopePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListAtManagementGroupScopePager not implemented")} } - newListAtManagementGroupScopePager := d.newListAtManagementGroupScopePager.get(req) + newListAtManagementGroupScopePager := s.newListAtManagementGroupScopePager.get(req) if newListAtManagementGroupScopePager == nil { const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/` regex := regexp.MustCompile(regexStr) @@ -1513,17 +1529,17 @@ func (d *DeploymentsServerTransport) dispatchNewListAtManagementGroupScopePager( if err != nil { return nil, err } - var options *armresources.DeploymentsClientListAtManagementGroupScopeOptions + var options *deployments.ClientListAtManagementGroupScopeOptions if filterParam != nil || topParam != nil { - options = &armresources.DeploymentsClientListAtManagementGroupScopeOptions{ + options = &deployments.ClientListAtManagementGroupScopeOptions{ Filter: filterParam, Top: topParam, } } - resp := d.srv.NewListAtManagementGroupScopePager(groupIDParam, options) + resp := s.srv.NewListAtManagementGroupScopePager(groupIDParam, options) newListAtManagementGroupScopePager = &resp - d.newListAtManagementGroupScopePager.add(req, newListAtManagementGroupScopePager) - server.PagerResponderInjectNextLinks(newListAtManagementGroupScopePager, req, func(page *armresources.DeploymentsClientListAtManagementGroupScopeResponse, createLink func() string) { + s.newListAtManagementGroupScopePager.add(req, newListAtManagementGroupScopePager) + server.PagerResponderInjectNextLinks(newListAtManagementGroupScopePager, req, func(page *deployments.ClientListAtManagementGroupScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -1532,20 +1548,20 @@ func (d *DeploymentsServerTransport) dispatchNewListAtManagementGroupScopePager( return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - d.newListAtManagementGroupScopePager.remove(req) + s.newListAtManagementGroupScopePager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListAtManagementGroupScopePager) { - d.newListAtManagementGroupScopePager.remove(req) + s.newListAtManagementGroupScopePager.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchNewListAtScopePager(req *http.Request) (*http.Response, error) { - if d.srv.NewListAtScopePager == nil { +func (s *ServerTransport) dispatchNewListAtScopePager(req *http.Request) (*http.Response, error) { + if s.srv.NewListAtScopePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListAtScopePager not implemented")} } - newListAtScopePager := d.newListAtScopePager.get(req) + newListAtScopePager := s.newListAtScopePager.get(req) if newListAtScopePager == nil { const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/` regex := regexp.MustCompile(regexStr) @@ -1577,17 +1593,17 @@ func (d *DeploymentsServerTransport) dispatchNewListAtScopePager(req *http.Reque if err != nil { return nil, err } - var options *armresources.DeploymentsClientListAtScopeOptions + var options *deployments.ClientListAtScopeOptions if filterParam != nil || topParam != nil { - options = &armresources.DeploymentsClientListAtScopeOptions{ + options = &deployments.ClientListAtScopeOptions{ Filter: filterParam, Top: topParam, } } - resp := d.srv.NewListAtScopePager(scopeParam, options) + resp := s.srv.NewListAtScopePager(scopeParam, options) newListAtScopePager = &resp - d.newListAtScopePager.add(req, newListAtScopePager) - server.PagerResponderInjectNextLinks(newListAtScopePager, req, func(page *armresources.DeploymentsClientListAtScopeResponse, createLink func() string) { + s.newListAtScopePager.add(req, newListAtScopePager) + server.PagerResponderInjectNextLinks(newListAtScopePager, req, func(page *deployments.ClientListAtScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -1596,20 +1612,20 @@ func (d *DeploymentsServerTransport) dispatchNewListAtScopePager(req *http.Reque return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - d.newListAtScopePager.remove(req) + s.newListAtScopePager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListAtScopePager) { - d.newListAtScopePager.remove(req) + s.newListAtScopePager.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchNewListAtSubscriptionScopePager(req *http.Request) (*http.Response, error) { - if d.srv.NewListAtSubscriptionScopePager == nil { +func (s *ServerTransport) dispatchNewListAtSubscriptionScopePager(req *http.Request) (*http.Response, error) { + if s.srv.NewListAtSubscriptionScopePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListAtSubscriptionScopePager not implemented")} } - newListAtSubscriptionScopePager := d.newListAtSubscriptionScopePager.get(req) + newListAtSubscriptionScopePager := s.newListAtSubscriptionScopePager.get(req) if newListAtSubscriptionScopePager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/` regex := regexp.MustCompile(regexStr) @@ -1637,17 +1653,17 @@ func (d *DeploymentsServerTransport) dispatchNewListAtSubscriptionScopePager(req if err != nil { return nil, err } - var options *armresources.DeploymentsClientListAtSubscriptionScopeOptions + var options *deployments.ClientListAtSubscriptionScopeOptions if filterParam != nil || topParam != nil { - options = &armresources.DeploymentsClientListAtSubscriptionScopeOptions{ + options = &deployments.ClientListAtSubscriptionScopeOptions{ Filter: filterParam, Top: topParam, } } - resp := d.srv.NewListAtSubscriptionScopePager(options) + resp := s.srv.NewListAtSubscriptionScopePager(options) newListAtSubscriptionScopePager = &resp - d.newListAtSubscriptionScopePager.add(req, newListAtSubscriptionScopePager) - server.PagerResponderInjectNextLinks(newListAtSubscriptionScopePager, req, func(page *armresources.DeploymentsClientListAtSubscriptionScopeResponse, createLink func() string) { + s.newListAtSubscriptionScopePager.add(req, newListAtSubscriptionScopePager) + server.PagerResponderInjectNextLinks(newListAtSubscriptionScopePager, req, func(page *deployments.ClientListAtSubscriptionScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -1656,20 +1672,20 @@ func (d *DeploymentsServerTransport) dispatchNewListAtSubscriptionScopePager(req return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - d.newListAtSubscriptionScopePager.remove(req) + s.newListAtSubscriptionScopePager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListAtSubscriptionScopePager) { - d.newListAtSubscriptionScopePager.remove(req) + s.newListAtSubscriptionScopePager.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchNewListAtTenantScopePager(req *http.Request) (*http.Response, error) { - if d.srv.NewListAtTenantScopePager == nil { +func (s *ServerTransport) dispatchNewListAtTenantScopePager(req *http.Request) (*http.Response, error) { + if s.srv.NewListAtTenantScopePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListAtTenantScopePager not implemented")} } - newListAtTenantScopePager := d.newListAtTenantScopePager.get(req) + newListAtTenantScopePager := s.newListAtTenantScopePager.get(req) if newListAtTenantScopePager == nil { qp := req.URL.Query() filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) @@ -1691,17 +1707,17 @@ func (d *DeploymentsServerTransport) dispatchNewListAtTenantScopePager(req *http if err != nil { return nil, err } - var options *armresources.DeploymentsClientListAtTenantScopeOptions + var options *deployments.ClientListAtTenantScopeOptions if filterParam != nil || topParam != nil { - options = &armresources.DeploymentsClientListAtTenantScopeOptions{ + options = &deployments.ClientListAtTenantScopeOptions{ Filter: filterParam, Top: topParam, } } - resp := d.srv.NewListAtTenantScopePager(options) + resp := s.srv.NewListAtTenantScopePager(options) newListAtTenantScopePager = &resp - d.newListAtTenantScopePager.add(req, newListAtTenantScopePager) - server.PagerResponderInjectNextLinks(newListAtTenantScopePager, req, func(page *armresources.DeploymentsClientListAtTenantScopeResponse, createLink func() string) { + s.newListAtTenantScopePager.add(req, newListAtTenantScopePager) + server.PagerResponderInjectNextLinks(newListAtTenantScopePager, req, func(page *deployments.ClientListAtTenantScopeResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -1710,20 +1726,20 @@ func (d *DeploymentsServerTransport) dispatchNewListAtTenantScopePager(req *http return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - d.newListAtTenantScopePager.remove(req) + s.newListAtTenantScopePager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListAtTenantScopePager) { - d.newListAtTenantScopePager.remove(req) + s.newListAtTenantScopePager.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { - if d.srv.NewListByResourceGroupPager == nil { +func (s *ServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByResourceGroupPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} } - newListByResourceGroupPager := d.newListByResourceGroupPager.get(req) + newListByResourceGroupPager := s.newListByResourceGroupPager.get(req) if newListByResourceGroupPager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/` regex := regexp.MustCompile(regexStr) @@ -1755,17 +1771,17 @@ func (d *DeploymentsServerTransport) dispatchNewListByResourceGroupPager(req *ht if err != nil { return nil, err } - var options *armresources.DeploymentsClientListByResourceGroupOptions + var options *deployments.ClientListByResourceGroupOptions if filterParam != nil || topParam != nil { - options = &armresources.DeploymentsClientListByResourceGroupOptions{ + options = &deployments.ClientListByResourceGroupOptions{ Filter: filterParam, Top: topParam, } } - resp := d.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + resp := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) newListByResourceGroupPager = &resp - d.newListByResourceGroupPager.add(req, newListByResourceGroupPager) - server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armresources.DeploymentsClientListByResourceGroupResponse, createLink func() string) { + s.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *deployments.ClientListByResourceGroupResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -1774,20 +1790,20 @@ func (d *DeploymentsServerTransport) dispatchNewListByResourceGroupPager(req *ht return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - d.newListByResourceGroupPager.remove(req) + s.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListByResourceGroupPager) { - d.newListByResourceGroupPager.remove(req) + s.newListByResourceGroupPager.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginValidate(req *http.Request) (*http.Response, error) { - if d.srv.BeginValidate == nil { +func (s *ServerTransport) dispatchBeginValidate(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidate == nil { return nil, &nonRetriableError{errors.New("fake for method BeginValidate not implemented")} } - beginValidate := d.beginValidate.get(req) + beginValidate := s.beginValidate.get(req) if beginValidate == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` regex := regexp.MustCompile(regexStr) @@ -1795,7 +1811,7 @@ func (d *DeploymentsServerTransport) dispatchBeginValidate(req *http.Request) (* if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.Deployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.Deployment](req) if err != nil { return nil, err } @@ -1807,12 +1823,12 @@ func (d *DeploymentsServerTransport) dispatchBeginValidate(req *http.Request) (* if err != nil { return nil, err } - respr, errRespr := d.srv.BeginValidate(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginValidate(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginValidate = &respr - d.beginValidate.add(req, beginValidate) + s.beginValidate.add(req, beginValidate) } resp, err := server.PollerResponderNext(beginValidate, req) @@ -1821,21 +1837,21 @@ func (d *DeploymentsServerTransport) dispatchBeginValidate(req *http.Request) (* } if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { - d.beginValidate.remove(req) + s.beginValidate.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} } if !server.PollerResponderMore(beginValidate) { - d.beginValidate.remove(req) + s.beginValidate.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginValidateAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginValidateAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchBeginValidateAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidateAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginValidateAtManagementGroupScope not implemented")} } - beginValidateAtManagementGroupScope := d.beginValidateAtManagementGroupScope.get(req) + beginValidateAtManagementGroupScope := s.beginValidateAtManagementGroupScope.get(req) if beginValidateAtManagementGroupScope == nil { const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` regex := regexp.MustCompile(regexStr) @@ -1843,7 +1859,7 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtManagementGroupScope if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.ScopedDeployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.ScopedDeployment](req) if err != nil { return nil, err } @@ -1855,12 +1871,12 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtManagementGroupScope if err != nil { return nil, err } - respr, errRespr := d.srv.BeginValidateAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginValidateAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginValidateAtManagementGroupScope = &respr - d.beginValidateAtManagementGroupScope.add(req, beginValidateAtManagementGroupScope) + s.beginValidateAtManagementGroupScope.add(req, beginValidateAtManagementGroupScope) } resp, err := server.PollerResponderNext(beginValidateAtManagementGroupScope, req) @@ -1869,21 +1885,21 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtManagementGroupScope } if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { - d.beginValidateAtManagementGroupScope.remove(req) + s.beginValidateAtManagementGroupScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} } if !server.PollerResponderMore(beginValidateAtManagementGroupScope) { - d.beginValidateAtManagementGroupScope.remove(req) + s.beginValidateAtManagementGroupScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginValidateAtScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginValidateAtScope == nil { +func (s *ServerTransport) dispatchBeginValidateAtScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidateAtScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginValidateAtScope not implemented")} } - beginValidateAtScope := d.beginValidateAtScope.get(req) + beginValidateAtScope := s.beginValidateAtScope.get(req) if beginValidateAtScope == nil { const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` regex := regexp.MustCompile(regexStr) @@ -1891,7 +1907,7 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtScope(req *http.Requ if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.Deployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.Deployment](req) if err != nil { return nil, err } @@ -1903,12 +1919,12 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtScope(req *http.Requ if err != nil { return nil, err } - respr, errRespr := d.srv.BeginValidateAtScope(req.Context(), scopeParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginValidateAtScope(req.Context(), scopeParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginValidateAtScope = &respr - d.beginValidateAtScope.add(req, beginValidateAtScope) + s.beginValidateAtScope.add(req, beginValidateAtScope) } resp, err := server.PollerResponderNext(beginValidateAtScope, req) @@ -1917,21 +1933,21 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtScope(req *http.Requ } if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { - d.beginValidateAtScope.remove(req) + s.beginValidateAtScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} } if !server.PollerResponderMore(beginValidateAtScope) { - d.beginValidateAtScope.remove(req) + s.beginValidateAtScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginValidateAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginValidateAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchBeginValidateAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidateAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginValidateAtSubscriptionScope not implemented")} } - beginValidateAtSubscriptionScope := d.beginValidateAtSubscriptionScope.get(req) + beginValidateAtSubscriptionScope := s.beginValidateAtSubscriptionScope.get(req) if beginValidateAtSubscriptionScope == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` regex := regexp.MustCompile(regexStr) @@ -1939,7 +1955,7 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtSubscriptionScope(re if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.Deployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.Deployment](req) if err != nil { return nil, err } @@ -1947,12 +1963,12 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtSubscriptionScope(re if err != nil { return nil, err } - respr, errRespr := d.srv.BeginValidateAtSubscriptionScope(req.Context(), deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginValidateAtSubscriptionScope(req.Context(), deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginValidateAtSubscriptionScope = &respr - d.beginValidateAtSubscriptionScope.add(req, beginValidateAtSubscriptionScope) + s.beginValidateAtSubscriptionScope.add(req, beginValidateAtSubscriptionScope) } resp, err := server.PollerResponderNext(beginValidateAtSubscriptionScope, req) @@ -1961,21 +1977,21 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtSubscriptionScope(re } if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { - d.beginValidateAtSubscriptionScope.remove(req) + s.beginValidateAtSubscriptionScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} } if !server.PollerResponderMore(beginValidateAtSubscriptionScope) { - d.beginValidateAtSubscriptionScope.remove(req) + s.beginValidateAtSubscriptionScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginValidateAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginValidateAtTenantScope == nil { +func (s *ServerTransport) dispatchBeginValidateAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidateAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginValidateAtTenantScope not implemented")} } - beginValidateAtTenantScope := d.beginValidateAtTenantScope.get(req) + beginValidateAtTenantScope := s.beginValidateAtTenantScope.get(req) if beginValidateAtTenantScope == nil { const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` regex := regexp.MustCompile(regexStr) @@ -1983,7 +1999,7 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtTenantScope(req *htt if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.ScopedDeployment](req) + body, err := server.UnmarshalRequestAsJSON[deployments.ScopedDeployment](req) if err != nil { return nil, err } @@ -1991,12 +2007,12 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtTenantScope(req *htt if err != nil { return nil, err } - respr, errRespr := d.srv.BeginValidateAtTenantScope(req.Context(), deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginValidateAtTenantScope(req.Context(), deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginValidateAtTenantScope = &respr - d.beginValidateAtTenantScope.add(req, beginValidateAtTenantScope) + s.beginValidateAtTenantScope.add(req, beginValidateAtTenantScope) } resp, err := server.PollerResponderNext(beginValidateAtTenantScope, req) @@ -2005,21 +2021,21 @@ func (d *DeploymentsServerTransport) dispatchBeginValidateAtTenantScope(req *htt } if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { - d.beginValidateAtTenantScope.remove(req) + s.beginValidateAtTenantScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} } if !server.PollerResponderMore(beginValidateAtTenantScope) { - d.beginValidateAtTenantScope.remove(req) + s.beginValidateAtTenantScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginWhatIf(req *http.Request) (*http.Response, error) { - if d.srv.BeginWhatIf == nil { +func (s *ServerTransport) dispatchBeginWhatIf(req *http.Request) (*http.Response, error) { + if s.srv.BeginWhatIf == nil { return nil, &nonRetriableError{errors.New("fake for method BeginWhatIf not implemented")} } - beginWhatIf := d.beginWhatIf.get(req) + beginWhatIf := s.beginWhatIf.get(req) if beginWhatIf == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/whatIf` regex := regexp.MustCompile(regexStr) @@ -2027,7 +2043,7 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIf(req *http.Request) (*ht if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.DeploymentWhatIf](req) + body, err := server.UnmarshalRequestAsJSON[deployments.DeploymentWhatIf](req) if err != nil { return nil, err } @@ -2039,12 +2055,12 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIf(req *http.Request) (*ht if err != nil { return nil, err } - respr, errRespr := d.srv.BeginWhatIf(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginWhatIf(req.Context(), resourceGroupNameParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginWhatIf = &respr - d.beginWhatIf.add(req, beginWhatIf) + s.beginWhatIf.add(req, beginWhatIf) } resp, err := server.PollerResponderNext(beginWhatIf, req) @@ -2053,21 +2069,21 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIf(req *http.Request) (*ht } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - d.beginWhatIf.remove(req) + s.beginWhatIf.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginWhatIf) { - d.beginWhatIf.remove(req) + s.beginWhatIf.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtManagementGroupScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginWhatIfAtManagementGroupScope == nil { +func (s *ServerTransport) dispatchBeginWhatIfAtManagementGroupScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginWhatIfAtManagementGroupScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginWhatIfAtManagementGroupScope not implemented")} } - beginWhatIfAtManagementGroupScope := d.beginWhatIfAtManagementGroupScope.get(req) + beginWhatIfAtManagementGroupScope := s.beginWhatIfAtManagementGroupScope.get(req) if beginWhatIfAtManagementGroupScope == nil { const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/whatIf` regex := regexp.MustCompile(regexStr) @@ -2075,7 +2091,7 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtManagementGroupScope(r if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.ScopedDeploymentWhatIf](req) + body, err := server.UnmarshalRequestAsJSON[deployments.ScopedDeploymentWhatIf](req) if err != nil { return nil, err } @@ -2087,12 +2103,12 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtManagementGroupScope(r if err != nil { return nil, err } - respr, errRespr := d.srv.BeginWhatIfAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginWhatIfAtManagementGroupScope(req.Context(), groupIDParam, deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginWhatIfAtManagementGroupScope = &respr - d.beginWhatIfAtManagementGroupScope.add(req, beginWhatIfAtManagementGroupScope) + s.beginWhatIfAtManagementGroupScope.add(req, beginWhatIfAtManagementGroupScope) } resp, err := server.PollerResponderNext(beginWhatIfAtManagementGroupScope, req) @@ -2101,21 +2117,21 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtManagementGroupScope(r } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - d.beginWhatIfAtManagementGroupScope.remove(req) + s.beginWhatIfAtManagementGroupScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginWhatIfAtManagementGroupScope) { - d.beginWhatIfAtManagementGroupScope.remove(req) + s.beginWhatIfAtManagementGroupScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtSubscriptionScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginWhatIfAtSubscriptionScope == nil { +func (s *ServerTransport) dispatchBeginWhatIfAtSubscriptionScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginWhatIfAtSubscriptionScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginWhatIfAtSubscriptionScope not implemented")} } - beginWhatIfAtSubscriptionScope := d.beginWhatIfAtSubscriptionScope.get(req) + beginWhatIfAtSubscriptionScope := s.beginWhatIfAtSubscriptionScope.get(req) if beginWhatIfAtSubscriptionScope == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/whatIf` regex := regexp.MustCompile(regexStr) @@ -2123,7 +2139,7 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtSubscriptionScope(req if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.DeploymentWhatIf](req) + body, err := server.UnmarshalRequestAsJSON[deployments.DeploymentWhatIf](req) if err != nil { return nil, err } @@ -2131,12 +2147,12 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtSubscriptionScope(req if err != nil { return nil, err } - respr, errRespr := d.srv.BeginWhatIfAtSubscriptionScope(req.Context(), deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginWhatIfAtSubscriptionScope(req.Context(), deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginWhatIfAtSubscriptionScope = &respr - d.beginWhatIfAtSubscriptionScope.add(req, beginWhatIfAtSubscriptionScope) + s.beginWhatIfAtSubscriptionScope.add(req, beginWhatIfAtSubscriptionScope) } resp, err := server.PollerResponderNext(beginWhatIfAtSubscriptionScope, req) @@ -2145,21 +2161,21 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtSubscriptionScope(req } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - d.beginWhatIfAtSubscriptionScope.remove(req) + s.beginWhatIfAtSubscriptionScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginWhatIfAtSubscriptionScope) { - d.beginWhatIfAtSubscriptionScope.remove(req) + s.beginWhatIfAtSubscriptionScope.remove(req) } return resp, nil } -func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtTenantScope(req *http.Request) (*http.Response, error) { - if d.srv.BeginWhatIfAtTenantScope == nil { +func (s *ServerTransport) dispatchBeginWhatIfAtTenantScope(req *http.Request) (*http.Response, error) { + if s.srv.BeginWhatIfAtTenantScope == nil { return nil, &nonRetriableError{errors.New("fake for method BeginWhatIfAtTenantScope not implemented")} } - beginWhatIfAtTenantScope := d.beginWhatIfAtTenantScope.get(req) + beginWhatIfAtTenantScope := s.beginWhatIfAtTenantScope.get(req) if beginWhatIfAtTenantScope == nil { const regexStr = `/providers/Microsoft\.Resources/deployments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/whatIf` regex := regexp.MustCompile(regexStr) @@ -2167,7 +2183,7 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtTenantScope(req *http. if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armresources.ScopedDeploymentWhatIf](req) + body, err := server.UnmarshalRequestAsJSON[deployments.ScopedDeploymentWhatIf](req) if err != nil { return nil, err } @@ -2175,12 +2191,12 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtTenantScope(req *http. if err != nil { return nil, err } - respr, errRespr := d.srv.BeginWhatIfAtTenantScope(req.Context(), deploymentNameParam, body, nil) + respr, errRespr := s.srv.BeginWhatIfAtTenantScope(req.Context(), deploymentNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginWhatIfAtTenantScope = &respr - d.beginWhatIfAtTenantScope.add(req, beginWhatIfAtTenantScope) + s.beginWhatIfAtTenantScope.add(req, beginWhatIfAtTenantScope) } resp, err := server.PollerResponderNext(beginWhatIfAtTenantScope, req) @@ -2189,12 +2205,18 @@ func (d *DeploymentsServerTransport) dispatchBeginWhatIfAtTenantScope(req *http. } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - d.beginWhatIfAtTenantScope.remove(req) + s.beginWhatIfAtTenantScope.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginWhatIfAtTenantScope) { - d.beginWhatIfAtTenantScope.remove(req) + s.beginWhatIfAtTenantScope.remove(req) } return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/deployments/deployments/fake/server_factory.go b/sdk/resourcemanager/deployments/deployments/fake/server_factory.go new file mode 100644 index 000000000000..cd8ffe0692ef --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/fake/server_factory.go @@ -0,0 +1,82 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the deployments.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server + + // DeploymentOperationsServer contains the fakes for client DeploymentOperationsClient + DeploymentOperationsServer DeploymentOperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of deployments.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of deployments.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trDeploymentOperationsServer *DeploymentOperationsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "DeploymentOperationsClient": + initServer(s, &s.trDeploymentOperationsServer, func() *DeploymentOperationsServerTransport { + return NewDeploymentOperationsServerTransport(&s.srv.DeploymentOperationsServer) + }) + resp, err = s.trDeploymentOperationsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/deployments/deployments/go.mod b/sdk/resourcemanager/deployments/deployments/go.mod new file mode 100644 index 000000000000..b3394ea8d26c --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deployments + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/deployments/deployments/go.sum b/sdk/resourcemanager/deployments/deployments/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/deployments/deployments/models.go b/sdk/resourcemanager/deployments/deployments/models.go new file mode 100644 index 000000000000..dd1baf1c9a18 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/models.go @@ -0,0 +1,852 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deployments + +import "time" + +type APIProfile struct { + // READ-ONLY; The API version. + APIVersion *string + + // READ-ONLY; The profile version. + ProfileVersion *string +} + +// Alias - The alias type. +type Alias struct { + // The default path for an alias. + DefaultPath *string + + // The default pattern for an alias. + DefaultPattern *AliasPattern + + // The alias name. + Name *string + + // The paths for an alias. + Paths []*AliasPath + + // The type of the alias. + Type *AliasType + + // READ-ONLY; The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata + DefaultMetadata *AliasPathMetadata +} + +// AliasPath - The type of the paths for alias. +type AliasPath struct { + // The API versions. + APIVersions []*string + + // The path of an alias. + Path *string + + // The pattern for an alias path. + Pattern *AliasPattern + + // READ-ONLY; The metadata of the alias path. If missing, fall back to the default metadata of the alias. + Metadata *AliasPathMetadata +} + +type AliasPathMetadata struct { + // READ-ONLY; The attributes of the token that the alias path is referring to. + Attributes *AliasPathAttributes + + // READ-ONLY; The type of the token that the alias path is referring to. + Type *AliasPathTokenType +} + +// AliasPattern - The type of the pattern for an alias path. +type AliasPattern struct { + // The alias pattern phrase. + Phrase *string + + // The type of alias pattern + Type *AliasPatternType + + // The alias pattern variable. + Variable *string +} + +// BasicDependency - Deployment dependency information. +type BasicDependency struct { + // The ID of the dependency. + ID *string + + // The dependency resource name. + ResourceName *string + + // The dependency resource type. + ResourceType *string +} + +// DebugSetting - The debug setting. +type DebugSetting struct { + // Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, + // or both requestContent and responseContent separated by a comma. The default is + // none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging + // information about the request or response, you could potentially expose + // sensitive data that is retrieved through the deployment operations. + DetailLevel *string +} + +// Dependency - Deployment dependency information. +type Dependency struct { + // The list of dependencies. + DependsOn []*BasicDependency + + // The ID of the dependency. + ID *string + + // The dependency resource name. + ResourceName *string + + // The dependency resource type. + ResourceType *string +} + +// Deployment operation parameters. +type Deployment struct { + // REQUIRED; The deployment properties. + Properties *DeploymentProperties + + // The Managed Identity configuration for a deployment. + Identity *DeploymentIdentity + + // The location to store the deployment data. + Location *string + + // Deployment tags + Tags map[string]*string +} + +type DeploymentDiagnosticsDefinition struct { + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; Denotes the additional response level. + Level *Level + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error target. + Target *string +} + +// DeploymentExportResult - The deployment export result. +type DeploymentExportResult struct { + // The template content. + Template any +} + +// DeploymentExtended - Deployment information. +type DeploymentExtended struct { + // the location of the deployment. + Location *string + + // Deployment properties. + Properties *DeploymentPropertiesExtended + + // Deployment tags + Tags map[string]*string + + // READ-ONLY; The ID of the deployment. + ID *string + + // READ-ONLY; The name of the deployment. + Name *string + + // READ-ONLY; The type of the deployment. + Type *string +} + +// DeploymentExtendedFilter - Deployment filter. +type DeploymentExtendedFilter struct { + // The provisioning state. + ProvisioningState *string +} + +type DeploymentExtensionConfigItem struct { + // The Azure Key Vault reference used to retrieve the secret value of the extension config property. + KeyVaultReference *KeyVaultParameterReference + + // The value of the extension config property. + Value any + + // READ-ONLY; The value type of the extension config property. + Type *ExtensionConfigPropertyType +} + +type DeploymentExtensionDefinition struct { + // READ-ONLY; The alias of the extension as defined in the deployment template. + Alias *string + + // READ-ONLY; The extension configuration. + Config map[string]*DeploymentExtensionConfigItem + + // READ-ONLY; The extension configuration ID. It uniquely identifies a deployment control plane within an extension. + ConfigID *string + + // READ-ONLY; The extension name. + Name *string + + // READ-ONLY; The extension version. + Version *string +} + +// DeploymentExternalInput - Deployment external input for parameterization. +type DeploymentExternalInput struct { + // REQUIRED; External input value. + Value any +} + +// DeploymentExternalInputDefinition - Deployment external input definition for parameterization. +type DeploymentExternalInputDefinition struct { + // REQUIRED; The kind of external input. + Kind *string + + // Configuration for the external input. + Config any +} + +// DeploymentIdentity - The Managed Identity configuration for a deployment. +type DeploymentIdentity struct { + // REQUIRED; The identity type. + Type *DeploymentIdentityType + + // The set of user assigned identities associated with the resource. + UserAssignedIdentities map[string]*UserAssignedIdentity +} + +// DeploymentListResult - List of deployments. +type DeploymentListResult struct { + // An array of deployments. + Value []*DeploymentExtended + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} + +// DeploymentOperation - Deployment operation information. +type DeploymentOperation struct { + // Deployment properties. + Properties *DeploymentOperationProperties + + // READ-ONLY; Full deployment operation ID. + ID *string + + // READ-ONLY; Deployment operation ID. + OperationID *string +} + +// DeploymentOperationProperties - Deployment operation properties. +type DeploymentOperationProperties struct { + // READ-ONLY; The duration of the operation. + Duration *string + + // READ-ONLY; The name of the current provisioning operation. + ProvisioningOperation *ProvisioningOperation + + // READ-ONLY; The state of the provisioning. + ProvisioningState *string + + // READ-ONLY; The HTTP request message. + Request *HTTPMessage + + // READ-ONLY; The HTTP response message. + Response *HTTPMessage + + // READ-ONLY; Deployment operation service request id. + ServiceRequestID *string + + // READ-ONLY; Operation status code from the resource provider. This property may not be set if a response has not yet been + // received. + StatusCode *string + + // READ-ONLY; Operation status message from the resource provider. This property is optional. It will only be provided if + // an error was received from the resource provider. + StatusMessage *StatusMessage + + // READ-ONLY; The target resource. + TargetResource *TargetResource + + // READ-ONLY; The date and time of the operation. + Timestamp *time.Time +} + +// DeploymentOperationsListResult - List of deployment operations. +type DeploymentOperationsListResult struct { + // An array of deployment operations. + Value []*DeploymentOperation + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} + +// DeploymentParameter - Deployment parameter for the template. +type DeploymentParameter struct { + // Input expression to the parameter. + Expression *string + + // Azure Key Vault parameter reference. + Reference *KeyVaultParameterReference + + // Input value to the parameter . + Value any +} + +// DeploymentProperties - Deployment properties. +type DeploymentProperties struct { + // REQUIRED; The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, + // resources are deployed without deleting existing resources that are not included in + // the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included + // in the template are deleted. Be careful when using Complete mode as you may + // unintentionally delete resources. + Mode *DeploymentMode + + // The debug setting of the deployment. + DebugSetting *DebugSetting + + // Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable + // to nested templates. If not specified, default value is outer. + ExpressionEvaluationOptions *ExpressionEvaluationOptions + + // The configurations to use for deployment extensions. The keys of this object are deployment extension aliases as defined + // in the deployment template. + ExtensionConfigs map[string]map[string]*DeploymentExtensionConfigItem + + // External input definitions, used by external tooling to define expected external input values. + ExternalInputDefinitions map[string]*DeploymentExternalInputDefinition + + // External input values, used by external tooling for parameter evaluation. + ExternalInputs map[string]*DeploymentExternalInput + + // The deployment on error behavior. + OnErrorDeployment *OnErrorDeployment + + // Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide + // the parameter values directly in the request rather than link to an existing + // parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or + // a well formed JSON string. + Parameters map[string]*DeploymentParameter + + // The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink + // property or the parameters property, but not both. + ParametersLink *ParametersLink + + // The template content. You use this element when you want to pass the template syntax directly in the request rather than + // link to an existing template. It can be a JObject or well-formed JSON string. + // Use either the templateLink property or the template property, but not both. + Template any + + // The URI of the template. Use either the templateLink property or the template property, but not both. + TemplateLink *TemplateLink + + // The validation level of the deployment + ValidationLevel *ValidationLevel +} + +// DeploymentPropertiesExtended - Deployment properties with additional details. +type DeploymentPropertiesExtended struct { + // The validation level of the deployment + ValidationLevel *ValidationLevel + + // READ-ONLY; The correlation ID of the deployment. + CorrelationID *string + + // READ-ONLY; The debug setting of the deployment. + DebugSetting *DebugSetting + + // READ-ONLY; The list of deployment dependencies. + Dependencies []*Dependency + + // READ-ONLY; Contains diagnostic information collected during validation process. + Diagnostics []*DeploymentDiagnosticsDefinition + + // READ-ONLY; The duration of the template deployment. + Duration *string + + // READ-ONLY; The deployment error. + Error *ErrorResponse + + // READ-ONLY; The extensions used in this deployment. + Extensions []*DeploymentExtensionDefinition + + // READ-ONLY; The deployment mode. Possible values are Incremental and Complete. + Mode *DeploymentMode + + // READ-ONLY; The deployment on error behavior. + OnErrorDeployment *OnErrorDeploymentExtended + + // READ-ONLY; Array of provisioned resources. + OutputResources []*ResourceReference + + // READ-ONLY; Key/value pairs that represent deployment output. + Outputs any + + // READ-ONLY; Deployment parameters. + Parameters any + + // READ-ONLY; The URI referencing the parameters. + ParametersLink *ParametersLink + + // READ-ONLY; The list of resource providers needed for the deployment. + Providers []*Provider + + // READ-ONLY; Denotes the state of provisioning. + ProvisioningState *ProvisioningState + + // READ-ONLY; The hash produced for the template. + TemplateHash *string + + // READ-ONLY; The URI referencing the template. + TemplateLink *TemplateLink + + // READ-ONLY; The timestamp of the template deployment. + Timestamp *time.Time + + // READ-ONLY; Array of validated resources. + ValidatedResources []*ResourceReference +} + +// DeploymentValidateResult - Information from validate template deployment response. +type DeploymentValidateResult struct { + // The template deployment properties. + Properties *DeploymentPropertiesExtended + + // READ-ONLY; The deployment validation error. + Error *ErrorResponse + + // READ-ONLY; The ID of the deployment. + ID *string + + // READ-ONLY; The name of the deployment. + Name *string + + // READ-ONLY; The type of the deployment. + Type *string +} + +// DeploymentWhatIf - Deployment What-if operation parameters. +type DeploymentWhatIf struct { + // REQUIRED; The deployment properties. + Properties *DeploymentWhatIfProperties + + // The location to store the deployment data. + Location *string +} + +// DeploymentWhatIfProperties - Deployment What-if properties. +type DeploymentWhatIfProperties struct { + // REQUIRED; The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, + // resources are deployed without deleting existing resources that are not included in + // the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included + // in the template are deleted. Be careful when using Complete mode as you may + // unintentionally delete resources. + Mode *DeploymentMode + + // The debug setting of the deployment. + DebugSetting *DebugSetting + + // Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable + // to nested templates. If not specified, default value is outer. + ExpressionEvaluationOptions *ExpressionEvaluationOptions + + // The configurations to use for deployment extensions. The keys of this object are deployment extension aliases as defined + // in the deployment template. + ExtensionConfigs map[string]map[string]*DeploymentExtensionConfigItem + + // External input definitions, used by external tooling to define expected external input values. + ExternalInputDefinitions map[string]*DeploymentExternalInputDefinition + + // External input values, used by external tooling for parameter evaluation. + ExternalInputs map[string]*DeploymentExternalInput + + // The deployment on error behavior. + OnErrorDeployment *OnErrorDeployment + + // Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide + // the parameter values directly in the request rather than link to an existing + // parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or + // a well formed JSON string. + Parameters map[string]*DeploymentParameter + + // The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink + // property or the parameters property, but not both. + ParametersLink *ParametersLink + + // The template content. You use this element when you want to pass the template syntax directly in the request rather than + // link to an existing template. It can be a JObject or well-formed JSON string. + // Use either the templateLink property or the template property, but not both. + Template any + + // The URI of the template. Use either the templateLink property or the template property, but not both. + TemplateLink *TemplateLink + + // The validation level of the deployment + ValidationLevel *ValidationLevel + + // Optional What-If operation settings. + WhatIfSettings *DeploymentWhatIfSettings +} + +// DeploymentWhatIfSettings - Deployment What-If operation settings. +type DeploymentWhatIfSettings struct { + // The format of the What-If results + ResultFormat *WhatIfResultFormat +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.) +type ErrorResponse struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorResponse + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// ExpressionEvaluationOptions - Specifies whether template expressions are evaluated within the scope of the parent template +// or nested template. +type ExpressionEvaluationOptions struct { + // The scope to be used for evaluation of parameters, variables and functions in a nested template. + Scope *ExpressionEvaluationOptionsScopeType +} + +// HTTPMessage - HTTP message. +type HTTPMessage struct { + // HTTP message content. + Content any +} + +// KeyVaultParameterReference - Azure Key Vault parameter reference. +type KeyVaultParameterReference struct { + // REQUIRED; Azure Key Vault reference. + KeyVault *KeyVaultReference + + // REQUIRED; Azure Key Vault secret name. + SecretName *string + + // Azure Key Vault secret version. + SecretVersion *string +} + +// KeyVaultReference - Azure Key Vault reference. +type KeyVaultReference struct { + // REQUIRED; Azure Key Vault resource id. + ID *string +} + +// OnErrorDeployment - Deployment on error behavior. +type OnErrorDeployment struct { + // The deployment to be used on error case. + DeploymentName *string + + // The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. + Type *OnErrorDeploymentType +} + +// OnErrorDeploymentExtended - Deployment on error behavior with additional details. +type OnErrorDeploymentExtended struct { + // The deployment to be used on error case. + DeploymentName *string + + // The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. + Type *OnErrorDeploymentType + + // READ-ONLY; The state of the provisioning for the on error deployment. + ProvisioningState *string +} + +// ParametersLink - Entity representing the reference to the deployment parameters. +type ParametersLink struct { + // REQUIRED; The URI of the parameters file. + URI *string + + // If included, must match the ContentVersion in the template. + ContentVersion *string +} + +// Provider - Resource provider information. +type Provider struct { + // The namespace of the resource provider. + Namespace *string + + // The provider authorization consent state. + ProviderAuthorizationConsentState *ProviderAuthorizationConsentState + + // READ-ONLY; The provider ID. + ID *string + + // READ-ONLY; The registration policy of the resource provider. + RegistrationPolicy *string + + // READ-ONLY; The registration state of the resource provider. + RegistrationState *string + + // READ-ONLY; The collection of provider resource types. + ResourceTypes []*ProviderResourceType +} + +// ProviderExtendedLocation - The provider extended location. +type ProviderExtendedLocation struct { + // The extended locations for the azure location. + ExtendedLocations []*string + + // The azure location. + Location *string + + // The extended location type. + Type *string +} + +// ProviderResourceType - Resource type managed by the resource provider. +type ProviderResourceType struct { + // The API version. + APIVersions []*string + + // The aliases that are supported by this resource type. + Aliases []*Alias + + // The additional capabilities offered by this resource type. + Capabilities *string + + // The location mappings that are supported by this resource type. + LocationMappings []*ProviderExtendedLocation + + // The collection of locations where this resource type can be created. + Locations []*string + + // The properties. + Properties map[string]*string + + // The resource type. + ResourceType *string + ZoneMappings []*ZoneMapping + + // READ-ONLY; The API profiles for the resource provider. + APIProfiles []*APIProfile + + // READ-ONLY; The default API version. + DefaultAPIVersion *string +} + +// ResourceReference - The resource Id model. +type ResourceReference struct { + // READ-ONLY; The API version the resource was deployed with. + APIVersion *string + + // READ-ONLY; The extension the resource was deployed with. + Extension *DeploymentExtensionDefinition + + // READ-ONLY; The fully qualified Azure resource ID. + ID *string + + // READ-ONLY; The extensible resource identifiers. + Identifiers any + + // READ-ONLY; The resource type. + ResourceType *string +} + +// ScopedDeployment - Deployment operation parameters. +type ScopedDeployment struct { + // REQUIRED; The location to store the deployment data. + Location *string + + // REQUIRED; The deployment properties. + Properties *DeploymentProperties + + // Deployment tags + Tags map[string]*string +} + +// ScopedDeploymentWhatIf - Deployment What-if operation parameters. +type ScopedDeploymentWhatIf struct { + // REQUIRED; The location to store the deployment data. + Location *string + + // REQUIRED; The deployment properties. + Properties *DeploymentWhatIfProperties +} + +// StatusMessage - Operation status message object. +type StatusMessage struct { + // The error reported by the operation. + Error *ErrorResponse + + // Status of the deployment operation. + Status *string +} + +// TargetResource - Target resource. +type TargetResource struct { + // The API version the resource was deployed with. + APIVersion *string + + // The extension the resource was deployed with. + Extension *DeploymentExtensionDefinition + + // The Azure resource ID of the resource. + ID *string + + // The extensible resource identifiers. + Identifiers any + + // The name of the resource. + ResourceName *string + + // The type of the resource. + ResourceType *string + + // The symbolic name of the resource as defined in the deployment template. + SymbolicName *string +} + +// TemplateHashResult - Result of the request to calculate template hash. It contains a string of minified template and its +// hash. +type TemplateHashResult struct { + // The minified template string. + MinifiedTemplate *string + + // The template hash. + TemplateHash *string +} + +// TemplateLink - Entity representing the reference to the template. +type TemplateLink struct { + // If included, must match the ContentVersion in the template. + ContentVersion *string + + // The resource id of a Template Spec. Use either the id or uri property, but not both. + ID *string + + // The query string (for example, a SAS token) to be used with the templateLink URI. + QueryString *string + + // The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template + // was linked with a TemplateSpec, this will reference an artifact in the + // TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath + // URIs + RelativePath *string + + // The URI of the template to deploy. Use either the uri or id property, but not both. + URI *string +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string +} + +// WhatIfChange - Information about a single resource change predicted by What-If operation. +type WhatIfChange struct { + // REQUIRED; Type of change that will be made to the resource when the deployment is executed. + ChangeType *ChangeType + + // The predicted snapshot of the resource after the deployment is executed. + After any + + // The snapshot of the resource before the deployment is executed. + Before any + + // The predicted changes to resource properties. + Delta []*WhatIfPropertyChange + + // The resource id of the Deployment responsible for this change. + DeploymentID *string + + // The extension the resource was deployed with. + Extension *DeploymentExtensionDefinition + + // A subset of properties that uniquely identify a Bicep extensible resource because it lacks a resource id like an Azure + // resource has. + Identifiers any + + // Resource ID + ResourceID *string + + // The symbolic name of the resource responsible for this change. + SymbolicName *string + + // The explanation about why the resource is unsupported by What-If. + UnsupportedReason *string +} + +// WhatIfOperationProperties - Deployment operation properties. +type WhatIfOperationProperties struct { + // List of resource changes predicted by What-If operation. + Changes []*WhatIfChange + + // List of resource changes predicted by What-If operation. + PotentialChanges []*WhatIfChange + + // READ-ONLY; List of resource diagnostics detected by What-If operation. + Diagnostics []*DeploymentDiagnosticsDefinition +} + +// WhatIfOperationResult - Result of the What-If operation. Contains a list of predicted changes and a URL link to get to +// the next set of results. +type WhatIfOperationResult struct { + // Error when What-If operation fails. + Error *ErrorResponse + + // What-If operation properties. + Properties *WhatIfOperationProperties + + // Status of the What-If operation. + Status *string +} + +// WhatIfPropertyChange - The predicted change to the resource property. +type WhatIfPropertyChange struct { + // REQUIRED; The path of the property. + Path *string + + // REQUIRED; The type of property change. + PropertyChangeType *PropertyChangeType + + // The value of the property after the deployment is executed. + After any + + // The value of the property before the deployment is executed. + Before any + + // Nested property changes. + Children []*WhatIfPropertyChange +} + +type ZoneMapping struct { + // The location of the zone mapping. + Location *string + Zones []*string +} diff --git a/sdk/resourcemanager/deployments/deployments/models_serde.go b/sdk/resourcemanager/deployments/deployments/models_serde.go new file mode 100644 index 000000000000..591368a8ebc4 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/models_serde.go @@ -0,0 +1,2157 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deployments + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type APIProfile. +func (a APIProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", a.APIVersion) + populate(objectMap, "profileVersion", a.ProfileVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIProfile. +func (a *APIProfile) 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 "apiVersion": + err = unpopulate(val, "APIVersion", &a.APIVersion) + delete(rawMsg, key) + case "profileVersion": + err = unpopulate(val, "ProfileVersion", &a.ProfileVersion) + 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 Alias. +func (a Alias) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "defaultMetadata", a.DefaultMetadata) + populate(objectMap, "defaultPath", a.DefaultPath) + populate(objectMap, "defaultPattern", a.DefaultPattern) + populate(objectMap, "name", a.Name) + populate(objectMap, "paths", a.Paths) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Alias. +func (a *Alias) 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 "defaultMetadata": + err = unpopulate(val, "DefaultMetadata", &a.DefaultMetadata) + delete(rawMsg, key) + case "defaultPath": + err = unpopulate(val, "DefaultPath", &a.DefaultPath) + delete(rawMsg, key) + case "defaultPattern": + err = unpopulate(val, "DefaultPattern", &a.DefaultPattern) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "paths": + err = unpopulate(val, "Paths", &a.Paths) + 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 AliasPath. +func (a AliasPath) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersions", a.APIVersions) + populate(objectMap, "metadata", a.Metadata) + populate(objectMap, "path", a.Path) + populate(objectMap, "pattern", a.Pattern) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPath. +func (a *AliasPath) 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 "apiVersions": + err = unpopulate(val, "APIVersions", &a.APIVersions) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &a.Metadata) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &a.Path) + delete(rawMsg, key) + case "pattern": + err = unpopulate(val, "Pattern", &a.Pattern) + 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 AliasPathMetadata. +func (a AliasPathMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attributes", a.Attributes) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPathMetadata. +func (a *AliasPathMetadata) 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 "attributes": + err = unpopulate(val, "Attributes", &a.Attributes) + 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 AliasPattern. +func (a AliasPattern) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "phrase", a.Phrase) + populate(objectMap, "type", a.Type) + populate(objectMap, "variable", a.Variable) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPattern. +func (a *AliasPattern) 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 "phrase": + err = unpopulate(val, "Phrase", &a.Phrase) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + case "variable": + err = unpopulate(val, "Variable", &a.Variable) + 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 BasicDependency. +func (b BasicDependency) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", b.ID) + populate(objectMap, "resourceName", b.ResourceName) + populate(objectMap, "resourceType", b.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BasicDependency. +func (b *BasicDependency) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "resourceName": + err = unpopulate(val, "ResourceName", &b.ResourceName) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &b.ResourceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DebugSetting. +func (d DebugSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "detailLevel", d.DetailLevel) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DebugSetting. +func (d *DebugSetting) 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 "detailLevel": + err = unpopulate(val, "DetailLevel", &d.DetailLevel) + 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 Dependency. +func (d Dependency) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dependsOn", d.DependsOn) + populate(objectMap, "id", d.ID) + populate(objectMap, "resourceName", d.ResourceName) + populate(objectMap, "resourceType", d.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Dependency. +func (d *Dependency) 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 "dependsOn": + err = unpopulate(val, "DependsOn", &d.DependsOn) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "resourceName": + err = unpopulate(val, "ResourceName", &d.ResourceName) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &d.ResourceType) + 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 Deployment. +func (d Deployment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "location", d.Location) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Deployment. +func (d *Deployment) 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 "identity": + err = unpopulate(val, "Identity", &d.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + 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 DeploymentDiagnosticsDefinition. +func (d DeploymentDiagnosticsDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", d.AdditionalInfo) + populate(objectMap, "code", d.Code) + populate(objectMap, "level", d.Level) + populate(objectMap, "message", d.Message) + populate(objectMap, "target", d.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentDiagnosticsDefinition. +func (d *DeploymentDiagnosticsDefinition) 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 "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &d.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &d.Code) + delete(rawMsg, key) + case "level": + err = unpopulate(val, "Level", &d.Level) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &d.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &d.Target) + 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 DeploymentExportResult. +func (d DeploymentExportResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "template", d.Template) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExportResult. +func (d *DeploymentExportResult) 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 "template": + err = unpopulate(val, "Template", &d.Template) + 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 DeploymentExtended. +func (d DeploymentExtended) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExtended. +func (d *DeploymentExtended) 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 "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + 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 DeploymentExtendedFilter. +func (d DeploymentExtendedFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", d.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExtendedFilter. +func (d *DeploymentExtendedFilter) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + 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 DeploymentExtensionConfigItem. +func (d DeploymentExtensionConfigItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyVaultReference", d.KeyVaultReference) + populate(objectMap, "type", d.Type) + populateAny(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExtensionConfigItem. +func (d *DeploymentExtensionConfigItem) 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 "keyVaultReference": + err = unpopulate(val, "KeyVaultReference", &d.KeyVaultReference) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + 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 DeploymentExtensionDefinition. +func (d DeploymentExtensionDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "alias", d.Alias) + populate(objectMap, "config", d.Config) + populate(objectMap, "configId", d.ConfigID) + populate(objectMap, "name", d.Name) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExtensionDefinition. +func (d *DeploymentExtensionDefinition) 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 "alias": + err = unpopulate(val, "Alias", &d.Alias) + delete(rawMsg, key) + case "config": + err = unpopulate(val, "Config", &d.Config) + delete(rawMsg, key) + case "configId": + err = unpopulate(val, "ConfigID", &d.ConfigID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + 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 DeploymentExternalInput. +func (d DeploymentExternalInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExternalInput. +func (d *DeploymentExternalInput) 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 "value": + err = unpopulate(val, "Value", &d.Value) + 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 DeploymentExternalInputDefinition. +func (d DeploymentExternalInputDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "config", d.Config) + populate(objectMap, "kind", d.Kind) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExternalInputDefinition. +func (d *DeploymentExternalInputDefinition) 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 "config": + err = unpopulate(val, "Config", &d.Config) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &d.Kind) + 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 DeploymentIdentity. +func (d DeploymentIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "type", d.Type) + populate(objectMap, "userAssignedIdentities", d.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentIdentity. +func (d *DeploymentIdentity) 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 "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &d.UserAssignedIdentities) + 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 DeploymentListResult. +func (d DeploymentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentListResult. +func (d *DeploymentListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + 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 DeploymentOperation. +func (d DeploymentOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "operationId", d.OperationID) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentOperation. +func (d *DeploymentOperation) 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 "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &d.OperationID) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + 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 DeploymentOperationProperties. +func (d DeploymentOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "duration", d.Duration) + populate(objectMap, "provisioningOperation", d.ProvisioningOperation) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "request", d.Request) + populate(objectMap, "response", d.Response) + populate(objectMap, "serviceRequestId", d.ServiceRequestID) + populate(objectMap, "statusCode", d.StatusCode) + populate(objectMap, "statusMessage", d.StatusMessage) + populate(objectMap, "targetResource", d.TargetResource) + populateDateTimeRFC3339(objectMap, "timestamp", d.Timestamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentOperationProperties. +func (d *DeploymentOperationProperties) 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 "duration": + err = unpopulate(val, "Duration", &d.Duration) + delete(rawMsg, key) + case "provisioningOperation": + err = unpopulate(val, "ProvisioningOperation", &d.ProvisioningOperation) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "request": + err = unpopulate(val, "Request", &d.Request) + delete(rawMsg, key) + case "response": + err = unpopulate(val, "Response", &d.Response) + delete(rawMsg, key) + case "serviceRequestId": + err = unpopulate(val, "ServiceRequestID", &d.ServiceRequestID) + delete(rawMsg, key) + case "statusCode": + err = unpopulate(val, "StatusCode", &d.StatusCode) + delete(rawMsg, key) + case "statusMessage": + err = unpopulate(val, "StatusMessage", &d.StatusMessage) + delete(rawMsg, key) + case "targetResource": + err = unpopulate(val, "TargetResource", &d.TargetResource) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &d.Timestamp) + 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 DeploymentOperationsListResult. +func (d DeploymentOperationsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentOperationsListResult. +func (d *DeploymentOperationsListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + 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 DeploymentParameter. +func (d DeploymentParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expression", d.Expression) + populate(objectMap, "reference", d.Reference) + populateAny(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentParameter. +func (d *DeploymentParameter) 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 "expression": + err = unpopulate(val, "Expression", &d.Expression) + delete(rawMsg, key) + case "reference": + err = unpopulate(val, "Reference", &d.Reference) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + 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 DeploymentProperties. +func (d DeploymentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "debugSetting", d.DebugSetting) + populate(objectMap, "expressionEvaluationOptions", d.ExpressionEvaluationOptions) + populate(objectMap, "extensionConfigs", d.ExtensionConfigs) + populate(objectMap, "externalInputDefinitions", d.ExternalInputDefinitions) + populate(objectMap, "externalInputs", d.ExternalInputs) + populate(objectMap, "mode", d.Mode) + populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "parametersLink", d.ParametersLink) + populateAny(objectMap, "template", d.Template) + populate(objectMap, "templateLink", d.TemplateLink) + populate(objectMap, "validationLevel", d.ValidationLevel) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentProperties. +func (d *DeploymentProperties) 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 "debugSetting": + err = unpopulate(val, "DebugSetting", &d.DebugSetting) + delete(rawMsg, key) + case "expressionEvaluationOptions": + err = unpopulate(val, "ExpressionEvaluationOptions", &d.ExpressionEvaluationOptions) + delete(rawMsg, key) + case "extensionConfigs": + err = unpopulate(val, "ExtensionConfigs", &d.ExtensionConfigs) + delete(rawMsg, key) + case "externalInputDefinitions": + err = unpopulate(val, "ExternalInputDefinitions", &d.ExternalInputDefinitions) + delete(rawMsg, key) + case "externalInputs": + err = unpopulate(val, "ExternalInputs", &d.ExternalInputs) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &d.Mode) + delete(rawMsg, key) + case "onErrorDeployment": + err = unpopulate(val, "OnErrorDeployment", &d.OnErrorDeployment) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "parametersLink": + err = unpopulate(val, "ParametersLink", &d.ParametersLink) + delete(rawMsg, key) + case "template": + err = unpopulate(val, "Template", &d.Template) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + delete(rawMsg, key) + case "validationLevel": + err = unpopulate(val, "ValidationLevel", &d.ValidationLevel) + 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 DeploymentPropertiesExtended. +func (d DeploymentPropertiesExtended) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationId", d.CorrelationID) + populate(objectMap, "debugSetting", d.DebugSetting) + populate(objectMap, "dependencies", d.Dependencies) + populate(objectMap, "diagnostics", d.Diagnostics) + populate(objectMap, "duration", d.Duration) + populate(objectMap, "error", d.Error) + populate(objectMap, "extensions", d.Extensions) + populate(objectMap, "mode", d.Mode) + populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) + populate(objectMap, "outputResources", d.OutputResources) + populateAny(objectMap, "outputs", d.Outputs) + populateAny(objectMap, "parameters", d.Parameters) + populate(objectMap, "parametersLink", d.ParametersLink) + populate(objectMap, "providers", d.Providers) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "templateHash", d.TemplateHash) + populate(objectMap, "templateLink", d.TemplateLink) + populateDateTimeRFC3339(objectMap, "timestamp", d.Timestamp) + populate(objectMap, "validatedResources", d.ValidatedResources) + populate(objectMap, "validationLevel", d.ValidationLevel) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentPropertiesExtended. +func (d *DeploymentPropertiesExtended) 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 "correlationId": + err = unpopulate(val, "CorrelationID", &d.CorrelationID) + delete(rawMsg, key) + case "debugSetting": + err = unpopulate(val, "DebugSetting", &d.DebugSetting) + delete(rawMsg, key) + case "dependencies": + err = unpopulate(val, "Dependencies", &d.Dependencies) + delete(rawMsg, key) + case "diagnostics": + err = unpopulate(val, "Diagnostics", &d.Diagnostics) + delete(rawMsg, key) + case "duration": + err = unpopulate(val, "Duration", &d.Duration) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &d.Error) + delete(rawMsg, key) + case "extensions": + err = unpopulate(val, "Extensions", &d.Extensions) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &d.Mode) + delete(rawMsg, key) + case "onErrorDeployment": + err = unpopulate(val, "OnErrorDeployment", &d.OnErrorDeployment) + delete(rawMsg, key) + case "outputResources": + err = unpopulate(val, "OutputResources", &d.OutputResources) + delete(rawMsg, key) + case "outputs": + err = unpopulate(val, "Outputs", &d.Outputs) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "parametersLink": + err = unpopulate(val, "ParametersLink", &d.ParametersLink) + delete(rawMsg, key) + case "providers": + err = unpopulate(val, "Providers", &d.Providers) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "templateHash": + err = unpopulate(val, "TemplateHash", &d.TemplateHash) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + delete(rawMsg, key) + case "timestamp": + err = unpopulateDateTimeRFC3339(val, "Timestamp", &d.Timestamp) + delete(rawMsg, key) + case "validatedResources": + err = unpopulate(val, "ValidatedResources", &d.ValidatedResources) + delete(rawMsg, key) + case "validationLevel": + err = unpopulate(val, "ValidationLevel", &d.ValidationLevel) + 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 DeploymentValidateResult. +func (d DeploymentValidateResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", d.Error) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentValidateResult. +func (d *DeploymentValidateResult) 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 "error": + err = unpopulate(val, "Error", &d.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + 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 DeploymentWhatIf. +func (d DeploymentWhatIf) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", d.Location) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWhatIf. +func (d *DeploymentWhatIf) 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 "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + 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 DeploymentWhatIfProperties. +func (d DeploymentWhatIfProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "debugSetting", d.DebugSetting) + populate(objectMap, "expressionEvaluationOptions", d.ExpressionEvaluationOptions) + populate(objectMap, "extensionConfigs", d.ExtensionConfigs) + populate(objectMap, "externalInputDefinitions", d.ExternalInputDefinitions) + populate(objectMap, "externalInputs", d.ExternalInputs) + populate(objectMap, "mode", d.Mode) + populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "parametersLink", d.ParametersLink) + populateAny(objectMap, "template", d.Template) + populate(objectMap, "templateLink", d.TemplateLink) + populate(objectMap, "validationLevel", d.ValidationLevel) + populate(objectMap, "whatIfSettings", d.WhatIfSettings) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWhatIfProperties. +func (d *DeploymentWhatIfProperties) 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 "debugSetting": + err = unpopulate(val, "DebugSetting", &d.DebugSetting) + delete(rawMsg, key) + case "expressionEvaluationOptions": + err = unpopulate(val, "ExpressionEvaluationOptions", &d.ExpressionEvaluationOptions) + delete(rawMsg, key) + case "extensionConfigs": + err = unpopulate(val, "ExtensionConfigs", &d.ExtensionConfigs) + delete(rawMsg, key) + case "externalInputDefinitions": + err = unpopulate(val, "ExternalInputDefinitions", &d.ExternalInputDefinitions) + delete(rawMsg, key) + case "externalInputs": + err = unpopulate(val, "ExternalInputs", &d.ExternalInputs) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &d.Mode) + delete(rawMsg, key) + case "onErrorDeployment": + err = unpopulate(val, "OnErrorDeployment", &d.OnErrorDeployment) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "parametersLink": + err = unpopulate(val, "ParametersLink", &d.ParametersLink) + delete(rawMsg, key) + case "template": + err = unpopulate(val, "Template", &d.Template) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + delete(rawMsg, key) + case "validationLevel": + err = unpopulate(val, "ValidationLevel", &d.ValidationLevel) + delete(rawMsg, key) + case "whatIfSettings": + err = unpopulate(val, "WhatIfSettings", &d.WhatIfSettings) + 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 DeploymentWhatIfSettings. +func (d DeploymentWhatIfSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resultFormat", d.ResultFormat) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWhatIfSettings. +func (d *DeploymentWhatIfSettings) 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 "resultFormat": + err = unpopulate(val, "ResultFormat", &d.ResultFormat) + 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) + populateAny(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 ErrorResponse. +func (e ErrorResponse) 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 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 "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 ExpressionEvaluationOptions. +func (e ExpressionEvaluationOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scope", e.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExpressionEvaluationOptions. +func (e *ExpressionEvaluationOptions) 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 "scope": + err = unpopulate(val, "Scope", &e.Scope) + 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 HTTPMessage. +func (h HTTPMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "content", h.Content) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPMessage. +func (h *HTTPMessage) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content": + err = unpopulate(val, "Content", &h.Content) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultParameterReference. +func (k KeyVaultParameterReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyVault", k.KeyVault) + populate(objectMap, "secretName", k.SecretName) + populate(objectMap, "secretVersion", k.SecretVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultParameterReference. +func (k *KeyVaultParameterReference) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyVault": + err = unpopulate(val, "KeyVault", &k.KeyVault) + delete(rawMsg, key) + case "secretName": + err = unpopulate(val, "SecretName", &k.SecretName) + delete(rawMsg, key) + case "secretVersion": + err = unpopulate(val, "SecretVersion", &k.SecretVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultReference. +func (k KeyVaultReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", k.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultReference. +func (k *KeyVaultReference) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OnErrorDeployment. +func (o OnErrorDeployment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deploymentName", o.DeploymentName) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OnErrorDeployment. +func (o *OnErrorDeployment) 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 "deploymentName": + err = unpopulate(val, "DeploymentName", &o.DeploymentName) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + 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 OnErrorDeploymentExtended. +func (o OnErrorDeploymentExtended) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deploymentName", o.DeploymentName) + populate(objectMap, "provisioningState", o.ProvisioningState) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OnErrorDeploymentExtended. +func (o *OnErrorDeploymentExtended) 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 "deploymentName": + err = unpopulate(val, "DeploymentName", &o.DeploymentName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + 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 ParametersLink. +func (p ParametersLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentVersion", p.ContentVersion) + populate(objectMap, "uri", p.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParametersLink. +func (p *ParametersLink) 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 "contentVersion": + err = unpopulate(val, "ContentVersion", &p.ContentVersion) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &p.URI) + 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 Provider. +func (p Provider) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "namespace", p.Namespace) + populate(objectMap, "providerAuthorizationConsentState", p.ProviderAuthorizationConsentState) + populate(objectMap, "registrationPolicy", p.RegistrationPolicy) + populate(objectMap, "registrationState", p.RegistrationState) + populate(objectMap, "resourceTypes", p.ResourceTypes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Provider. +func (p *Provider) 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 "namespace": + err = unpopulate(val, "Namespace", &p.Namespace) + delete(rawMsg, key) + case "providerAuthorizationConsentState": + err = unpopulate(val, "ProviderAuthorizationConsentState", &p.ProviderAuthorizationConsentState) + delete(rawMsg, key) + case "registrationPolicy": + err = unpopulate(val, "RegistrationPolicy", &p.RegistrationPolicy) + delete(rawMsg, key) + case "registrationState": + err = unpopulate(val, "RegistrationState", &p.RegistrationState) + delete(rawMsg, key) + case "resourceTypes": + err = unpopulate(val, "ResourceTypes", &p.ResourceTypes) + 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 ProviderExtendedLocation. +func (p ProviderExtendedLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "extendedLocations", p.ExtendedLocations) + populate(objectMap, "location", p.Location) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProviderExtendedLocation. +func (p *ProviderExtendedLocation) 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 "extendedLocations": + err = unpopulate(val, "ExtendedLocations", &p.ExtendedLocations) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + 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 ProviderResourceType. +func (p ProviderResourceType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiProfiles", p.APIProfiles) + populate(objectMap, "apiVersions", p.APIVersions) + populate(objectMap, "aliases", p.Aliases) + populate(objectMap, "capabilities", p.Capabilities) + populate(objectMap, "defaultApiVersion", p.DefaultAPIVersion) + populate(objectMap, "locationMappings", p.LocationMappings) + populate(objectMap, "locations", p.Locations) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "resourceType", p.ResourceType) + populate(objectMap, "zoneMappings", p.ZoneMappings) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProviderResourceType. +func (p *ProviderResourceType) 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 "apiProfiles": + err = unpopulate(val, "APIProfiles", &p.APIProfiles) + delete(rawMsg, key) + case "apiVersions": + err = unpopulate(val, "APIVersions", &p.APIVersions) + delete(rawMsg, key) + case "aliases": + err = unpopulate(val, "Aliases", &p.Aliases) + delete(rawMsg, key) + case "capabilities": + err = unpopulate(val, "Capabilities", &p.Capabilities) + delete(rawMsg, key) + case "defaultApiVersion": + err = unpopulate(val, "DefaultAPIVersion", &p.DefaultAPIVersion) + delete(rawMsg, key) + case "locationMappings": + err = unpopulate(val, "LocationMappings", &p.LocationMappings) + delete(rawMsg, key) + case "locations": + err = unpopulate(val, "Locations", &p.Locations) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &p.ResourceType) + delete(rawMsg, key) + case "zoneMappings": + err = unpopulate(val, "ZoneMappings", &p.ZoneMappings) + 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 ResourceReference. +func (r ResourceReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", r.APIVersion) + populate(objectMap, "extension", r.Extension) + populate(objectMap, "id", r.ID) + populateAny(objectMap, "identifiers", r.Identifiers) + populate(objectMap, "resourceType", r.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReference. +func (r *ResourceReference) 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 "apiVersion": + err = unpopulate(val, "APIVersion", &r.APIVersion) + delete(rawMsg, key) + case "extension": + err = unpopulate(val, "Extension", &r.Extension) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "identifiers": + err = unpopulate(val, "Identifiers", &r.Identifiers) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) + 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 ScopedDeployment. +func (s ScopedDeployment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", s.Location) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopedDeployment. +func (s *ScopedDeployment) 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 "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + 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 ScopedDeploymentWhatIf. +func (s ScopedDeploymentWhatIf) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", s.Location) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopedDeploymentWhatIf. +func (s *ScopedDeploymentWhatIf) 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 "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + 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 StatusMessage. +func (s StatusMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", s.Error) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StatusMessage. +func (s *StatusMessage) 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 "error": + err = unpopulate(val, "Error", &s.Error) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + 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 TargetResource. +func (t TargetResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", t.APIVersion) + populate(objectMap, "extension", t.Extension) + populate(objectMap, "id", t.ID) + populateAny(objectMap, "identifiers", t.Identifiers) + populate(objectMap, "resourceName", t.ResourceName) + populate(objectMap, "resourceType", t.ResourceType) + populate(objectMap, "symbolicName", t.SymbolicName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetResource. +func (t *TargetResource) 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 "apiVersion": + err = unpopulate(val, "APIVersion", &t.APIVersion) + delete(rawMsg, key) + case "extension": + err = unpopulate(val, "Extension", &t.Extension) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "identifiers": + err = unpopulate(val, "Identifiers", &t.Identifiers) + delete(rawMsg, key) + case "resourceName": + err = unpopulate(val, "ResourceName", &t.ResourceName) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &t.ResourceType) + delete(rawMsg, key) + case "symbolicName": + err = unpopulate(val, "SymbolicName", &t.SymbolicName) + 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 TemplateHashResult. +func (t TemplateHashResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "minifiedTemplate", t.MinifiedTemplate) + populate(objectMap, "templateHash", t.TemplateHash) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateHashResult. +func (t *TemplateHashResult) 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 "minifiedTemplate": + err = unpopulate(val, "MinifiedTemplate", &t.MinifiedTemplate) + delete(rawMsg, key) + case "templateHash": + err = unpopulate(val, "TemplateHash", &t.TemplateHash) + 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 TemplateLink. +func (t TemplateLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentVersion", t.ContentVersion) + populate(objectMap, "id", t.ID) + populate(objectMap, "queryString", t.QueryString) + populate(objectMap, "relativePath", t.RelativePath) + populate(objectMap, "uri", t.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateLink. +func (t *TemplateLink) 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 "contentVersion": + err = unpopulate(val, "ContentVersion", &t.ContentVersion) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "queryString": + err = unpopulate(val, "QueryString", &t.QueryString) + delete(rawMsg, key) + case "relativePath": + err = unpopulate(val, "RelativePath", &t.RelativePath) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &t.URI) + 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 UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) 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 "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + 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 WhatIfChange. +func (w WhatIfChange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "after", w.After) + populateAny(objectMap, "before", w.Before) + populate(objectMap, "changeType", w.ChangeType) + populate(objectMap, "delta", w.Delta) + populate(objectMap, "deploymentId", w.DeploymentID) + populate(objectMap, "extension", w.Extension) + populateAny(objectMap, "identifiers", w.Identifiers) + populate(objectMap, "resourceId", w.ResourceID) + populate(objectMap, "symbolicName", w.SymbolicName) + populate(objectMap, "unsupportedReason", w.UnsupportedReason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfChange. +func (w *WhatIfChange) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "after": + err = unpopulate(val, "After", &w.After) + delete(rawMsg, key) + case "before": + err = unpopulate(val, "Before", &w.Before) + delete(rawMsg, key) + case "changeType": + err = unpopulate(val, "ChangeType", &w.ChangeType) + delete(rawMsg, key) + case "delta": + err = unpopulate(val, "Delta", &w.Delta) + delete(rawMsg, key) + case "deploymentId": + err = unpopulate(val, "DeploymentID", &w.DeploymentID) + delete(rawMsg, key) + case "extension": + err = unpopulate(val, "Extension", &w.Extension) + delete(rawMsg, key) + case "identifiers": + err = unpopulate(val, "Identifiers", &w.Identifiers) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &w.ResourceID) + delete(rawMsg, key) + case "symbolicName": + err = unpopulate(val, "SymbolicName", &w.SymbolicName) + delete(rawMsg, key) + case "unsupportedReason": + err = unpopulate(val, "UnsupportedReason", &w.UnsupportedReason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WhatIfOperationProperties. +func (w WhatIfOperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "changes", w.Changes) + populate(objectMap, "diagnostics", w.Diagnostics) + populate(objectMap, "potentialChanges", w.PotentialChanges) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfOperationProperties. +func (w *WhatIfOperationProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "changes": + err = unpopulate(val, "Changes", &w.Changes) + delete(rawMsg, key) + case "diagnostics": + err = unpopulate(val, "Diagnostics", &w.Diagnostics) + delete(rawMsg, key) + case "potentialChanges": + err = unpopulate(val, "PotentialChanges", &w.PotentialChanges) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WhatIfOperationResult. +func (w WhatIfOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", w.Error) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "status", w.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfOperationResult. +func (w *WhatIfOperationResult) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &w.Error) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &w.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WhatIfPropertyChange. +func (w WhatIfPropertyChange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "after", w.After) + populateAny(objectMap, "before", w.Before) + populate(objectMap, "children", w.Children) + populate(objectMap, "path", w.Path) + populate(objectMap, "propertyChangeType", w.PropertyChangeType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfPropertyChange. +func (w *WhatIfPropertyChange) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "after": + err = unpopulate(val, "After", &w.After) + delete(rawMsg, key) + case "before": + err = unpopulate(val, "Before", &w.Before) + delete(rawMsg, key) + case "children": + err = unpopulate(val, "Children", &w.Children) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &w.Path) + delete(rawMsg, key) + case "propertyChangeType": + err = unpopulate(val, "PropertyChangeType", &w.PropertyChangeType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ZoneMapping. +func (z ZoneMapping) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", z.Location) + populate(objectMap, "zones", z.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ZoneMapping. +func (z *ZoneMapping) 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", z, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &z.Location) + delete(rawMsg, key) + case "zones": + err = unpopulate(val, "Zones", &z.Zones) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", z, 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 populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + 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/deployments/deployments/options.go b/sdk/resourcemanager/deployments/deployments/options.go new file mode 100644 index 000000000000..b8f6d57088d7 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/options.go @@ -0,0 +1,349 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deployments + +// ClientBeginCreateOrUpdateAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtManagementGroupScope +// method. +type ClientBeginCreateOrUpdateAtManagementGroupScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtScope method. +type ClientBeginCreateOrUpdateAtScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtSubscriptionScope +// method. +type ClientBeginCreateOrUpdateAtSubscriptionScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateAtTenantScopeOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtTenantScope +// method. +type ClientBeginCreateOrUpdateAtTenantScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. +type ClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginDeleteAtManagementGroupScope +// method. +type ClientBeginDeleteAtManagementGroupScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteAtScopeOptions contains the optional parameters for the Client.BeginDeleteAtScope method. +type ClientBeginDeleteAtScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginDeleteAtSubscriptionScope +// method. +type ClientBeginDeleteAtSubscriptionScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteAtTenantScopeOptions contains the optional parameters for the Client.BeginDeleteAtTenantScope method. +type ClientBeginDeleteAtTenantScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +type ClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginValidateAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginValidateAtManagementGroupScope +// method. +type ClientBeginValidateAtManagementGroupScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginValidateAtScopeOptions contains the optional parameters for the Client.BeginValidateAtScope method. +type ClientBeginValidateAtScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginValidateAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginValidateAtSubscriptionScope +// method. +type ClientBeginValidateAtSubscriptionScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginValidateAtTenantScopeOptions contains the optional parameters for the Client.BeginValidateAtTenantScope method. +type ClientBeginValidateAtTenantScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginValidateOptions contains the optional parameters for the Client.BeginValidate method. +type ClientBeginValidateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginWhatIfAtManagementGroupScopeOptions contains the optional parameters for the Client.BeginWhatIfAtManagementGroupScope +// method. +type ClientBeginWhatIfAtManagementGroupScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginWhatIfAtSubscriptionScopeOptions contains the optional parameters for the Client.BeginWhatIfAtSubscriptionScope +// method. +type ClientBeginWhatIfAtSubscriptionScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginWhatIfAtTenantScopeOptions contains the optional parameters for the Client.BeginWhatIfAtTenantScope method. +type ClientBeginWhatIfAtTenantScopeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginWhatIfOptions contains the optional parameters for the Client.BeginWhatIf method. +type ClientBeginWhatIfOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientCalculateTemplateHashOptions contains the optional parameters for the Client.CalculateTemplateHash method. +type ClientCalculateTemplateHashOptions struct { + // placeholder for future optional parameters +} + +// ClientCancelAtManagementGroupScopeOptions contains the optional parameters for the Client.CancelAtManagementGroupScope +// method. +type ClientCancelAtManagementGroupScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCancelAtScopeOptions contains the optional parameters for the Client.CancelAtScope method. +type ClientCancelAtScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCancelAtSubscriptionScopeOptions contains the optional parameters for the Client.CancelAtSubscriptionScope method. +type ClientCancelAtSubscriptionScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCancelAtTenantScopeOptions contains the optional parameters for the Client.CancelAtTenantScope method. +type ClientCancelAtTenantScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCancelOptions contains the optional parameters for the Client.Cancel method. +type ClientCancelOptions struct { + // placeholder for future optional parameters +} + +// ClientCheckExistenceAtManagementGroupScopeOptions contains the optional parameters for the Client.CheckExistenceAtManagementGroupScope +// method. +type ClientCheckExistenceAtManagementGroupScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCheckExistenceAtScopeOptions contains the optional parameters for the Client.CheckExistenceAtScope method. +type ClientCheckExistenceAtScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCheckExistenceAtSubscriptionScopeOptions contains the optional parameters for the Client.CheckExistenceAtSubscriptionScope +// method. +type ClientCheckExistenceAtSubscriptionScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCheckExistenceAtTenantScopeOptions contains the optional parameters for the Client.CheckExistenceAtTenantScope method. +type ClientCheckExistenceAtTenantScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientCheckExistenceOptions contains the optional parameters for the Client.CheckExistence method. +type ClientCheckExistenceOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtManagementGroupScopeOptions contains the optional parameters for the Client.ExportTemplateAtManagementGroupScope +// method. +type ClientExportTemplateAtManagementGroupScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtScopeOptions contains the optional parameters for the Client.ExportTemplateAtScope method. +type ClientExportTemplateAtScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtSubscriptionScopeOptions contains the optional parameters for the Client.ExportTemplateAtSubscriptionScope +// method. +type ClientExportTemplateAtSubscriptionScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtTenantScopeOptions contains the optional parameters for the Client.ExportTemplateAtTenantScope method. +type ClientExportTemplateAtTenantScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateOptions contains the optional parameters for the Client.ExportTemplate method. +type ClientExportTemplateOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtManagementGroupScopeOptions contains the optional parameters for the Client.GetAtManagementGroupScope method. +type ClientGetAtManagementGroupScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtScopeOptions contains the optional parameters for the Client.GetAtScope method. +type ClientGetAtScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtSubscriptionScopeOptions contains the optional parameters for the Client.GetAtSubscriptionScope method. +type ClientGetAtSubscriptionScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtTenantScopeOptions contains the optional parameters for the Client.GetAtTenantScope method. +type ClientGetAtTenantScopeOptions struct { + // placeholder for future optional parameters +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientListAtManagementGroupScopeOptions contains the optional parameters for the Client.NewListAtManagementGroupScopePager +// method. +type ClientListAtManagementGroupScopeOptions struct { + // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. + Filter *string + + // The number of results to get. If null is passed, returns all deployments. + Top *int32 +} + +// ClientListAtScopeOptions contains the optional parameters for the Client.NewListAtScopePager method. +type ClientListAtScopeOptions struct { + // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. + Filter *string + + // The number of results to get. If null is passed, returns all deployments. + Top *int32 +} + +// ClientListAtSubscriptionScopeOptions contains the optional parameters for the Client.NewListAtSubscriptionScopePager method. +type ClientListAtSubscriptionScopeOptions struct { + // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. + Filter *string + + // The number of results to get. If null is passed, returns all deployments. + Top *int32 +} + +// ClientListAtTenantScopeOptions contains the optional parameters for the Client.NewListAtTenantScopePager method. +type ClientListAtTenantScopeOptions struct { + // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. + Filter *string + + // The number of results to get. If null is passed, returns all deployments. + Top *int32 +} + +// ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager method. +type ClientListByResourceGroupOptions struct { + // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. + Filter *string + + // The number of results to get. If null is passed, returns all deployments. + Top *int32 +} + +// DeploymentOperationsClientGetAtManagementGroupScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtManagementGroupScope +// method. +type DeploymentOperationsClientGetAtManagementGroupScopeOptions struct { + // placeholder for future optional parameters +} + +// DeploymentOperationsClientGetAtScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtScope +// method. +type DeploymentOperationsClientGetAtScopeOptions struct { + // placeholder for future optional parameters +} + +// DeploymentOperationsClientGetAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtSubscriptionScope +// method. +type DeploymentOperationsClientGetAtSubscriptionScopeOptions struct { + // placeholder for future optional parameters +} + +// DeploymentOperationsClientGetAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtTenantScope +// method. +type DeploymentOperationsClientGetAtTenantScopeOptions struct { + // placeholder for future optional parameters +} + +// DeploymentOperationsClientGetOptions contains the optional parameters for the DeploymentOperationsClient.Get method. +type DeploymentOperationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DeploymentOperationsClientListAtManagementGroupScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtManagementGroupScopePager +// method. +type DeploymentOperationsClientListAtManagementGroupScopeOptions struct { + // The number of results to return. + Top *int32 +} + +// DeploymentOperationsClientListAtScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtScopePager +// method. +type DeploymentOperationsClientListAtScopeOptions struct { + // The number of results to return. + Top *int32 +} + +// DeploymentOperationsClientListAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtSubscriptionScopePager +// method. +type DeploymentOperationsClientListAtSubscriptionScopeOptions struct { + // The number of results to return. + Top *int32 +} + +// DeploymentOperationsClientListAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtTenantScopePager +// method. +type DeploymentOperationsClientListAtTenantScopeOptions struct { + // The number of results to return. + Top *int32 +} + +// DeploymentOperationsClientListOptions contains the optional parameters for the DeploymentOperationsClient.NewListPager +// method. +type DeploymentOperationsClientListOptions struct { + // The number of results to return. + Top *int32 +} diff --git a/sdk/resourcemanager/deployments/deployments/responses.go b/sdk/resourcemanager/deployments/deployments/responses.go new file mode 100644 index 000000000000..ed5ffe3151c3 --- /dev/null +++ b/sdk/resourcemanager/deployments/deployments/responses.go @@ -0,0 +1,326 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deployments + +// ClientCalculateTemplateHashResponse contains the response from method Client.CalculateTemplateHash. +type ClientCalculateTemplateHashResponse struct { + // Result of the request to calculate template hash. It contains a string of minified template and its hash. + TemplateHashResult +} + +// ClientCancelAtManagementGroupScopeResponse contains the response from method Client.CancelAtManagementGroupScope. +type ClientCancelAtManagementGroupScopeResponse struct { + // placeholder for future response values +} + +// ClientCancelAtScopeResponse contains the response from method Client.CancelAtScope. +type ClientCancelAtScopeResponse struct { + // placeholder for future response values +} + +// ClientCancelAtSubscriptionScopeResponse contains the response from method Client.CancelAtSubscriptionScope. +type ClientCancelAtSubscriptionScopeResponse struct { + // placeholder for future response values +} + +// ClientCancelAtTenantScopeResponse contains the response from method Client.CancelAtTenantScope. +type ClientCancelAtTenantScopeResponse struct { + // placeholder for future response values +} + +// ClientCancelResponse contains the response from method Client.Cancel. +type ClientCancelResponse struct { + // placeholder for future response values +} + +// ClientCheckExistenceAtManagementGroupScopeResponse contains the response from method Client.CheckExistenceAtManagementGroupScope. +type ClientCheckExistenceAtManagementGroupScopeResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ClientCheckExistenceAtScopeResponse contains the response from method Client.CheckExistenceAtScope. +type ClientCheckExistenceAtScopeResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ClientCheckExistenceAtSubscriptionScopeResponse contains the response from method Client.CheckExistenceAtSubscriptionScope. +type ClientCheckExistenceAtSubscriptionScopeResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ClientCheckExistenceAtTenantScopeResponse contains the response from method Client.CheckExistenceAtTenantScope. +type ClientCheckExistenceAtTenantScopeResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ClientCheckExistenceResponse contains the response from method Client.CheckExistence. +type ClientCheckExistenceResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ClientCreateOrUpdateAtManagementGroupScopeResponse contains the response from method Client.BeginCreateOrUpdateAtManagementGroupScope. +type ClientCreateOrUpdateAtManagementGroupScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientCreateOrUpdateAtScopeResponse contains the response from method Client.BeginCreateOrUpdateAtScope. +type ClientCreateOrUpdateAtScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientCreateOrUpdateAtSubscriptionScopeResponse contains the response from method Client.BeginCreateOrUpdateAtSubscriptionScope. +type ClientCreateOrUpdateAtSubscriptionScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientCreateOrUpdateAtTenantScopeResponse contains the response from method Client.BeginCreateOrUpdateAtTenantScope. +type ClientCreateOrUpdateAtTenantScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientCreateOrUpdateResponse contains the response from method Client.BeginCreateOrUpdate. +type ClientCreateOrUpdateResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientDeleteAtManagementGroupScopeResponse contains the response from method Client.BeginDeleteAtManagementGroupScope. +type ClientDeleteAtManagementGroupScopeResponse struct { + // placeholder for future response values +} + +// ClientDeleteAtScopeResponse contains the response from method Client.BeginDeleteAtScope. +type ClientDeleteAtScopeResponse struct { + // placeholder for future response values +} + +// ClientDeleteAtSubscriptionScopeResponse contains the response from method Client.BeginDeleteAtSubscriptionScope. +type ClientDeleteAtSubscriptionScopeResponse struct { + // placeholder for future response values +} + +// ClientDeleteAtTenantScopeResponse contains the response from method Client.BeginDeleteAtTenantScope. +type ClientDeleteAtTenantScopeResponse struct { + // placeholder for future response values +} + +// ClientDeleteResponse contains the response from method Client.BeginDelete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientExportTemplateAtManagementGroupScopeResponse contains the response from method Client.ExportTemplateAtManagementGroupScope. +type ClientExportTemplateAtManagementGroupScopeResponse struct { + // The deployment export result. + DeploymentExportResult +} + +// ClientExportTemplateAtScopeResponse contains the response from method Client.ExportTemplateAtScope. +type ClientExportTemplateAtScopeResponse struct { + // The deployment export result. + DeploymentExportResult +} + +// ClientExportTemplateAtSubscriptionScopeResponse contains the response from method Client.ExportTemplateAtSubscriptionScope. +type ClientExportTemplateAtSubscriptionScopeResponse struct { + // The deployment export result. + DeploymentExportResult +} + +// ClientExportTemplateAtTenantScopeResponse contains the response from method Client.ExportTemplateAtTenantScope. +type ClientExportTemplateAtTenantScopeResponse struct { + // The deployment export result. + DeploymentExportResult +} + +// ClientExportTemplateResponse contains the response from method Client.ExportTemplate. +type ClientExportTemplateResponse struct { + // The deployment export result. + DeploymentExportResult +} + +// ClientGetAtManagementGroupScopeResponse contains the response from method Client.GetAtManagementGroupScope. +type ClientGetAtManagementGroupScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientGetAtScopeResponse contains the response from method Client.GetAtScope. +type ClientGetAtScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientGetAtSubscriptionScopeResponse contains the response from method Client.GetAtSubscriptionScope. +type ClientGetAtSubscriptionScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientGetAtTenantScopeResponse contains the response from method Client.GetAtTenantScope. +type ClientGetAtTenantScopeResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // Deployment information. + DeploymentExtended +} + +// ClientListAtManagementGroupScopeResponse contains the response from method Client.NewListAtManagementGroupScopePager. +type ClientListAtManagementGroupScopeResponse struct { + // List of deployments. + DeploymentListResult +} + +// ClientListAtScopeResponse contains the response from method Client.NewListAtScopePager. +type ClientListAtScopeResponse struct { + // List of deployments. + DeploymentListResult +} + +// ClientListAtSubscriptionScopeResponse contains the response from method Client.NewListAtSubscriptionScopePager. +type ClientListAtSubscriptionScopeResponse struct { + // List of deployments. + DeploymentListResult +} + +// ClientListAtTenantScopeResponse contains the response from method Client.NewListAtTenantScopePager. +type ClientListAtTenantScopeResponse struct { + // List of deployments. + DeploymentListResult +} + +// ClientListByResourceGroupResponse contains the response from method Client.NewListByResourceGroupPager. +type ClientListByResourceGroupResponse struct { + // List of deployments. + DeploymentListResult +} + +// ClientValidateAtManagementGroupScopeResponse contains the response from method Client.BeginValidateAtManagementGroupScope. +type ClientValidateAtManagementGroupScopeResponse struct { + // Information from validate template deployment response. + DeploymentValidateResult +} + +// ClientValidateAtScopeResponse contains the response from method Client.BeginValidateAtScope. +type ClientValidateAtScopeResponse struct { + // Information from validate template deployment response. + DeploymentValidateResult +} + +// ClientValidateAtSubscriptionScopeResponse contains the response from method Client.BeginValidateAtSubscriptionScope. +type ClientValidateAtSubscriptionScopeResponse struct { + // Information from validate template deployment response. + DeploymentValidateResult +} + +// ClientValidateAtTenantScopeResponse contains the response from method Client.BeginValidateAtTenantScope. +type ClientValidateAtTenantScopeResponse struct { + // Information from validate template deployment response. + DeploymentValidateResult +} + +// ClientValidateResponse contains the response from method Client.BeginValidate. +type ClientValidateResponse struct { + // Information from validate template deployment response. + DeploymentValidateResult +} + +// ClientWhatIfAtManagementGroupScopeResponse contains the response from method Client.BeginWhatIfAtManagementGroupScope. +type ClientWhatIfAtManagementGroupScopeResponse struct { + // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. + WhatIfOperationResult +} + +// ClientWhatIfAtSubscriptionScopeResponse contains the response from method Client.BeginWhatIfAtSubscriptionScope. +type ClientWhatIfAtSubscriptionScopeResponse struct { + // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. + WhatIfOperationResult +} + +// ClientWhatIfAtTenantScopeResponse contains the response from method Client.BeginWhatIfAtTenantScope. +type ClientWhatIfAtTenantScopeResponse struct { + // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. + WhatIfOperationResult +} + +// ClientWhatIfResponse contains the response from method Client.BeginWhatIf. +type ClientWhatIfResponse struct { + // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. + WhatIfOperationResult +} + +// DeploymentOperationsClientGetAtManagementGroupScopeResponse contains the response from method DeploymentOperationsClient.GetAtManagementGroupScope. +type DeploymentOperationsClientGetAtManagementGroupScopeResponse struct { + // Deployment operation information. + DeploymentOperation +} + +// DeploymentOperationsClientGetAtScopeResponse contains the response from method DeploymentOperationsClient.GetAtScope. +type DeploymentOperationsClientGetAtScopeResponse struct { + // Deployment operation information. + DeploymentOperation +} + +// DeploymentOperationsClientGetAtSubscriptionScopeResponse contains the response from method DeploymentOperationsClient.GetAtSubscriptionScope. +type DeploymentOperationsClientGetAtSubscriptionScopeResponse struct { + // Deployment operation information. + DeploymentOperation +} + +// DeploymentOperationsClientGetAtTenantScopeResponse contains the response from method DeploymentOperationsClient.GetAtTenantScope. +type DeploymentOperationsClientGetAtTenantScopeResponse struct { + // Deployment operation information. + DeploymentOperation +} + +// DeploymentOperationsClientGetResponse contains the response from method DeploymentOperationsClient.Get. +type DeploymentOperationsClientGetResponse struct { + // Deployment operation information. + DeploymentOperation +} + +// DeploymentOperationsClientListAtManagementGroupScopeResponse contains the response from method DeploymentOperationsClient.NewListAtManagementGroupScopePager. +type DeploymentOperationsClientListAtManagementGroupScopeResponse struct { + // List of deployment operations. + DeploymentOperationsListResult +} + +// DeploymentOperationsClientListAtScopeResponse contains the response from method DeploymentOperationsClient.NewListAtScopePager. +type DeploymentOperationsClientListAtScopeResponse struct { + // List of deployment operations. + DeploymentOperationsListResult +} + +// DeploymentOperationsClientListAtSubscriptionScopeResponse contains the response from method DeploymentOperationsClient.NewListAtSubscriptionScopePager. +type DeploymentOperationsClientListAtSubscriptionScopeResponse struct { + // List of deployment operations. + DeploymentOperationsListResult +} + +// DeploymentOperationsClientListAtTenantScopeResponse contains the response from method DeploymentOperationsClient.NewListAtTenantScopePager. +type DeploymentOperationsClientListAtTenantScopeResponse struct { + // List of deployment operations. + DeploymentOperationsListResult +} + +// DeploymentOperationsClientListResponse contains the response from method DeploymentOperationsClient.NewListPager. +type DeploymentOperationsClientListResponse struct { + // List of deployment operations. + DeploymentOperationsListResult +} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go b/sdk/resourcemanager/deployments/deployments/time_rfc3339.go similarity index 99% rename from sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go rename to sdk/resourcemanager/deployments/deployments/time_rfc3339.go index 7691a451714b..e98829672230 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go +++ b/sdk/resourcemanager/deployments/deployments/time_rfc3339.go @@ -3,7 +3,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package fake +package deployments import ( "encoding/json" diff --git a/sdk/resourcemanager/deployments/deploymentscripts/CHANGELOG.md b/sdk/resourcemanager/deployments/deploymentscripts/CHANGELOG.md new file mode 100644 index 000000000000..85155d17c389 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-04-28) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentscripts` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentscripts/LICENSE.txt b/sdk/resourcemanager/deployments/deploymentscripts/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentscripts/README.md b/sdk/resourcemanager/deployments/deploymentscripts/README.md new file mode 100644 index 000000000000..861d57037662 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/README.md @@ -0,0 +1,90 @@ +# Azure Deployments Module for Go + +The `deploymentscripts` module provides operations for working with Azure Deployments. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/deployments/deploymentscripts) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Deployments module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentscripts +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Deployments. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +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). + +## Client Factory + +Azure Deployments module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := deploymentscripts.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 { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := deploymentscripts.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() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Deployments` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentscripts/autorest.md b/sdk/resourcemanager/deployments/deploymentscripts/autorest.md new file mode 100644 index 000000000000..fb0a43409732 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/deploymentScripts/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/deploymentScripts/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentscripts/build.go b/sdk/resourcemanager/deployments/deploymentscripts/build.go new file mode 100644 index 000000000000..c373dce52eea --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/deployments/deploymentscripts + +package deploymentscripts diff --git a/sdk/resourcemanager/deployments/deploymentscripts/ci.yml b/sdk/resourcemanager/deployments/deploymentscripts/ci.yml new file mode 100644 index 000000000000..a1d6d9518955 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/deploymentscripts/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/deploymentscripts/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/deployments/deploymentscripts' diff --git a/sdk/resourcemanager/deployments/deploymentscripts/client.go b/sdk/resourcemanager/deployments/deploymentscripts/client.go new file mode 100644 index 000000000000..c8fc73b5726d --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/client.go @@ -0,0 +1,552 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// Client contains the methods for the DeploymentScripts group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - Subscription Id which forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates a deployment script. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scriptName - Name of the deployment script. +// - deploymentScript - Deployment script supplied to the operation. +// - options - ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +func (client *Client) BeginCreate(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript DeploymentScriptClassification, options *ClientBeginCreateOptions) (*runtime.Poller[ClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, scriptName, deploymentScript, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Creates a deployment script. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +func (client *Client) create(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript DeploymentScriptClassification, options *ClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, scriptName, deploymentScript, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *Client) createCreateRequest(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript DeploymentScriptClassification, _ *ClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentScript); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes a deployment script. When operation completes, status code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scriptName - Name of the deployment script. +// - options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. +func (client *Client) Delete(ctx context.Context, resourceGroupName string, scriptName string, options *ClientDeleteOptions) (ClientDeleteResponse, error) { + var err error + const operationName = "Client.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, scriptName, options) + if err != nil { + return ClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ClientDeleteResponse{}, err + } + return ClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, scriptName string, _ *ClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a deployment script with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scriptName - Name of the deployment script. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, scriptName string, options *ClientGetOptions) (ClientGetResponse, error) { + var err error + const operationName = "Client.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, scriptName, options) + if err != nil { + return ClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, scriptName string, _ *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// GetLogs - Gets deployment script logs for a given deployment script name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scriptName - Name of the deployment script. +// - options - ClientGetLogsOptions contains the optional parameters for the Client.GetLogs method. +func (client *Client) GetLogs(ctx context.Context, resourceGroupName string, scriptName string, options *ClientGetLogsOptions) (ClientGetLogsResponse, error) { + var err error + const operationName = "Client.GetLogs" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getLogsCreateRequest(ctx, resourceGroupName, scriptName, options) + if err != nil { + return ClientGetLogsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetLogsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetLogsResponse{}, err + } + resp, err := client.getLogsHandleResponse(httpResp) + return resp, err +} + +// getLogsCreateRequest creates the GetLogs request. +func (client *Client) getLogsCreateRequest(ctx context.Context, resourceGroupName string, scriptName string, _ *ClientGetLogsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getLogsHandleResponse handles the GetLogs response. +func (client *Client) getLogsHandleResponse(resp *http.Response) (ClientGetLogsResponse, error) { + result := ClientGetLogsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptLogsList); err != nil { + return ClientGetLogsResponse{}, err + } + return result, nil +} + +// GetLogsDefault - Gets deployment script logs for a given deployment script name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scriptName - Name of the deployment script. +// - options - ClientGetLogsDefaultOptions contains the optional parameters for the Client.GetLogsDefault method. +func (client *Client) GetLogsDefault(ctx context.Context, resourceGroupName string, scriptName string, options *ClientGetLogsDefaultOptions) (ClientGetLogsDefaultResponse, error) { + var err error + const operationName = "Client.GetLogsDefault" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getLogsDefaultCreateRequest(ctx, resourceGroupName, scriptName, options) + if err != nil { + return ClientGetLogsDefaultResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetLogsDefaultResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetLogsDefaultResponse{}, err + } + resp, err := client.getLogsDefaultHandleResponse(httpResp) + return resp, err +} + +// getLogsDefaultCreateRequest creates the GetLogsDefault request. +func (client *Client) getLogsDefaultCreateRequest(ctx context.Context, resourceGroupName string, scriptName string, options *ClientGetLogsDefaultOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + if options != nil && options.Tail != nil { + reqQP.Set("tail", strconv.FormatInt(int64(*options.Tail), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getLogsDefaultHandleResponse handles the GetLogsDefault response. +func (client *Client) getLogsDefaultHandleResponse(resp *http.Response) (ClientGetLogsDefaultResponse, error) { + result := ClientGetLogsDefaultResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScriptLog); err != nil { + return ClientGetLogsDefaultResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists deployments scripts. +// +// Generated from API version 2023-08-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager +// method. +func (client *Client) NewListByResourceGroupPager(resourceGroupName string, options *ClientListByResourceGroupOptions) *runtime.Pager[ClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListByResourceGroupResponse]{ + More: func(page ClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListByResourceGroupResponse) (ClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (ClientListByResourceGroupResponse, error) { + result := ClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentScriptListResult); err != nil { + return ClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists all deployment scripts for a given subscription. +// +// Generated from API version 2023-08-01 +// - options - ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. +func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListBySubscriptionResponse]{ + More: func(page ClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListBySubscriptionResponse) (ClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return ClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, _ *ClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts" + if client.subscriptionID == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *Client) listBySubscriptionHandleResponse(resp *http.Response) (ClientListBySubscriptionResponse, error) { + result := ClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentScriptListResult); err != nil { + return ClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Updates deployment script tags with specified values. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - scriptName - Name of the deployment script. +// - deploymentScript - Deployment script resource with the tags to be updated. +// - options - ClientUpdateOptions contains the optional parameters for the Client.Update method. +func (client *Client) Update(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript DeploymentScriptUpdateParameter, options *ClientUpdateOptions) (ClientUpdateResponse, error) { + var err error + const operationName = "Client.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, scriptName, deploymentScript, options) + if err != nil { + return ClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript DeploymentScriptUpdateParameter, _ *ClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if scriptName == "" { + return nil, errors.New("parameter scriptName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scriptName}", url.PathEscape(scriptName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentScript); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *Client) updateHandleResponse(resp *http.Response) (ClientUpdateResponse, error) { + result := ClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return ClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/client_factory.go b/sdk/resourcemanager/deployments/deploymentscripts/client_factory.go new file mode 100644 index 000000000000..944270aa4374 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/client_factory.go @@ -0,0 +1,42 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +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 + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Subscription Id which forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/constants.go b/sdk/resourcemanager/deployments/deploymentscripts/constants.go new file mode 100644 index 000000000000..9fe3b43caf47 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/constants.go @@ -0,0 +1,103 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentscripts" + moduleVersion = "v0.1.0" +) + +// CleanupOptions - The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. +type CleanupOptions string + +const ( + CleanupOptionsAlways CleanupOptions = "Always" + CleanupOptionsOnExpiration CleanupOptions = "OnExpiration" + CleanupOptionsOnSuccess CleanupOptions = "OnSuccess" +) + +// PossibleCleanupOptionsValues returns the possible values for the CleanupOptions const type. +func PossibleCleanupOptionsValues() []CleanupOptions { + return []CleanupOptions{ + CleanupOptionsAlways, + CleanupOptionsOnExpiration, + CleanupOptionsOnSuccess, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ManagedServiceIdentityType - Type of the managed identity. +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeUserAssigned, + } +} + +// ScriptProvisioningState - State of the script execution. This only appears in the response. +type ScriptProvisioningState string + +const ( + ScriptProvisioningStateCanceled ScriptProvisioningState = "Canceled" + ScriptProvisioningStateCreating ScriptProvisioningState = "Creating" + ScriptProvisioningStateFailed ScriptProvisioningState = "Failed" + ScriptProvisioningStateProvisioningResources ScriptProvisioningState = "ProvisioningResources" + ScriptProvisioningStateRunning ScriptProvisioningState = "Running" + ScriptProvisioningStateSucceeded ScriptProvisioningState = "Succeeded" +) + +// PossibleScriptProvisioningStateValues returns the possible values for the ScriptProvisioningState const type. +func PossibleScriptProvisioningStateValues() []ScriptProvisioningState { + return []ScriptProvisioningState{ + ScriptProvisioningStateCanceled, + ScriptProvisioningStateCreating, + ScriptProvisioningStateFailed, + ScriptProvisioningStateProvisioningResources, + ScriptProvisioningStateRunning, + ScriptProvisioningStateSucceeded, + } +} + +// ScriptType - Type of the script. +type ScriptType string + +const ( + ScriptTypeAzureCLI ScriptType = "AzureCLI" + ScriptTypeAzurePowerShell ScriptType = "AzurePowerShell" +) + +// PossibleScriptTypeValues returns the possible values for the ScriptType const type. +func PossibleScriptTypeValues() []ScriptType { + return []ScriptType{ + ScriptTypeAzureCLI, + ScriptTypeAzurePowerShell, + } +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/fake/internal.go b/sdk/resourcemanager/deployments/deploymentscripts/fake/internal.go new file mode 100644 index 000000000000..bd3c81fecb98 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/fake/internal.go @@ -0,0 +1,90 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "io" + "net/http" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func readRequestBody(req *http.Request) ([]byte, error) { + if req.Body == nil { + return nil, nil + } + body, err := io.ReadAll(req.Body) + if err != nil { + return nil, err + } + req.Body.Close() + return body, nil +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/fake/polymorphic_helpers.go b/sdk/resourcemanager/deployments/deploymentscripts/fake/polymorphic_helpers.go new file mode 100644 index 000000000000..0f36439d4572 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/fake/polymorphic_helpers.go @@ -0,0 +1,34 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentscripts" +) + +func unmarshalDeploymentScriptClassification(rawMsg json.RawMessage) (deploymentscripts.DeploymentScriptClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b deploymentscripts.DeploymentScriptClassification + switch m["kind"] { + case string(deploymentscripts.ScriptTypeAzureCLI): + b = &deploymentscripts.AzureCliScript{} + case string(deploymentscripts.ScriptTypeAzurePowerShell): + b = &deploymentscripts.AzurePowerShellScript{} + default: + b = &deploymentscripts.DeploymentScript{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/fake/server.go b/sdk/resourcemanager/deployments/deploymentscripts/fake/server.go new file mode 100644 index 000000000000..02073d3537e6 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/fake/server.go @@ -0,0 +1,453 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentscripts" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// Server is a fake server for instances of the deploymentscripts.Client type. +type Server struct { + // BeginCreate is the fake for method Client.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript deploymentscripts.DeploymentScriptClassification, options *deploymentscripts.ClientBeginCreateOptions) (resp azfake.PollerResponder[deploymentscripts.ClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method Client.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, scriptName string, options *deploymentscripts.ClientDeleteOptions) (resp azfake.Responder[deploymentscripts.ClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method Client.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, scriptName string, options *deploymentscripts.ClientGetOptions) (resp azfake.Responder[deploymentscripts.ClientGetResponse], errResp azfake.ErrorResponder) + + // GetLogs is the fake for method Client.GetLogs + // HTTP status codes to indicate success: http.StatusOK + GetLogs func(ctx context.Context, resourceGroupName string, scriptName string, options *deploymentscripts.ClientGetLogsOptions) (resp azfake.Responder[deploymentscripts.ClientGetLogsResponse], errResp azfake.ErrorResponder) + + // GetLogsDefault is the fake for method Client.GetLogsDefault + // HTTP status codes to indicate success: http.StatusOK + GetLogsDefault func(ctx context.Context, resourceGroupName string, scriptName string, options *deploymentscripts.ClientGetLogsDefaultOptions) (resp azfake.Responder[deploymentscripts.ClientGetLogsDefaultResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method Client.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *deploymentscripts.ClientListByResourceGroupOptions) (resp azfake.PagerResponder[deploymentscripts.ClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method Client.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *deploymentscripts.ClientListBySubscriptionOptions) (resp azfake.PagerResponder[deploymentscripts.ClientListBySubscriptionResponse]) + + // Update is the fake for method Client.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript deploymentscripts.DeploymentScriptUpdateParameter, options *deploymentscripts.ClientUpdateOptions) (resp azfake.Responder[deploymentscripts.ClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of deploymentscripts.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[deploymentscripts.ClientCreateResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[deploymentscripts.ClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[deploymentscripts.ClientListBySubscriptionResponse]](), + } +} + +// ServerTransport connects instances of deploymentscripts.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + beginCreate *tracker[azfake.PollerResponder[deploymentscripts.ClientCreateResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[deploymentscripts.ClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[deploymentscripts.ClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.BeginCreate": + res.resp, res.err = s.dispatchBeginCreate(req) + case "Client.Delete": + res.resp, res.err = s.dispatchDelete(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.GetLogs": + res.resp, res.err = s.dispatchGetLogs(req) + case "Client.GetLogsDefault": + res.resp, res.err = s.dispatchGetLogsDefault(req) + case "Client.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "Client.NewListBySubscriptionPager": + res.resp, res.err = s.dispatchNewListBySubscriptionPager(req) + case "Client.Update": + res.resp, res.err = s.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := s.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalDeploymentScriptClassification(raw) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreate(req.Context(), resourceGroupNameParam, scriptNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + s.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + s.beginCreate.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), resourceGroupNameParam, scriptNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, scriptNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentScriptClassification, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGetLogs(req *http.Request) (*http.Response, error) { + if s.srv.GetLogs == nil { + return nil, &nonRetriableError{errors.New("fake for method GetLogs not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/logs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetLogs(req.Context(), resourceGroupNameParam, scriptNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ScriptLogsList, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGetLogsDefault(req *http.Request) (*http.Response, error) { + if s.srv.GetLogsDefault == nil { + return nil, &nonRetriableError{errors.New("fake for method GetLogsDefault not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/logs/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + tailUnescaped, err := url.QueryUnescape(qp.Get("tail")) + if err != nil { + return nil, err + } + tailParam, err := parseOptional(tailUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *deploymentscripts.ClientGetLogsDefaultOptions + if tailParam != nil { + options = &deploymentscripts.ClientGetLogsDefaultOptions{ + Tail: tailParam, + } + } + respr, errRespr := s.srv.GetLogsDefault(req.Context(), resourceGroupNameParam, scriptNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ScriptLog, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := s.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + s.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *deploymentscripts.ClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + s.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := s.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + s.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *deploymentscripts.ClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + s.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if s.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentScripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[deploymentscripts.DeploymentScriptUpdateParameter](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Update(req.Context(), resourceGroupNameParam, scriptNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentScriptClassification, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/fake/server_factory.go b/sdk/resourcemanager/deployments/deploymentscripts/fake/server_factory.go new file mode 100644 index 000000000000..fcc32c98ac6f --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/fake/server_factory.go @@ -0,0 +1,73 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the deploymentscripts.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of deploymentscripts.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of deploymentscripts.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/go.mod b/sdk/resourcemanager/deployments/deploymentscripts/go.mod new file mode 100644 index 000000000000..9285edb9697f --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentscripts + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/deployments/deploymentscripts/go.sum b/sdk/resourcemanager/deployments/deploymentscripts/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/deployments/deploymentscripts/interfaces.go b/sdk/resourcemanager/deployments/deploymentscripts/interfaces.go new file mode 100644 index 000000000000..bb0bd4ec1c44 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/interfaces.go @@ -0,0 +1,15 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +// DeploymentScriptClassification provides polymorphic access to related types. +// Call the interface's GetDeploymentScript() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureCliScript, *AzurePowerShellScript, *DeploymentScript +type DeploymentScriptClassification interface { + // GetDeploymentScript returns the DeploymentScript content of the underlying type. + GetDeploymentScript() *DeploymentScript +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/models.go b/sdk/resourcemanager/deployments/deploymentscripts/models.go new file mode 100644 index 000000000000..7a6901c831dd --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/models.go @@ -0,0 +1,419 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +import "time" + +// AzureCliScript - Object model for the Azure CLI script. +type AzureCliScript struct { + // REQUIRED; Type of the script. + Kind *ScriptType + + // REQUIRED; The location of the ACI and the storage account for the deployment script. + Location *string + + // REQUIRED; Properties of the Azure CLI script object. + Properties *AzureCliScriptProperties + + // Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. + Identity *ManagedServiceIdentity + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; The system metadata related to this resource. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// GetDeploymentScript implements the DeploymentScriptClassification interface for type AzureCliScript. +func (a *AzureCliScript) GetDeploymentScript() *DeploymentScript { + return &DeploymentScript{ + ID: a.ID, + Identity: a.Identity, + Kind: a.Kind, + Location: a.Location, + Name: a.Name, + SystemData: a.SystemData, + Tags: a.Tags, + Type: a.Type, + } +} + +// AzureCliScriptProperties - Properties of the Azure CLI script object. +type AzureCliScriptProperties struct { + // REQUIRED; Azure CLI module version to be used. + AzCliVersion *string + + // REQUIRED; Interval for which the service retains the script resource after it reaches a terminal state. Resource will be + // deleted when this duration expires. Duration is based on ISO 8601 pattern (for example + // P1D means one day). + RetentionInterval *string + + // Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2' + Arguments *string + + // The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. + CleanupPreference *CleanupOptions + + // Container settings. + ContainerSettings *ContainerConfiguration + + // The environment variables to pass over to the script. + EnvironmentVariables []*EnvironmentVariable + + // Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be + // current time stamp or a GUID. + ForceUpdateTag *string + + // Uri for the script. This is the entry point for the external script. + PrimaryScriptURI *string + + // Script body. + ScriptContent *string + + // Storage Account settings. + StorageAccountSettings *StorageAccountConfiguration + + // Supporting files for the external script. + SupportingScriptUris []*string + + // Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D + Timeout *string + + // READ-ONLY; List of script outputs. + Outputs map[string]any + + // READ-ONLY; State of the script execution. This only appears in the response. + ProvisioningState *ScriptProvisioningState + + // READ-ONLY; Contains the results of script execution. + Status *ScriptStatus +} + +// AzurePowerShellScript - Object model for the Azure PowerShell script. +type AzurePowerShellScript struct { + // REQUIRED; Type of the script. + Kind *ScriptType + + // REQUIRED; The location of the ACI and the storage account for the deployment script. + Location *string + + // REQUIRED; Properties of the Azure PowerShell script object. + Properties *AzurePowerShellScriptProperties + + // Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. + Identity *ManagedServiceIdentity + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; The system metadata related to this resource. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// GetDeploymentScript implements the DeploymentScriptClassification interface for type AzurePowerShellScript. +func (a *AzurePowerShellScript) GetDeploymentScript() *DeploymentScript { + return &DeploymentScript{ + ID: a.ID, + Identity: a.Identity, + Kind: a.Kind, + Location: a.Location, + Name: a.Name, + SystemData: a.SystemData, + Tags: a.Tags, + Type: a.Type, + } +} + +// AzurePowerShellScriptProperties - Properties of the Azure PowerShell script object. +type AzurePowerShellScriptProperties struct { + // REQUIRED; Azure PowerShell module version to be used. + AzPowerShellVersion *string + + // REQUIRED; Interval for which the service retains the script resource after it reaches a terminal state. Resource will be + // deleted when this duration expires. Duration is based on ISO 8601 pattern (for example + // P1D means one day). + RetentionInterval *string + + // Command line arguments to pass to the script. Arguments are separated by spaces. ex: -Name blue* -Location 'West US 2' + Arguments *string + + // The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. + CleanupPreference *CleanupOptions + + // Container settings. + ContainerSettings *ContainerConfiguration + + // The environment variables to pass over to the script. + EnvironmentVariables []*EnvironmentVariable + + // Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be + // current time stamp or a GUID. + ForceUpdateTag *string + + // Uri for the script. This is the entry point for the external script. + PrimaryScriptURI *string + + // Script body. + ScriptContent *string + + // Storage Account settings. + StorageAccountSettings *StorageAccountConfiguration + + // Supporting files for the external script. + SupportingScriptUris []*string + + // Maximum allowed script execution time specified in ISO 8601 format. Default value is P1D + Timeout *string + + // READ-ONLY; List of script outputs. + Outputs map[string]any + + // READ-ONLY; State of the script execution. This only appears in the response. + ProvisioningState *ScriptProvisioningState + + // READ-ONLY; Contains the results of script execution. + Status *ScriptStatus +} + +// ContainerConfiguration - Settings to customize ACI container instance. +type ContainerConfiguration struct { + // Container group name, if not specified then the name will get auto-generated. Not specifying a 'containerGroupName' indicates + // the system to generate a unique name which might end up flagging an Azure + // Policy as non-compliant. Use 'containerGroupName' when you have an Azure Policy that expects a specific naming convention + // or when you want to fully control the name. 'containerGroupName' property must + // be between 1 and 63 characters long, must contain only lowercase letters, numbers, and dashes and it cannot start or end + // with a dash and consecutive dashes are not allowed. To specify a + // 'containerGroupName', add the following object to properties: { "containerSettings": { "containerGroupName": "contoso-container" + // } }. If you do not want to specify a 'containerGroupName' then do not + // add 'containerSettings' property. + ContainerGroupName *string + + // The subnet resource IDs for a container group. + SubnetIDs []*ContainerGroupSubnetID +} + +// ContainerGroupSubnetID - Container group subnet information. +type ContainerGroupSubnetID struct { + // REQUIRED; Resource ID of subnet. + ID *string + + // Friendly name for the subnet. + Name *string +} + +// DeploymentScript - Deployment script object. +type DeploymentScript struct { + // REQUIRED; Type of the script. + Kind *ScriptType + + // REQUIRED; The location of the ACI and the storage account for the deployment script. + Location *string + + // Optional property. Managed identity to be used for this deployment script. Currently, only user-assigned MSI is supported. + Identity *ManagedServiceIdentity + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; The system metadata related to this resource. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// GetDeploymentScript implements the DeploymentScriptClassification interface for type DeploymentScript. +func (d *DeploymentScript) GetDeploymentScript() *DeploymentScript { return d } + +// DeploymentScriptListResult - List of deployment scripts. +type DeploymentScriptListResult struct { + // An array of deployment scripts. + Value []DeploymentScriptClassification + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} + +// DeploymentScriptUpdateParameter - Deployment script parameters to be updated. +type DeploymentScriptUpdateParameter struct { + // Resource tags to be updated. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Type of this resource. + Type *string +} + +// EnvironmentVariable - The environment variable to pass to the script in the container instance. +type EnvironmentVariable struct { + // REQUIRED; The name of the environment variable. + Name *string + + // The value of the secure environment variable. + SecureValue *string + + // The value of the environment variable. + Value *string +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.) +type ErrorResponse struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorResponse + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// LogProperties - Script log properties. +type LogProperties struct { + // READ-ONLY; Script execution logs in text format. + Log *string +} + +// ManagedServiceIdentity - Managed identity generic object. +type ManagedServiceIdentity struct { + // Type of the managed identity. + Type *ManagedServiceIdentityType + + // The list of user-assigned managed identities associated with the resource. Key is the Azure resource Id of the managed + // identity. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; ID of the Azure Active Directory. + TenantID *string +} + +// ScriptLog - Script execution log object. +type ScriptLog struct { + // Script log properties. + Properties *LogProperties + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Type of this resource. + Type *string +} + +// ScriptLogsList - Deployment script execution logs. +type ScriptLogsList struct { + // Deployment scripts logs. + Value []*ScriptLog +} + +// ScriptStatus - Generic object modeling results of script execution. +type ScriptStatus struct { + // Error that is relayed from the script execution. + Error *ErrorResponse + + // READ-ONLY; ACI resource Id. + ContainerInstanceID *string + + // READ-ONLY; End time of the script execution. + EndTime *time.Time + + // READ-ONLY; Time the deployment script resource will expire. + ExpirationTime *time.Time + + // READ-ONLY; Start time of the script execution. + StartTime *time.Time + + // READ-ONLY; Storage account resource Id. + StorageAccountID *string +} + +// StorageAccountConfiguration - Settings to use an existing storage account. Valid storage account kinds are: Storage, StorageV2 +// and FileStorage +type StorageAccountConfiguration struct { + // The storage account access key. + StorageAccountKey *string + + // The storage account name. + StorageAccountName *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// UserAssignedIdentity - User-assigned managed identity. +type UserAssignedIdentity struct { + // READ-ONLY; Client App Id associated with this identity. + ClientID *string + + // READ-ONLY; Azure Active Directory principal ID associated with this identity. + PrincipalID *string +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/models_serde.go b/sdk/resourcemanager/deployments/deploymentscripts/models_serde.go new file mode 100644 index 000000000000..6e07b3c73212 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/models_serde.go @@ -0,0 +1,907 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AzureCliScript. +func (a AzureCliScript) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "identity", a.Identity) + objectMap["kind"] = ScriptTypeAzureCLI + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureCliScript. +func (a *AzureCliScript) 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 "identity": + err = unpopulate(val, "Identity", &a.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + 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 "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + 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 AzureCliScriptProperties. +func (a AzureCliScriptProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "arguments", a.Arguments) + populate(objectMap, "azCliVersion", a.AzCliVersion) + populate(objectMap, "cleanupPreference", a.CleanupPreference) + populate(objectMap, "containerSettings", a.ContainerSettings) + populate(objectMap, "environmentVariables", a.EnvironmentVariables) + populate(objectMap, "forceUpdateTag", a.ForceUpdateTag) + populate(objectMap, "outputs", a.Outputs) + populate(objectMap, "primaryScriptUri", a.PrimaryScriptURI) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "retentionInterval", a.RetentionInterval) + populate(objectMap, "scriptContent", a.ScriptContent) + populate(objectMap, "status", a.Status) + populate(objectMap, "storageAccountSettings", a.StorageAccountSettings) + populate(objectMap, "supportingScriptUris", a.SupportingScriptUris) + populate(objectMap, "timeout", a.Timeout) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureCliScriptProperties. +func (a *AzureCliScriptProperties) 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 "arguments": + err = unpopulate(val, "Arguments", &a.Arguments) + delete(rawMsg, key) + case "azCliVersion": + err = unpopulate(val, "AzCliVersion", &a.AzCliVersion) + delete(rawMsg, key) + case "cleanupPreference": + err = unpopulate(val, "CleanupPreference", &a.CleanupPreference) + delete(rawMsg, key) + case "containerSettings": + err = unpopulate(val, "ContainerSettings", &a.ContainerSettings) + delete(rawMsg, key) + case "environmentVariables": + err = unpopulate(val, "EnvironmentVariables", &a.EnvironmentVariables) + delete(rawMsg, key) + case "forceUpdateTag": + err = unpopulate(val, "ForceUpdateTag", &a.ForceUpdateTag) + delete(rawMsg, key) + case "outputs": + err = unpopulate(val, "Outputs", &a.Outputs) + delete(rawMsg, key) + case "primaryScriptUri": + err = unpopulate(val, "PrimaryScriptURI", &a.PrimaryScriptURI) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "retentionInterval": + err = unpopulate(val, "RetentionInterval", &a.RetentionInterval) + delete(rawMsg, key) + case "scriptContent": + err = unpopulate(val, "ScriptContent", &a.ScriptContent) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "storageAccountSettings": + err = unpopulate(val, "StorageAccountSettings", &a.StorageAccountSettings) + delete(rawMsg, key) + case "supportingScriptUris": + err = unpopulate(val, "SupportingScriptUris", &a.SupportingScriptUris) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, "Timeout", &a.Timeout) + 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 AzurePowerShellScript. +func (a AzurePowerShellScript) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "identity", a.Identity) + objectMap["kind"] = ScriptTypeAzurePowerShell + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzurePowerShellScript. +func (a *AzurePowerShellScript) 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 "identity": + err = unpopulate(val, "Identity", &a.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + 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 "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + 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 AzurePowerShellScriptProperties. +func (a AzurePowerShellScriptProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "arguments", a.Arguments) + populate(objectMap, "azPowerShellVersion", a.AzPowerShellVersion) + populate(objectMap, "cleanupPreference", a.CleanupPreference) + populate(objectMap, "containerSettings", a.ContainerSettings) + populate(objectMap, "environmentVariables", a.EnvironmentVariables) + populate(objectMap, "forceUpdateTag", a.ForceUpdateTag) + populate(objectMap, "outputs", a.Outputs) + populate(objectMap, "primaryScriptUri", a.PrimaryScriptURI) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "retentionInterval", a.RetentionInterval) + populate(objectMap, "scriptContent", a.ScriptContent) + populate(objectMap, "status", a.Status) + populate(objectMap, "storageAccountSettings", a.StorageAccountSettings) + populate(objectMap, "supportingScriptUris", a.SupportingScriptUris) + populate(objectMap, "timeout", a.Timeout) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzurePowerShellScriptProperties. +func (a *AzurePowerShellScriptProperties) 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 "arguments": + err = unpopulate(val, "Arguments", &a.Arguments) + delete(rawMsg, key) + case "azPowerShellVersion": + err = unpopulate(val, "AzPowerShellVersion", &a.AzPowerShellVersion) + delete(rawMsg, key) + case "cleanupPreference": + err = unpopulate(val, "CleanupPreference", &a.CleanupPreference) + delete(rawMsg, key) + case "containerSettings": + err = unpopulate(val, "ContainerSettings", &a.ContainerSettings) + delete(rawMsg, key) + case "environmentVariables": + err = unpopulate(val, "EnvironmentVariables", &a.EnvironmentVariables) + delete(rawMsg, key) + case "forceUpdateTag": + err = unpopulate(val, "ForceUpdateTag", &a.ForceUpdateTag) + delete(rawMsg, key) + case "outputs": + err = unpopulate(val, "Outputs", &a.Outputs) + delete(rawMsg, key) + case "primaryScriptUri": + err = unpopulate(val, "PrimaryScriptURI", &a.PrimaryScriptURI) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "retentionInterval": + err = unpopulate(val, "RetentionInterval", &a.RetentionInterval) + delete(rawMsg, key) + case "scriptContent": + err = unpopulate(val, "ScriptContent", &a.ScriptContent) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "storageAccountSettings": + err = unpopulate(val, "StorageAccountSettings", &a.StorageAccountSettings) + delete(rawMsg, key) + case "supportingScriptUris": + err = unpopulate(val, "SupportingScriptUris", &a.SupportingScriptUris) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, "Timeout", &a.Timeout) + 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 ContainerConfiguration. +func (c ContainerConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "containerGroupName", c.ContainerGroupName) + populate(objectMap, "subnetIds", c.SubnetIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerConfiguration. +func (c *ContainerConfiguration) 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 "containerGroupName": + err = unpopulate(val, "ContainerGroupName", &c.ContainerGroupName) + delete(rawMsg, key) + case "subnetIds": + err = unpopulate(val, "SubnetIDs", &c.SubnetIDs) + 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 ContainerGroupSubnetID. +func (c ContainerGroupSubnetID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupSubnetID. +func (c *ContainerGroupSubnetID) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentScript. +func (d DeploymentScript) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "identity", d.Identity) + objectMap["kind"] = d.Kind + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentScript. +func (d *DeploymentScript) 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 "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &d.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &d.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + 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 DeploymentScriptListResult. +func (d DeploymentScriptListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentScriptListResult. +func (d *DeploymentScriptListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + d.Value, err = unmarshalDeploymentScriptClassificationArray(val) + 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 DeploymentScriptUpdateParameter. +func (d DeploymentScriptUpdateParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentScriptUpdateParameter. +func (d *DeploymentScriptUpdateParameter) 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 "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + 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 EnvironmentVariable. +func (e EnvironmentVariable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", e.Name) + populate(objectMap, "secureValue", e.SecureValue) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentVariable. +func (e *EnvironmentVariable) 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 "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "secureValue": + err = unpopulate(val, "SecureValue", &e.SecureValue) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(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 ErrorResponse. +func (e ErrorResponse) 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 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 "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 LogProperties. +func (l LogProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "log", l.Log) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogProperties. +func (l *LogProperties) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "log": + err = unpopulate(val, "Log", &l.Log) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) 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 "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + 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 ScriptLog. +func (s ScriptLog) 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 ScriptLog. +func (s *ScriptLog) 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 ScriptLogsList. +func (s ScriptLogsList) 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 ScriptLogsList. +func (s *ScriptLogsList) 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 ScriptStatus. +func (s ScriptStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "containerInstanceId", s.ContainerInstanceID) + populateDateTimeRFC3339(objectMap, "endTime", s.EndTime) + populate(objectMap, "error", s.Error) + populateDateTimeRFC3339(objectMap, "expirationTime", s.ExpirationTime) + populateDateTimeRFC3339(objectMap, "startTime", s.StartTime) + populate(objectMap, "storageAccountId", s.StorageAccountID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptStatus. +func (s *ScriptStatus) 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 "containerInstanceId": + err = unpopulate(val, "ContainerInstanceID", &s.ContainerInstanceID) + delete(rawMsg, key) + case "endTime": + err = unpopulateDateTimeRFC3339(val, "EndTime", &s.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &s.Error) + delete(rawMsg, key) + case "expirationTime": + err = unpopulateDateTimeRFC3339(val, "ExpirationTime", &s.ExpirationTime) + delete(rawMsg, key) + case "startTime": + err = unpopulateDateTimeRFC3339(val, "StartTime", &s.StartTime) + delete(rawMsg, key) + case "storageAccountId": + err = unpopulate(val, "StorageAccountID", &s.StorageAccountID) + 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 StorageAccountConfiguration. +func (s StorageAccountConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storageAccountKey", s.StorageAccountKey) + populate(objectMap, "storageAccountName", s.StorageAccountName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageAccountConfiguration. +func (s *StorageAccountConfiguration) 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 "storageAccountKey": + err = unpopulate(val, "StorageAccountKey", &s.StorageAccountKey) + delete(rawMsg, key) + case "storageAccountName": + err = unpopulate(val, "StorageAccountName", &s.StorageAccountName) + 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 SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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 "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + 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 UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) 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 "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + 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 populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + 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/deployments/deploymentscripts/options.go b/sdk/resourcemanager/deployments/deploymentscripts/options.go new file mode 100644 index 000000000000..c73432d238b6 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/options.go @@ -0,0 +1,50 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +// ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +type ClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientDeleteOptions contains the optional parameters for the Client.Delete method. +type ClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ClientGetLogsDefaultOptions contains the optional parameters for the Client.GetLogsDefault method. +type ClientGetLogsDefaultOptions struct { + // The number of lines to show from the tail of the deployment script log. Valid value is a positive number up to 1000. If + // 'tail' is not provided, all available logs are shown up to container instance + // log capacity of 4mb. + Tail *int32 +} + +// ClientGetLogsOptions contains the optional parameters for the Client.GetLogs method. +type ClientGetLogsOptions struct { + // placeholder for future optional parameters +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager method. +type ClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. +type ClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ClientUpdateOptions contains the optional parameters for the Client.Update method. +type ClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/polymorphic_helpers.go b/sdk/resourcemanager/deployments/deploymentscripts/polymorphic_helpers.go new file mode 100644 index 000000000000..c1eea968fce7 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/polymorphic_helpers.go @@ -0,0 +1,50 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +import "encoding/json" + +func unmarshalDeploymentScriptClassification(rawMsg json.RawMessage) (DeploymentScriptClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DeploymentScriptClassification + switch m["kind"] { + case string(ScriptTypeAzureCLI): + b = &AzureCliScript{} + case string(ScriptTypeAzurePowerShell): + b = &AzurePowerShellScript{} + default: + b = &DeploymentScript{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalDeploymentScriptClassificationArray(rawMsg json.RawMessage) ([]DeploymentScriptClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]DeploymentScriptClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalDeploymentScriptClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/responses.go b/sdk/resourcemanager/deployments/deploymentscripts/responses.go new file mode 100644 index 000000000000..60f291e28cfc --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/responses.go @@ -0,0 +1,53 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +// ClientCreateResponse contains the response from method Client.BeginCreate. +type ClientCreateResponse struct { + // Deployment script object. + DeploymentScriptClassification +} + +// ClientDeleteResponse contains the response from method Client.Delete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientGetLogsDefaultResponse contains the response from method Client.GetLogsDefault. +type ClientGetLogsDefaultResponse struct { + // Script execution log object. + ScriptLog +} + +// ClientGetLogsResponse contains the response from method Client.GetLogs. +type ClientGetLogsResponse struct { + // Deployment script execution logs. + ScriptLogsList +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // Deployment script object. + DeploymentScriptClassification +} + +// ClientListByResourceGroupResponse contains the response from method Client.NewListByResourceGroupPager. +type ClientListByResourceGroupResponse struct { + // List of deployment scripts. + DeploymentScriptListResult +} + +// ClientListBySubscriptionResponse contains the response from method Client.NewListBySubscriptionPager. +type ClientListBySubscriptionResponse struct { + // List of deployment scripts. + DeploymentScriptListResult +} + +// ClientUpdateResponse contains the response from method Client.Update. +type ClientUpdateResponse struct { + // Deployment script object. + DeploymentScriptClassification +} diff --git a/sdk/resourcemanager/deployments/deploymentscripts/responses_serde.go b/sdk/resourcemanager/deployments/deploymentscripts/responses_serde.go new file mode 100644 index 000000000000..4c685913bbc1 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentscripts/responses_serde.go @@ -0,0 +1,43 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentscripts + +import "encoding/json" + +// MarshalJSON implements the json.Marshaller interface for type ClientCreateResponse. +func (c ClientCreateResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(c.DeploymentScriptClassification) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClientCreateResponse. +func (c *ClientCreateResponse) UnmarshalJSON(data []byte) error { + res, err := unmarshalDeploymentScriptClassification(data) + if err != nil { + return err + } + c.DeploymentScriptClassification = res + return nil +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClientGetResponse. +func (c *ClientGetResponse) UnmarshalJSON(data []byte) error { + res, err := unmarshalDeploymentScriptClassification(data) + if err != nil { + return err + } + c.DeploymentScriptClassification = res + return nil +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClientUpdateResponse. +func (c *ClientUpdateResponse) UnmarshalJSON(data []byte) error { + res, err := unmarshalDeploymentScriptClassification(data) + if err != nil { + return err + } + c.DeploymentScriptClassification = res + return nil +} diff --git a/sdk/resourcemanager/resources/armfeatures/fake/time_rfc3339.go b/sdk/resourcemanager/deployments/deploymentscripts/time_rfc3339.go similarity index 58% rename from sdk/resourcemanager/resources/armfeatures/fake/time_rfc3339.go rename to sdk/resourcemanager/deployments/deploymentscripts/time_rfc3339.go index b0535a7b63e6..c5aee2780242 100644 --- a/sdk/resourcemanager/resources/armfeatures/fake/time_rfc3339.go +++ b/sdk/resourcemanager/deployments/deploymentscripts/time_rfc3339.go @@ -1,12 +1,9 @@ -//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. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package fake +package deploymentscripts import ( "encoding/json" @@ -19,12 +16,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +41,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/deployments/deploymentstacks/CHANGELOG.md b/sdk/resourcemanager/deployments/deploymentstacks/CHANGELOG.md new file mode 100644 index 000000000000..e380b110ea9f --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-04-28) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentstacks` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentstacks/LICENSE.txt b/sdk/resourcemanager/deployments/deploymentstacks/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentstacks/README.md b/sdk/resourcemanager/deployments/deploymentstacks/README.md new file mode 100644 index 000000000000..6f03622003b3 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/README.md @@ -0,0 +1,90 @@ +# Azure Deployments Module for Go + +The `deploymentstacks` module provides operations for working with Azure Deployments. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/deployments/deploymentstacks) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Deployments module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentstacks +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Deployments. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +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). + +## Client Factory + +Azure Deployments module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := deploymentstacks.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 { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := deploymentstacks.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() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Deployments` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentstacks/autorest.md b/sdk/resourcemanager/deployments/deploymentstacks/autorest.md new file mode 100644 index 000000000000..045a26f8eefe --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/deploymentStacks/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/deploymentStacks/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/deploymentstacks/build.go b/sdk/resourcemanager/deployments/deploymentstacks/build.go new file mode 100644 index 000000000000..7711ca34acd7 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/deployments/deploymentstacks + +package deploymentstacks diff --git a/sdk/resourcemanager/deployments/deploymentstacks/ci.yml b/sdk/resourcemanager/deployments/deploymentstacks/ci.yml new file mode 100644 index 000000000000..d2dedbab500c --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/deploymentstacks/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/deploymentstacks/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/deployments/deploymentstacks' diff --git a/sdk/resourcemanager/deployments/deploymentstacks/client.go b/sdk/resourcemanager/deployments/deploymentstacks/client.go new file mode 100644 index 000000000000..aa7ee4681d74 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/client.go @@ -0,0 +1,1319 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentstacks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// Client contains the methods for the DeploymentStacks group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdateAtManagementGroup - Creates or updates a Deployment stack at Management Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - managementGroupID - Management Group id. +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment stack supplied to the operation. +// - options - ClientBeginCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtManagementGroup +// method. +func (client *Client) BeginCreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtManagementGroupOptions) (*runtime.Poller[ClientCreateOrUpdateAtManagementGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateAtManagementGroup(ctx, managementGroupID, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtManagementGroupResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateAtManagementGroupResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateAtManagementGroup - Creates or updates a Deployment stack at Management Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) createOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtManagementGroupOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginCreateOrUpdateAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. +func (client *Client) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, _ *ClientBeginCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdateAtResourceGroup - Creates or updates a Deployment stack at Resource Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment stack supplied to the operation. +// - options - ClientBeginCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtResourceGroup +// method. +func (client *Client) BeginCreateOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtResourceGroupOptions) (*runtime.Poller[ClientCreateOrUpdateAtResourceGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateAtResourceGroup(ctx, resourceGroupName, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtResourceGroupResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateAtResourceGroupResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateAtResourceGroup - Creates or updates a Deployment stack at Resource Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) createOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtResourceGroupOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginCreateOrUpdateAtResourceGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateAtResourceGroupCreateRequest creates the CreateOrUpdateAtResourceGroup request. +func (client *Client) createOrUpdateAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, _ *ClientBeginCreateOrUpdateAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdateAtSubscription - Creates or updates a Deployment stack at Subscription scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment stack supplied to the operation. +// - options - ClientBeginCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtSubscription +// method. +func (client *Client) BeginCreateOrUpdateAtSubscription(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtSubscriptionOptions) (*runtime.Poller[ClientCreateOrUpdateAtSubscriptionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateAtSubscription(ctx, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtSubscriptionResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateOrUpdateAtSubscriptionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateAtSubscription - Creates or updates a Deployment stack at Subscription scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) createOrUpdateAtSubscription(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtSubscriptionOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginCreateOrUpdateAtSubscription" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateAtSubscriptionCreateRequest(ctx, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateAtSubscriptionCreateRequest creates the CreateOrUpdateAtSubscription request. +func (client *Client) createOrUpdateAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, _ *ClientBeginCreateOrUpdateAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginDeleteAtManagementGroup - Deletes a Deployment stack by name at Management Group scope. When operation completes, +// status code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - managementGroupID - Management Group id. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientBeginDeleteAtManagementGroupOptions contains the optional parameters for the Client.BeginDeleteAtManagementGroup +// method. +func (client *Client) BeginDeleteAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientBeginDeleteAtManagementGroupOptions) (*runtime.Poller[ClientDeleteAtManagementGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAtManagementGroup(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtManagementGroupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAtManagementGroupResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteAtManagementGroup - Deletes a Deployment stack by name at Management Group scope. When operation completes, status +// code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) deleteAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientBeginDeleteAtManagementGroupOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginDeleteAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. +func (client *Client) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientBeginDeleteAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if options != nil && options.BypassStackOutOfSyncError != nil { + reqQP.Set("bypassStackOutOfSyncError", strconv.FormatBool(*options.BypassStackOutOfSyncError)) + } + if options != nil && options.UnmanageActionManagementGroups != nil { + reqQP.Set("unmanageAction.ManagementGroups", string(*options.UnmanageActionManagementGroups)) + } + if options != nil && options.UnmanageActionResourceGroups != nil { + reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) + } + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDeleteAtResourceGroup - Deletes a Deployment stack by name at Resource Group scope. When operation completes, status +// code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientBeginDeleteAtResourceGroupOptions contains the optional parameters for the Client.BeginDeleteAtResourceGroup +// method. +func (client *Client) BeginDeleteAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientBeginDeleteAtResourceGroupOptions) (*runtime.Poller[ClientDeleteAtResourceGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAtResourceGroup(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtResourceGroupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAtResourceGroupResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteAtResourceGroup - Deletes a Deployment stack by name at Resource Group scope. When operation completes, status code +// 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) deleteAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientBeginDeleteAtResourceGroupOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginDeleteAtResourceGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteAtResourceGroupCreateRequest creates the DeleteAtResourceGroup request. +func (client *Client) deleteAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientBeginDeleteAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if options != nil && options.BypassStackOutOfSyncError != nil { + reqQP.Set("bypassStackOutOfSyncError", strconv.FormatBool(*options.BypassStackOutOfSyncError)) + } + if options != nil && options.UnmanageActionManagementGroups != nil { + reqQP.Set("unmanageAction.ManagementGroups", string(*options.UnmanageActionManagementGroups)) + } + if options != nil && options.UnmanageActionResourceGroups != nil { + reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) + } + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDeleteAtSubscription - Deletes a Deployment stack by name at Subscription scope. When operation completes, status +// code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - deploymentStackName - Name of the deployment stack. +// - options - ClientBeginDeleteAtSubscriptionOptions contains the optional parameters for the Client.BeginDeleteAtSubscription +// method. +func (client *Client) BeginDeleteAtSubscription(ctx context.Context, deploymentStackName string, options *ClientBeginDeleteAtSubscriptionOptions) (*runtime.Poller[ClientDeleteAtSubscriptionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAtSubscription(ctx, deploymentStackName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtSubscriptionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAtSubscriptionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteAtSubscription - Deletes a Deployment stack by name at Subscription scope. When operation completes, status code +// 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) deleteAtSubscription(ctx context.Context, deploymentStackName string, options *ClientBeginDeleteAtSubscriptionOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginDeleteAtSubscription" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteAtSubscriptionCreateRequest(ctx, deploymentStackName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteAtSubscriptionCreateRequest creates the DeleteAtSubscription request. +func (client *Client) deleteAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, options *ClientBeginDeleteAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if options != nil && options.BypassStackOutOfSyncError != nil { + reqQP.Set("bypassStackOutOfSyncError", strconv.FormatBool(*options.BypassStackOutOfSyncError)) + } + if options != nil && options.UnmanageActionManagementGroups != nil { + reqQP.Set("unmanageAction.ManagementGroups", string(*options.UnmanageActionManagementGroups)) + } + if options != nil && options.UnmanageActionResourceGroups != nil { + reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) + } + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// ExportTemplateAtManagementGroup - Exports the template used to create the Deployment stack at Management Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - managementGroupID - Management Group id. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientExportTemplateAtManagementGroupOptions contains the optional parameters for the Client.ExportTemplateAtManagementGroup +// method. +func (client *Client) ExportTemplateAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientExportTemplateAtManagementGroupOptions) (ClientExportTemplateAtManagementGroupResponse, error) { + var err error + const operationName = "Client.ExportTemplateAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.exportTemplateAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return ClientExportTemplateAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientExportTemplateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientExportTemplateAtManagementGroupResponse{}, err + } + resp, err := client.exportTemplateAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// exportTemplateAtManagementGroupCreateRequest creates the ExportTemplateAtManagementGroup request. +func (client *Client) exportTemplateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, _ *ClientExportTemplateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/exportTemplate" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// exportTemplateAtManagementGroupHandleResponse handles the ExportTemplateAtManagementGroup response. +func (client *Client) exportTemplateAtManagementGroupHandleResponse(resp *http.Response) (ClientExportTemplateAtManagementGroupResponse, error) { + result := ClientExportTemplateAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackTemplateDefinition); err != nil { + return ClientExportTemplateAtManagementGroupResponse{}, err + } + return result, nil +} + +// ExportTemplateAtResourceGroup - Exports the template used to create the Deployment stack at Resource Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientExportTemplateAtResourceGroupOptions contains the optional parameters for the Client.ExportTemplateAtResourceGroup +// method. +func (client *Client) ExportTemplateAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientExportTemplateAtResourceGroupOptions) (ClientExportTemplateAtResourceGroupResponse, error) { + var err error + const operationName = "Client.ExportTemplateAtResourceGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.exportTemplateAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return ClientExportTemplateAtResourceGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientExportTemplateAtResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientExportTemplateAtResourceGroupResponse{}, err + } + resp, err := client.exportTemplateAtResourceGroupHandleResponse(httpResp) + return resp, err +} + +// exportTemplateAtResourceGroupCreateRequest creates the ExportTemplateAtResourceGroup request. +func (client *Client) exportTemplateAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, _ *ClientExportTemplateAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/exportTemplate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// exportTemplateAtResourceGroupHandleResponse handles the ExportTemplateAtResourceGroup response. +func (client *Client) exportTemplateAtResourceGroupHandleResponse(resp *http.Response) (ClientExportTemplateAtResourceGroupResponse, error) { + result := ClientExportTemplateAtResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackTemplateDefinition); err != nil { + return ClientExportTemplateAtResourceGroupResponse{}, err + } + return result, nil +} + +// ExportTemplateAtSubscription - Exports the template used to create the Deployment stack at Subscription scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - deploymentStackName - Name of the deployment stack. +// - options - ClientExportTemplateAtSubscriptionOptions contains the optional parameters for the Client.ExportTemplateAtSubscription +// method. +func (client *Client) ExportTemplateAtSubscription(ctx context.Context, deploymentStackName string, options *ClientExportTemplateAtSubscriptionOptions) (ClientExportTemplateAtSubscriptionResponse, error) { + var err error + const operationName = "Client.ExportTemplateAtSubscription" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.exportTemplateAtSubscriptionCreateRequest(ctx, deploymentStackName, options) + if err != nil { + return ClientExportTemplateAtSubscriptionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientExportTemplateAtSubscriptionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientExportTemplateAtSubscriptionResponse{}, err + } + resp, err := client.exportTemplateAtSubscriptionHandleResponse(httpResp) + return resp, err +} + +// exportTemplateAtSubscriptionCreateRequest creates the ExportTemplateAtSubscription request. +func (client *Client) exportTemplateAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, _ *ClientExportTemplateAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/exportTemplate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// exportTemplateAtSubscriptionHandleResponse handles the ExportTemplateAtSubscription response. +func (client *Client) exportTemplateAtSubscriptionHandleResponse(resp *http.Response) (ClientExportTemplateAtSubscriptionResponse, error) { + result := ClientExportTemplateAtSubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackTemplateDefinition); err != nil { + return ClientExportTemplateAtSubscriptionResponse{}, err + } + return result, nil +} + +// GetAtManagementGroup - Gets a Deployment stack with a given name at Management Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - managementGroupID - Management Group id. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientGetAtManagementGroupOptions contains the optional parameters for the Client.GetAtManagementGroup method. +func (client *Client) GetAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientGetAtManagementGroupOptions) (ClientGetAtManagementGroupResponse, error) { + var err error + const operationName = "Client.GetAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return ClientGetAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetAtManagementGroupResponse{}, err + } + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. +func (client *Client) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, _ *ClientGetAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. +func (client *Client) getAtManagementGroupHandleResponse(resp *http.Response) (ClientGetAtManagementGroupResponse, error) { + result := ClientGetAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStack); err != nil { + return ClientGetAtManagementGroupResponse{}, err + } + return result, nil +} + +// GetAtResourceGroup - Gets a Deployment stack with a given name at Resource Group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientGetAtResourceGroupOptions contains the optional parameters for the Client.GetAtResourceGroup method. +func (client *Client) GetAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientGetAtResourceGroupOptions) (ClientGetAtResourceGroupResponse, error) { + var err error + const operationName = "Client.GetAtResourceGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return ClientGetAtResourceGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetAtResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetAtResourceGroupResponse{}, err + } + resp, err := client.getAtResourceGroupHandleResponse(httpResp) + return resp, err +} + +// getAtResourceGroupCreateRequest creates the GetAtResourceGroup request. +func (client *Client) getAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, _ *ClientGetAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtResourceGroupHandleResponse handles the GetAtResourceGroup response. +func (client *Client) getAtResourceGroupHandleResponse(resp *http.Response) (ClientGetAtResourceGroupResponse, error) { + result := ClientGetAtResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStack); err != nil { + return ClientGetAtResourceGroupResponse{}, err + } + return result, nil +} + +// GetAtSubscription - Gets a Deployment stack with a given name at Subscription scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - deploymentStackName - Name of the deployment stack. +// - options - ClientGetAtSubscriptionOptions contains the optional parameters for the Client.GetAtSubscription method. +func (client *Client) GetAtSubscription(ctx context.Context, deploymentStackName string, options *ClientGetAtSubscriptionOptions) (ClientGetAtSubscriptionResponse, error) { + var err error + const operationName = "Client.GetAtSubscription" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getAtSubscriptionCreateRequest(ctx, deploymentStackName, options) + if err != nil { + return ClientGetAtSubscriptionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetAtSubscriptionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetAtSubscriptionResponse{}, err + } + resp, err := client.getAtSubscriptionHandleResponse(httpResp) + return resp, err +} + +// getAtSubscriptionCreateRequest creates the GetAtSubscription request. +func (client *Client) getAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, _ *ClientGetAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtSubscriptionHandleResponse handles the GetAtSubscription response. +func (client *Client) getAtSubscriptionHandleResponse(resp *http.Response) (ClientGetAtSubscriptionResponse, error) { + result := ClientGetAtSubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStack); err != nil { + return ClientGetAtSubscriptionResponse{}, err + } + return result, nil +} + +// NewListAtManagementGroupPager - Lists all the Deployment stacks within the specified Management Group. +// +// Generated from API version 2024-03-01 +// - managementGroupID - Management Group id. +// - options - ClientListAtManagementGroupOptions contains the optional parameters for the Client.NewListAtManagementGroupPager +// method. +func (client *Client) NewListAtManagementGroupPager(managementGroupID string, options *ClientListAtManagementGroupOptions) *runtime.Pager[ClientListAtManagementGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtManagementGroupResponse]{ + More: func(page ClientListAtManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListAtManagementGroupResponse) (ClientListAtManagementGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListAtManagementGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listAtManagementGroupCreateRequest(ctx, managementGroupID, options) + }, nil) + if err != nil { + return ClientListAtManagementGroupResponse{}, err + } + return client.listAtManagementGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listAtManagementGroupCreateRequest creates the ListAtManagementGroup request. +func (client *Client) listAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, _ *ClientListAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAtManagementGroupHandleResponse handles the ListAtManagementGroup response. +func (client *Client) listAtManagementGroupHandleResponse(resp *http.Response) (ClientListAtManagementGroupResponse, error) { + result := ClientListAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackListResult); err != nil { + return ClientListAtManagementGroupResponse{}, err + } + return result, nil +} + +// NewListAtResourceGroupPager - Lists all the Deployment stacks within the specified Resource Group. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ClientListAtResourceGroupOptions contains the optional parameters for the Client.NewListAtResourceGroupPager +// method. +func (client *Client) NewListAtResourceGroupPager(resourceGroupName string, options *ClientListAtResourceGroupOptions) *runtime.Pager[ClientListAtResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtResourceGroupResponse]{ + More: func(page ClientListAtResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListAtResourceGroupResponse) (ClientListAtResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListAtResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listAtResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ClientListAtResourceGroupResponse{}, err + } + return client.listAtResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listAtResourceGroupCreateRequest creates the ListAtResourceGroup request. +func (client *Client) listAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ClientListAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAtResourceGroupHandleResponse handles the ListAtResourceGroup response. +func (client *Client) listAtResourceGroupHandleResponse(resp *http.Response) (ClientListAtResourceGroupResponse, error) { + result := ClientListAtResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackListResult); err != nil { + return ClientListAtResourceGroupResponse{}, err + } + return result, nil +} + +// NewListAtSubscriptionPager - Lists all the Deployment stacks within the specified Subscription. +// +// Generated from API version 2024-03-01 +// - options - ClientListAtSubscriptionOptions contains the optional parameters for the Client.NewListAtSubscriptionPager method. +func (client *Client) NewListAtSubscriptionPager(options *ClientListAtSubscriptionOptions) *runtime.Pager[ClientListAtSubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtSubscriptionResponse]{ + More: func(page ClientListAtSubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListAtSubscriptionResponse) (ClientListAtSubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListAtSubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listAtSubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return ClientListAtSubscriptionResponse{}, err + } + return client.listAtSubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listAtSubscriptionCreateRequest creates the ListAtSubscription request. +func (client *Client) listAtSubscriptionCreateRequest(ctx context.Context, _ *ClientListAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks" + if client.subscriptionID == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAtSubscriptionHandleResponse handles the ListAtSubscription response. +func (client *Client) listAtSubscriptionHandleResponse(resp *http.Response) (ClientListAtSubscriptionResponse, error) { + result := ClientListAtSubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackListResult); err != nil { + return ClientListAtSubscriptionResponse{}, err + } + return result, nil +} + +// BeginValidateStackAtManagementGroup - Runs preflight validation on the Management Group scoped Deployment stack template +// to verify its acceptance to Azure Resource Manager. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - managementGroupID - Management Group id. +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment stack to validate. +// - options - ClientBeginValidateStackAtManagementGroupOptions contains the optional parameters for the Client.BeginValidateStackAtManagementGroup +// method. +func (client *Client) BeginValidateStackAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginValidateStackAtManagementGroupOptions) (*runtime.Poller[ClientValidateStackAtManagementGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.validateStackAtManagementGroup(ctx, managementGroupID, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateStackAtManagementGroupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateStackAtManagementGroupResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ValidateStackAtManagementGroup - Runs preflight validation on the Management Group scoped Deployment stack template to +// verify its acceptance to Azure Resource Manager. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) validateStackAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginValidateStackAtManagementGroupOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginValidateStackAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateStackAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusBadRequest) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// validateStackAtManagementGroupCreateRequest creates the ValidateStackAtManagementGroup request. +func (client *Client) validateStackAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, _ *ClientBeginValidateStackAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/validate" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginValidateStackAtResourceGroup - Runs preflight validation on the Resource Group scoped Deployment stack template to +// verify its acceptance to Azure Resource Manager. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment stack to validate. +// - options - ClientBeginValidateStackAtResourceGroupOptions contains the optional parameters for the Client.BeginValidateStackAtResourceGroup +// method. +func (client *Client) BeginValidateStackAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginValidateStackAtResourceGroupOptions) (*runtime.Poller[ClientValidateStackAtResourceGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.validateStackAtResourceGroup(ctx, resourceGroupName, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateStackAtResourceGroupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateStackAtResourceGroupResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ValidateStackAtResourceGroup - Runs preflight validation on the Resource Group scoped Deployment stack template to verify +// its acceptance to Azure Resource Manager. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) validateStackAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginValidateStackAtResourceGroupOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginValidateStackAtResourceGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateStackAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusBadRequest) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// validateStackAtResourceGroupCreateRequest creates the ValidateStackAtResourceGroup request. +func (client *Client) validateStackAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, _ *ClientBeginValidateStackAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/validate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginValidateStackAtSubscription - Runs preflight validation on the Subscription scoped Deployment stack template to verify +// its acceptance to Azure Resource Manager. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment stack to validate. +// - options - ClientBeginValidateStackAtSubscriptionOptions contains the optional parameters for the Client.BeginValidateStackAtSubscription +// method. +func (client *Client) BeginValidateStackAtSubscription(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginValidateStackAtSubscriptionOptions) (*runtime.Poller[ClientValidateStackAtSubscriptionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.validateStackAtSubscription(ctx, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientValidateStackAtSubscriptionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientValidateStackAtSubscriptionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ValidateStackAtSubscription - Runs preflight validation on the Subscription scoped Deployment stack template to verify +// its acceptance to Azure Resource Manager. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *Client) validateStackAtSubscription(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginValidateStackAtSubscriptionOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginValidateStackAtSubscription" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateStackAtSubscriptionCreateRequest(ctx, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusBadRequest) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// validateStackAtSubscriptionCreateRequest creates the ValidateStackAtSubscription request. +func (client *Client) validateStackAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, _ *ClientBeginValidateStackAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/validate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/client_factory.go b/sdk/resourcemanager/deployments/deploymentstacks/client_factory.go new file mode 100644 index 000000000000..9d364cb29240 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/client_factory.go @@ -0,0 +1,42 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentstacks + +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 + internal *arm.Client +} + +// 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. The value must be an UUID. +// - 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) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/constants.go b/sdk/resourcemanager/deployments/deploymentstacks/constants.go new file mode 100644 index 000000000000..e1be0ad60d52 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/constants.go @@ -0,0 +1,201 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentstacks + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentstacks" + moduleVersion = "v0.1.0" +) + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// DenySettingsMode - denySettings Mode that defines denied actions. +type DenySettingsMode string + +const ( + // DenySettingsModeDenyDelete - Authorized users are able to read and modify the resources, but cannot delete. + DenySettingsModeDenyDelete DenySettingsMode = "denyDelete" + // DenySettingsModeDenyWriteAndDelete - Authorized users can read from a resource, but cannot modify or delete it. + DenySettingsModeDenyWriteAndDelete DenySettingsMode = "denyWriteAndDelete" + // DenySettingsModeNone - No denyAssignments have been applied. + DenySettingsModeNone DenySettingsMode = "none" +) + +// PossibleDenySettingsModeValues returns the possible values for the DenySettingsMode const type. +func PossibleDenySettingsModeValues() []DenySettingsMode { + return []DenySettingsMode{ + DenySettingsModeDenyDelete, + DenySettingsModeDenyWriteAndDelete, + DenySettingsModeNone, + } +} + +// DenyStatusMode - denyAssignment settings applied to the resource. +type DenyStatusMode string + +const ( + // DenyStatusModeDenyDelete - Authorized users are able to read and modify the resources, but cannot delete. + DenyStatusModeDenyDelete DenyStatusMode = "denyDelete" + // DenyStatusModeDenyWriteAndDelete - Authorized users can only read from a resource, but cannot modify or delete it. + DenyStatusModeDenyWriteAndDelete DenyStatusMode = "denyWriteAndDelete" + // DenyStatusModeInapplicable - denyAssignments are not supported on resources outside the scope of the deployment stack. + DenyStatusModeInapplicable DenyStatusMode = "inapplicable" + // DenyStatusModeNone - No denyAssignments have been applied. + DenyStatusModeNone DenyStatusMode = "none" + // DenyStatusModeNotSupported - Resource type does not support denyAssignments. + DenyStatusModeNotSupported DenyStatusMode = "notSupported" + // DenyStatusModeRemovedBySystem - Deny assignment has been removed by Azure due to a resource management change (management + // group move, etc.) + DenyStatusModeRemovedBySystem DenyStatusMode = "removedBySystem" +) + +// PossibleDenyStatusModeValues returns the possible values for the DenyStatusMode const type. +func PossibleDenyStatusModeValues() []DenyStatusMode { + return []DenyStatusMode{ + DenyStatusModeDenyDelete, + DenyStatusModeDenyWriteAndDelete, + DenyStatusModeInapplicable, + DenyStatusModeNone, + DenyStatusModeNotSupported, + DenyStatusModeRemovedBySystem, + } +} + +// DeploymentStackProvisioningState - State of the deployment stack. +type DeploymentStackProvisioningState string + +const ( + DeploymentStackProvisioningStateCanceled DeploymentStackProvisioningState = "canceled" + DeploymentStackProvisioningStateCanceling DeploymentStackProvisioningState = "canceling" + DeploymentStackProvisioningStateCreating DeploymentStackProvisioningState = "creating" + DeploymentStackProvisioningStateDeleting DeploymentStackProvisioningState = "deleting" + DeploymentStackProvisioningStateDeletingResources DeploymentStackProvisioningState = "deletingResources" + DeploymentStackProvisioningStateDeploying DeploymentStackProvisioningState = "deploying" + DeploymentStackProvisioningStateFailed DeploymentStackProvisioningState = "failed" + DeploymentStackProvisioningStateSucceeded DeploymentStackProvisioningState = "succeeded" + DeploymentStackProvisioningStateUpdatingDenyAssignments DeploymentStackProvisioningState = "updatingDenyAssignments" + DeploymentStackProvisioningStateValidating DeploymentStackProvisioningState = "validating" + DeploymentStackProvisioningStateWaiting DeploymentStackProvisioningState = "waiting" +) + +// PossibleDeploymentStackProvisioningStateValues returns the possible values for the DeploymentStackProvisioningState const type. +func PossibleDeploymentStackProvisioningStateValues() []DeploymentStackProvisioningState { + return []DeploymentStackProvisioningState{ + DeploymentStackProvisioningStateCanceled, + DeploymentStackProvisioningStateCanceling, + DeploymentStackProvisioningStateCreating, + DeploymentStackProvisioningStateDeleting, + DeploymentStackProvisioningStateDeletingResources, + DeploymentStackProvisioningStateDeploying, + DeploymentStackProvisioningStateFailed, + DeploymentStackProvisioningStateSucceeded, + DeploymentStackProvisioningStateUpdatingDenyAssignments, + DeploymentStackProvisioningStateValidating, + DeploymentStackProvisioningStateWaiting, + } +} + +// DeploymentStacksDeleteDetachEnum - Specifies an action for a newly unmanaged resource. Delete will attempt to delete the +// resource from Azure. Detach will leave the resource in it's current state. +type DeploymentStacksDeleteDetachEnum string + +const ( + DeploymentStacksDeleteDetachEnumDelete DeploymentStacksDeleteDetachEnum = "delete" + DeploymentStacksDeleteDetachEnumDetach DeploymentStacksDeleteDetachEnum = "detach" +) + +// PossibleDeploymentStacksDeleteDetachEnumValues returns the possible values for the DeploymentStacksDeleteDetachEnum const type. +func PossibleDeploymentStacksDeleteDetachEnumValues() []DeploymentStacksDeleteDetachEnum { + return []DeploymentStacksDeleteDetachEnum{ + DeploymentStacksDeleteDetachEnumDelete, + DeploymentStacksDeleteDetachEnumDetach, + } +} + +// ResourceStatusMode - Current management state of the resource in the deployment stack. +type ResourceStatusMode string + +const ( + // ResourceStatusModeDeleteFailed - Unable to delete the resource from Azure. The delete will be retried on the next stack + // deployment, or can be deleted manually. + ResourceStatusModeDeleteFailed ResourceStatusMode = "deleteFailed" + // ResourceStatusModeManaged - This resource is managed by the deployment stack. + ResourceStatusModeManaged ResourceStatusMode = "managed" + // ResourceStatusModeRemoveDenyFailed - Unable to remove the deny assignment on resource. + ResourceStatusModeRemoveDenyFailed ResourceStatusMode = "removeDenyFailed" +) + +// PossibleResourceStatusModeValues returns the possible values for the ResourceStatusMode const type. +func PossibleResourceStatusModeValues() []ResourceStatusMode { + return []ResourceStatusMode{ + ResourceStatusModeDeleteFailed, + ResourceStatusModeManaged, + ResourceStatusModeRemoveDenyFailed, + } +} + +type UnmanageActionManagementGroupMode string + +const ( + UnmanageActionManagementGroupModeDelete UnmanageActionManagementGroupMode = "delete" + UnmanageActionManagementGroupModeDetach UnmanageActionManagementGroupMode = "detach" +) + +// PossibleUnmanageActionManagementGroupModeValues returns the possible values for the UnmanageActionManagementGroupMode const type. +func PossibleUnmanageActionManagementGroupModeValues() []UnmanageActionManagementGroupMode { + return []UnmanageActionManagementGroupMode{ + UnmanageActionManagementGroupModeDelete, + UnmanageActionManagementGroupModeDetach, + } +} + +type UnmanageActionResourceGroupMode string + +const ( + UnmanageActionResourceGroupModeDelete UnmanageActionResourceGroupMode = "delete" + UnmanageActionResourceGroupModeDetach UnmanageActionResourceGroupMode = "detach" +) + +// PossibleUnmanageActionResourceGroupModeValues returns the possible values for the UnmanageActionResourceGroupMode const type. +func PossibleUnmanageActionResourceGroupModeValues() []UnmanageActionResourceGroupMode { + return []UnmanageActionResourceGroupMode{ + UnmanageActionResourceGroupModeDelete, + UnmanageActionResourceGroupModeDetach, + } +} + +type UnmanageActionResourceMode string + +const ( + UnmanageActionResourceModeDelete UnmanageActionResourceMode = "delete" + UnmanageActionResourceModeDetach UnmanageActionResourceMode = "detach" +) + +// PossibleUnmanageActionResourceModeValues returns the possible values for the UnmanageActionResourceMode const type. +func PossibleUnmanageActionResourceModeValues() []UnmanageActionResourceMode { + return []UnmanageActionResourceMode{ + UnmanageActionResourceModeDelete, + UnmanageActionResourceModeDetach, + } +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/fake/internal.go b/sdk/resourcemanager/deployments/deploymentstacks/fake/internal.go new file mode 100644 index 000000000000..c614f8d5643a --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/fake/internal.go @@ -0,0 +1,85 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/fake/server.go b/sdk/resourcemanager/deployments/deploymentstacks/fake/server.go new file mode 100644 index 000000000000..d543d2e7fa85 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/fake/server.go @@ -0,0 +1,1023 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentstacks" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// Server is a fake server for instances of the deploymentstacks.Client type. +type Server struct { + // BeginCreateOrUpdateAtManagementGroup is the fake for method Client.BeginCreateOrUpdateAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack deploymentstacks.DeploymentStack, options *deploymentstacks.ClientBeginCreateOrUpdateAtManagementGroupOptions) (resp azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateAtResourceGroup is the fake for method Client.BeginCreateOrUpdateAtResourceGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateAtResourceGroup func(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack deploymentstacks.DeploymentStack, options *deploymentstacks.ClientBeginCreateOrUpdateAtResourceGroupOptions) (resp azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtResourceGroupResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateAtSubscription is the fake for method Client.BeginCreateOrUpdateAtSubscription + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateAtSubscription func(ctx context.Context, deploymentStackName string, deploymentStack deploymentstacks.DeploymentStack, options *deploymentstacks.ClientBeginCreateOrUpdateAtSubscriptionOptions) (resp azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtSubscriptionResponse], errResp azfake.ErrorResponder) + + // BeginDeleteAtManagementGroup is the fake for method Client.BeginDeleteAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAtManagementGroup func(ctx context.Context, managementGroupID string, deploymentStackName string, options *deploymentstacks.ClientBeginDeleteAtManagementGroupOptions) (resp azfake.PollerResponder[deploymentstacks.ClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // BeginDeleteAtResourceGroup is the fake for method Client.BeginDeleteAtResourceGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAtResourceGroup func(ctx context.Context, resourceGroupName string, deploymentStackName string, options *deploymentstacks.ClientBeginDeleteAtResourceGroupOptions) (resp azfake.PollerResponder[deploymentstacks.ClientDeleteAtResourceGroupResponse], errResp azfake.ErrorResponder) + + // BeginDeleteAtSubscription is the fake for method Client.BeginDeleteAtSubscription + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAtSubscription func(ctx context.Context, deploymentStackName string, options *deploymentstacks.ClientBeginDeleteAtSubscriptionOptions) (resp azfake.PollerResponder[deploymentstacks.ClientDeleteAtSubscriptionResponse], errResp azfake.ErrorResponder) + + // ExportTemplateAtManagementGroup is the fake for method Client.ExportTemplateAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK + ExportTemplateAtManagementGroup func(ctx context.Context, managementGroupID string, deploymentStackName string, options *deploymentstacks.ClientExportTemplateAtManagementGroupOptions) (resp azfake.Responder[deploymentstacks.ClientExportTemplateAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // ExportTemplateAtResourceGroup is the fake for method Client.ExportTemplateAtResourceGroup + // HTTP status codes to indicate success: http.StatusOK + ExportTemplateAtResourceGroup func(ctx context.Context, resourceGroupName string, deploymentStackName string, options *deploymentstacks.ClientExportTemplateAtResourceGroupOptions) (resp azfake.Responder[deploymentstacks.ClientExportTemplateAtResourceGroupResponse], errResp azfake.ErrorResponder) + + // ExportTemplateAtSubscription is the fake for method Client.ExportTemplateAtSubscription + // HTTP status codes to indicate success: http.StatusOK + ExportTemplateAtSubscription func(ctx context.Context, deploymentStackName string, options *deploymentstacks.ClientExportTemplateAtSubscriptionOptions) (resp azfake.Responder[deploymentstacks.ClientExportTemplateAtSubscriptionResponse], errResp azfake.ErrorResponder) + + // GetAtManagementGroup is the fake for method Client.GetAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK + GetAtManagementGroup func(ctx context.Context, managementGroupID string, deploymentStackName string, options *deploymentstacks.ClientGetAtManagementGroupOptions) (resp azfake.Responder[deploymentstacks.ClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // GetAtResourceGroup is the fake for method Client.GetAtResourceGroup + // HTTP status codes to indicate success: http.StatusOK + GetAtResourceGroup func(ctx context.Context, resourceGroupName string, deploymentStackName string, options *deploymentstacks.ClientGetAtResourceGroupOptions) (resp azfake.Responder[deploymentstacks.ClientGetAtResourceGroupResponse], errResp azfake.ErrorResponder) + + // GetAtSubscription is the fake for method Client.GetAtSubscription + // HTTP status codes to indicate success: http.StatusOK + GetAtSubscription func(ctx context.Context, deploymentStackName string, options *deploymentstacks.ClientGetAtSubscriptionOptions) (resp azfake.Responder[deploymentstacks.ClientGetAtSubscriptionResponse], errResp azfake.ErrorResponder) + + // NewListAtManagementGroupPager is the fake for method Client.NewListAtManagementGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListAtManagementGroupPager func(managementGroupID string, options *deploymentstacks.ClientListAtManagementGroupOptions) (resp azfake.PagerResponder[deploymentstacks.ClientListAtManagementGroupResponse]) + + // NewListAtResourceGroupPager is the fake for method Client.NewListAtResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListAtResourceGroupPager func(resourceGroupName string, options *deploymentstacks.ClientListAtResourceGroupOptions) (resp azfake.PagerResponder[deploymentstacks.ClientListAtResourceGroupResponse]) + + // NewListAtSubscriptionPager is the fake for method Client.NewListAtSubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListAtSubscriptionPager func(options *deploymentstacks.ClientListAtSubscriptionOptions) (resp azfake.PagerResponder[deploymentstacks.ClientListAtSubscriptionResponse]) + + // BeginValidateStackAtManagementGroup is the fake for method Client.BeginValidateStackAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest + BeginValidateStackAtManagementGroup func(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack deploymentstacks.DeploymentStack, options *deploymentstacks.ClientBeginValidateStackAtManagementGroupOptions) (resp azfake.PollerResponder[deploymentstacks.ClientValidateStackAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // BeginValidateStackAtResourceGroup is the fake for method Client.BeginValidateStackAtResourceGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest + BeginValidateStackAtResourceGroup func(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack deploymentstacks.DeploymentStack, options *deploymentstacks.ClientBeginValidateStackAtResourceGroupOptions) (resp azfake.PollerResponder[deploymentstacks.ClientValidateStackAtResourceGroupResponse], errResp azfake.ErrorResponder) + + // BeginValidateStackAtSubscription is the fake for method Client.BeginValidateStackAtSubscription + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusBadRequest + BeginValidateStackAtSubscription func(ctx context.Context, deploymentStackName string, deploymentStack deploymentstacks.DeploymentStack, options *deploymentstacks.ClientBeginValidateStackAtSubscriptionOptions) (resp azfake.PollerResponder[deploymentstacks.ClientValidateStackAtSubscriptionResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of deploymentstacks.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + beginCreateOrUpdateAtManagementGroup: newTracker[azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtManagementGroupResponse]](), + beginCreateOrUpdateAtResourceGroup: newTracker[azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtResourceGroupResponse]](), + beginCreateOrUpdateAtSubscription: newTracker[azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtSubscriptionResponse]](), + beginDeleteAtManagementGroup: newTracker[azfake.PollerResponder[deploymentstacks.ClientDeleteAtManagementGroupResponse]](), + beginDeleteAtResourceGroup: newTracker[azfake.PollerResponder[deploymentstacks.ClientDeleteAtResourceGroupResponse]](), + beginDeleteAtSubscription: newTracker[azfake.PollerResponder[deploymentstacks.ClientDeleteAtSubscriptionResponse]](), + newListAtManagementGroupPager: newTracker[azfake.PagerResponder[deploymentstacks.ClientListAtManagementGroupResponse]](), + newListAtResourceGroupPager: newTracker[azfake.PagerResponder[deploymentstacks.ClientListAtResourceGroupResponse]](), + newListAtSubscriptionPager: newTracker[azfake.PagerResponder[deploymentstacks.ClientListAtSubscriptionResponse]](), + beginValidateStackAtManagementGroup: newTracker[azfake.PollerResponder[deploymentstacks.ClientValidateStackAtManagementGroupResponse]](), + beginValidateStackAtResourceGroup: newTracker[azfake.PollerResponder[deploymentstacks.ClientValidateStackAtResourceGroupResponse]](), + beginValidateStackAtSubscription: newTracker[azfake.PollerResponder[deploymentstacks.ClientValidateStackAtSubscriptionResponse]](), + } +} + +// ServerTransport connects instances of deploymentstacks.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + beginCreateOrUpdateAtManagementGroup *tracker[azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtManagementGroupResponse]] + beginCreateOrUpdateAtResourceGroup *tracker[azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtResourceGroupResponse]] + beginCreateOrUpdateAtSubscription *tracker[azfake.PollerResponder[deploymentstacks.ClientCreateOrUpdateAtSubscriptionResponse]] + beginDeleteAtManagementGroup *tracker[azfake.PollerResponder[deploymentstacks.ClientDeleteAtManagementGroupResponse]] + beginDeleteAtResourceGroup *tracker[azfake.PollerResponder[deploymentstacks.ClientDeleteAtResourceGroupResponse]] + beginDeleteAtSubscription *tracker[azfake.PollerResponder[deploymentstacks.ClientDeleteAtSubscriptionResponse]] + newListAtManagementGroupPager *tracker[azfake.PagerResponder[deploymentstacks.ClientListAtManagementGroupResponse]] + newListAtResourceGroupPager *tracker[azfake.PagerResponder[deploymentstacks.ClientListAtResourceGroupResponse]] + newListAtSubscriptionPager *tracker[azfake.PagerResponder[deploymentstacks.ClientListAtSubscriptionResponse]] + beginValidateStackAtManagementGroup *tracker[azfake.PollerResponder[deploymentstacks.ClientValidateStackAtManagementGroupResponse]] + beginValidateStackAtResourceGroup *tracker[azfake.PollerResponder[deploymentstacks.ClientValidateStackAtResourceGroupResponse]] + beginValidateStackAtSubscription *tracker[azfake.PollerResponder[deploymentstacks.ClientValidateStackAtSubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.BeginCreateOrUpdateAtManagementGroup": + res.resp, res.err = s.dispatchBeginCreateOrUpdateAtManagementGroup(req) + case "Client.BeginCreateOrUpdateAtResourceGroup": + res.resp, res.err = s.dispatchBeginCreateOrUpdateAtResourceGroup(req) + case "Client.BeginCreateOrUpdateAtSubscription": + res.resp, res.err = s.dispatchBeginCreateOrUpdateAtSubscription(req) + case "Client.BeginDeleteAtManagementGroup": + res.resp, res.err = s.dispatchBeginDeleteAtManagementGroup(req) + case "Client.BeginDeleteAtResourceGroup": + res.resp, res.err = s.dispatchBeginDeleteAtResourceGroup(req) + case "Client.BeginDeleteAtSubscription": + res.resp, res.err = s.dispatchBeginDeleteAtSubscription(req) + case "Client.ExportTemplateAtManagementGroup": + res.resp, res.err = s.dispatchExportTemplateAtManagementGroup(req) + case "Client.ExportTemplateAtResourceGroup": + res.resp, res.err = s.dispatchExportTemplateAtResourceGroup(req) + case "Client.ExportTemplateAtSubscription": + res.resp, res.err = s.dispatchExportTemplateAtSubscription(req) + case "Client.GetAtManagementGroup": + res.resp, res.err = s.dispatchGetAtManagementGroup(req) + case "Client.GetAtResourceGroup": + res.resp, res.err = s.dispatchGetAtResourceGroup(req) + case "Client.GetAtSubscription": + res.resp, res.err = s.dispatchGetAtSubscription(req) + case "Client.NewListAtManagementGroupPager": + res.resp, res.err = s.dispatchNewListAtManagementGroupPager(req) + case "Client.NewListAtResourceGroupPager": + res.resp, res.err = s.dispatchNewListAtResourceGroupPager(req) + case "Client.NewListAtSubscriptionPager": + res.resp, res.err = s.dispatchNewListAtSubscriptionPager(req) + case "Client.BeginValidateStackAtManagementGroup": + res.resp, res.err = s.dispatchBeginValidateStackAtManagementGroup(req) + case "Client.BeginValidateStackAtResourceGroup": + res.resp, res.err = s.dispatchBeginValidateStackAtResourceGroup(req) + case "Client.BeginValidateStackAtSubscription": + res.resp, res.err = s.dispatchBeginValidateStackAtSubscription(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchBeginCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdateAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtManagementGroup not implemented")} + } + beginCreateOrUpdateAtManagementGroup := s.beginCreateOrUpdateAtManagementGroup.get(req) + if beginCreateOrUpdateAtManagementGroup == nil { + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[deploymentstacks.DeploymentStack](req) + if err != nil { + return nil, err + } + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, deploymentStackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateAtManagementGroup = &respr + s.beginCreateOrUpdateAtManagementGroup.add(req, beginCreateOrUpdateAtManagementGroup) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateAtManagementGroup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreateOrUpdateAtManagementGroup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateAtManagementGroup) { + s.beginCreateOrUpdateAtManagementGroup.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginCreateOrUpdateAtResourceGroup(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdateAtResourceGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtResourceGroup not implemented")} + } + beginCreateOrUpdateAtResourceGroup := s.beginCreateOrUpdateAtResourceGroup.get(req) + if beginCreateOrUpdateAtResourceGroup == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[deploymentstacks.DeploymentStack](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdateAtResourceGroup(req.Context(), resourceGroupNameParam, deploymentStackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateAtResourceGroup = &respr + s.beginCreateOrUpdateAtResourceGroup.add(req, beginCreateOrUpdateAtResourceGroup) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateAtResourceGroup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreateOrUpdateAtResourceGroup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateAtResourceGroup) { + s.beginCreateOrUpdateAtResourceGroup.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginCreateOrUpdateAtSubscription(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdateAtSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtSubscription not implemented")} + } + beginCreateOrUpdateAtSubscription := s.beginCreateOrUpdateAtSubscription.get(req) + if beginCreateOrUpdateAtSubscription == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[deploymentstacks.DeploymentStack](req) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdateAtSubscription(req.Context(), deploymentStackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateAtSubscription = &respr + s.beginCreateOrUpdateAtSubscription.add(req, beginCreateOrUpdateAtSubscription) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateAtSubscription, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreateOrUpdateAtSubscription.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateAtSubscription) { + s.beginCreateOrUpdateAtSubscription.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtManagementGroup not implemented")} + } + beginDeleteAtManagementGroup := s.beginDeleteAtManagementGroup.get(req) + if beginDeleteAtManagementGroup == nil { + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + unmanageActionResourcesUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.Resources")) + if err != nil { + return nil, err + } + unmanageActionResourcesParam := getOptional(deploymentstacks.UnmanageActionResourceMode(unmanageActionResourcesUnescaped)) + unmanageActionResourceGroupsUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.ResourceGroups")) + if err != nil { + return nil, err + } + unmanageActionResourceGroupsParam := getOptional(deploymentstacks.UnmanageActionResourceGroupMode(unmanageActionResourceGroupsUnescaped)) + unmanageActionManagementGroupsUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.ManagementGroups")) + if err != nil { + return nil, err + } + unmanageActionManagementGroupsParam := getOptional(deploymentstacks.UnmanageActionManagementGroupMode(unmanageActionManagementGroupsUnescaped)) + bypassStackOutOfSyncErrorUnescaped, err := url.QueryUnescape(qp.Get("bypassStackOutOfSyncError")) + if err != nil { + return nil, err + } + bypassStackOutOfSyncErrorParam, err := parseOptional(bypassStackOutOfSyncErrorUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *deploymentstacks.ClientBeginDeleteAtManagementGroupOptions + if unmanageActionResourcesParam != nil || unmanageActionResourceGroupsParam != nil || unmanageActionManagementGroupsParam != nil || bypassStackOutOfSyncErrorParam != nil { + options = &deploymentstacks.ClientBeginDeleteAtManagementGroupOptions{ + UnmanageActionResources: unmanageActionResourcesParam, + UnmanageActionResourceGroups: unmanageActionResourceGroupsParam, + UnmanageActionManagementGroups: unmanageActionManagementGroupsParam, + BypassStackOutOfSyncError: bypassStackOutOfSyncErrorParam, + } + } + respr, errRespr := s.srv.BeginDeleteAtManagementGroup(req.Context(), managementGroupIDParam, deploymentStackNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteAtManagementGroup = &respr + s.beginDeleteAtManagementGroup.add(req, beginDeleteAtManagementGroup) + } + + resp, err := server.PollerResponderNext(beginDeleteAtManagementGroup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAtManagementGroup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeleteAtManagementGroup) { + s.beginDeleteAtManagementGroup.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginDeleteAtResourceGroup(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAtResourceGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtResourceGroup not implemented")} + } + beginDeleteAtResourceGroup := s.beginDeleteAtResourceGroup.get(req) + if beginDeleteAtResourceGroup == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + unmanageActionResourcesUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.Resources")) + if err != nil { + return nil, err + } + unmanageActionResourcesParam := getOptional(deploymentstacks.UnmanageActionResourceMode(unmanageActionResourcesUnescaped)) + unmanageActionResourceGroupsUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.ResourceGroups")) + if err != nil { + return nil, err + } + unmanageActionResourceGroupsParam := getOptional(deploymentstacks.UnmanageActionResourceGroupMode(unmanageActionResourceGroupsUnescaped)) + unmanageActionManagementGroupsUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.ManagementGroups")) + if err != nil { + return nil, err + } + unmanageActionManagementGroupsParam := getOptional(deploymentstacks.UnmanageActionManagementGroupMode(unmanageActionManagementGroupsUnescaped)) + bypassStackOutOfSyncErrorUnescaped, err := url.QueryUnescape(qp.Get("bypassStackOutOfSyncError")) + if err != nil { + return nil, err + } + bypassStackOutOfSyncErrorParam, err := parseOptional(bypassStackOutOfSyncErrorUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *deploymentstacks.ClientBeginDeleteAtResourceGroupOptions + if unmanageActionResourcesParam != nil || unmanageActionResourceGroupsParam != nil || unmanageActionManagementGroupsParam != nil || bypassStackOutOfSyncErrorParam != nil { + options = &deploymentstacks.ClientBeginDeleteAtResourceGroupOptions{ + UnmanageActionResources: unmanageActionResourcesParam, + UnmanageActionResourceGroups: unmanageActionResourceGroupsParam, + UnmanageActionManagementGroups: unmanageActionManagementGroupsParam, + BypassStackOutOfSyncError: bypassStackOutOfSyncErrorParam, + } + } + respr, errRespr := s.srv.BeginDeleteAtResourceGroup(req.Context(), resourceGroupNameParam, deploymentStackNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteAtResourceGroup = &respr + s.beginDeleteAtResourceGroup.add(req, beginDeleteAtResourceGroup) + } + + resp, err := server.PollerResponderNext(beginDeleteAtResourceGroup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAtResourceGroup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeleteAtResourceGroup) { + s.beginDeleteAtResourceGroup.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginDeleteAtSubscription(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAtSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtSubscription not implemented")} + } + beginDeleteAtSubscription := s.beginDeleteAtSubscription.get(req) + if beginDeleteAtSubscription == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + unmanageActionResourcesUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.Resources")) + if err != nil { + return nil, err + } + unmanageActionResourcesParam := getOptional(deploymentstacks.UnmanageActionResourceMode(unmanageActionResourcesUnescaped)) + unmanageActionResourceGroupsUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.ResourceGroups")) + if err != nil { + return nil, err + } + unmanageActionResourceGroupsParam := getOptional(deploymentstacks.UnmanageActionResourceGroupMode(unmanageActionResourceGroupsUnescaped)) + unmanageActionManagementGroupsUnescaped, err := url.QueryUnescape(qp.Get("unmanageAction.ManagementGroups")) + if err != nil { + return nil, err + } + unmanageActionManagementGroupsParam := getOptional(deploymentstacks.UnmanageActionManagementGroupMode(unmanageActionManagementGroupsUnescaped)) + bypassStackOutOfSyncErrorUnescaped, err := url.QueryUnescape(qp.Get("bypassStackOutOfSyncError")) + if err != nil { + return nil, err + } + bypassStackOutOfSyncErrorParam, err := parseOptional(bypassStackOutOfSyncErrorUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *deploymentstacks.ClientBeginDeleteAtSubscriptionOptions + if unmanageActionResourcesParam != nil || unmanageActionResourceGroupsParam != nil || unmanageActionManagementGroupsParam != nil || bypassStackOutOfSyncErrorParam != nil { + options = &deploymentstacks.ClientBeginDeleteAtSubscriptionOptions{ + UnmanageActionResources: unmanageActionResourcesParam, + UnmanageActionResourceGroups: unmanageActionResourceGroupsParam, + UnmanageActionManagementGroups: unmanageActionManagementGroupsParam, + BypassStackOutOfSyncError: bypassStackOutOfSyncErrorParam, + } + } + respr, errRespr := s.srv.BeginDeleteAtSubscription(req.Context(), deploymentStackNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteAtSubscription = &respr + s.beginDeleteAtSubscription.add(req, beginDeleteAtSubscription) + } + + resp, err := server.PollerResponderNext(beginDeleteAtSubscription, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAtSubscription.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeleteAtSubscription) { + s.beginDeleteAtSubscription.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchExportTemplateAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplateAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method ExportTemplateAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ExportTemplateAtManagementGroup(req.Context(), managementGroupIDParam, deploymentStackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentStackTemplateDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchExportTemplateAtResourceGroup(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplateAtResourceGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method ExportTemplateAtResourceGroup not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ExportTemplateAtResourceGroup(req.Context(), resourceGroupNameParam, deploymentStackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentStackTemplateDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchExportTemplateAtSubscription(req *http.Request) (*http.Response, error) { + if s.srv.ExportTemplateAtSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method ExportTemplateAtSubscription not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportTemplate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ExportTemplateAtSubscription(req.Context(), deploymentStackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentStackTemplateDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.GetAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, deploymentStackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentStack, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGetAtResourceGroup(req *http.Request) (*http.Response, error) { + if s.srv.GetAtResourceGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAtResourceGroup not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetAtResourceGroup(req.Context(), resourceGroupNameParam, deploymentStackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentStack, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGetAtSubscription(req *http.Request) (*http.Response, error) { + if s.srv.GetAtSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAtSubscription not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetAtSubscription(req.Context(), deploymentStackNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeploymentStack, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListAtManagementGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListAtManagementGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListAtManagementGroupPager not implemented")} + } + newListAtManagementGroupPager := s.newListAtManagementGroupPager.get(req) + if newListAtManagementGroupPager == nil { + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListAtManagementGroupPager(managementGroupIDParam, nil) + newListAtManagementGroupPager = &resp + s.newListAtManagementGroupPager.add(req, newListAtManagementGroupPager) + server.PagerResponderInjectNextLinks(newListAtManagementGroupPager, req, func(page *deploymentstacks.ClientListAtManagementGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListAtManagementGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListAtManagementGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListAtManagementGroupPager) { + s.newListAtManagementGroupPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListAtResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListAtResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListAtResourceGroupPager not implemented")} + } + newListAtResourceGroupPager := s.newListAtResourceGroupPager.get(req) + if newListAtResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListAtResourceGroupPager(resourceGroupNameParam, nil) + newListAtResourceGroupPager = &resp + s.newListAtResourceGroupPager.add(req, newListAtResourceGroupPager) + server.PagerResponderInjectNextLinks(newListAtResourceGroupPager, req, func(page *deploymentstacks.ClientListAtResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListAtResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListAtResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListAtResourceGroupPager) { + s.newListAtResourceGroupPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListAtSubscriptionPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListAtSubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListAtSubscriptionPager not implemented")} + } + newListAtSubscriptionPager := s.newListAtSubscriptionPager.get(req) + if newListAtSubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListAtSubscriptionPager(nil) + newListAtSubscriptionPager = &resp + s.newListAtSubscriptionPager.add(req, newListAtSubscriptionPager) + server.PagerResponderInjectNextLinks(newListAtSubscriptionPager, req, func(page *deploymentstacks.ClientListAtSubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListAtSubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListAtSubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListAtSubscriptionPager) { + s.newListAtSubscriptionPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchBeginValidateStackAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidateStackAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginValidateStackAtManagementGroup not implemented")} + } + beginValidateStackAtManagementGroup := s.beginValidateStackAtManagementGroup.get(req) + if beginValidateStackAtManagementGroup == nil { + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[deploymentstacks.DeploymentStack](req) + if err != nil { + return nil, err + } + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginValidateStackAtManagementGroup(req.Context(), managementGroupIDParam, deploymentStackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginValidateStackAtManagementGroup = &respr + s.beginValidateStackAtManagementGroup.add(req, beginValidateStackAtManagementGroup) + } + + resp, err := server.PollerResponderNext(beginValidateStackAtManagementGroup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { + s.beginValidateStackAtManagementGroup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} + } + if !server.PollerResponderMore(beginValidateStackAtManagementGroup) { + s.beginValidateStackAtManagementGroup.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginValidateStackAtResourceGroup(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidateStackAtResourceGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginValidateStackAtResourceGroup not implemented")} + } + beginValidateStackAtResourceGroup := s.beginValidateStackAtResourceGroup.get(req) + if beginValidateStackAtResourceGroup == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[deploymentstacks.DeploymentStack](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginValidateStackAtResourceGroup(req.Context(), resourceGroupNameParam, deploymentStackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginValidateStackAtResourceGroup = &respr + s.beginValidateStackAtResourceGroup.add(req, beginValidateStackAtResourceGroup) + } + + resp, err := server.PollerResponderNext(beginValidateStackAtResourceGroup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { + s.beginValidateStackAtResourceGroup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} + } + if !server.PollerResponderMore(beginValidateStackAtResourceGroup) { + s.beginValidateStackAtResourceGroup.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginValidateStackAtSubscription(req *http.Request) (*http.Response, error) { + if s.srv.BeginValidateStackAtSubscription == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginValidateStackAtSubscription not implemented")} + } + beginValidateStackAtSubscription := s.beginValidateStackAtSubscription.get(req) + if beginValidateStackAtSubscription == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/deploymentStacks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[deploymentstacks.DeploymentStack](req) + if err != nil { + return nil, err + } + deploymentStackNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deploymentStackName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginValidateStackAtSubscription(req.Context(), deploymentStackNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginValidateStackAtSubscription = &respr + s.beginValidateStackAtSubscription.add(req, beginValidateStackAtSubscription) + } + + resp, err := server.PollerResponderNext(beginValidateStackAtSubscription, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusBadRequest}, resp.StatusCode) { + s.beginValidateStackAtSubscription.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusBadRequest", resp.StatusCode)} + } + if !server.PollerResponderMore(beginValidateStackAtSubscription) { + s.beginValidateStackAtSubscription.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/fake/server_factory.go b/sdk/resourcemanager/deployments/deploymentstacks/fake/server_factory.go new file mode 100644 index 000000000000..632293b7a8e7 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/fake/server_factory.go @@ -0,0 +1,73 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the deploymentstacks.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of deploymentstacks.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of deploymentstacks.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/go.mod b/sdk/resourcemanager/deployments/deploymentstacks/go.mod new file mode 100644 index 000000000000..bf009694229a --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/deploymentstacks + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/deployments/deploymentstacks/go.sum b/sdk/resourcemanager/deployments/deploymentstacks/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/deployments/deploymentstacks/models.go b/sdk/resourcemanager/deployments/deploymentstacks/models.go new file mode 100644 index 000000000000..1d397753740f --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/models.go @@ -0,0 +1,357 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentstacks + +import "time" + +// ActionOnUnmanage - Defines the behavior of resources that are no longer managed after the stack is updated or deleted. +type ActionOnUnmanage struct { + // REQUIRED; Specifies an action for a newly unmanaged resource. Delete will attempt to delete the resource from Azure. Detach + // will leave the resource in it's current state. + Resources *DeploymentStacksDeleteDetachEnum + + // Specifies an action for a newly unmanaged resource. Delete will attempt to delete the resource from Azure. Detach will + // leave the resource in it's current state. + ManagementGroups *DeploymentStacksDeleteDetachEnum + + // Specifies an action for a newly unmanaged resource. Delete will attempt to delete the resource from Azure. Detach will + // leave the resource in it's current state. + ResourceGroups *DeploymentStacksDeleteDetachEnum +} + +// DebugSetting - The debug setting. +type DebugSetting struct { + // Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, + // or both requestContent and responseContent separated by a comma. The default is + // none. When setting this value, carefully consider the type of information that is being passed in during deployment. By + // logging information about the request or response, sensitive data that is + // retrieved through the deployment operations could potentially be exposed. + DetailLevel *string +} + +// DenySettings - Defines how resources deployed by the Deployment stack are locked. +type DenySettings struct { + // REQUIRED; denySettings Mode that defines denied actions. + Mode *DenySettingsMode + + // DenySettings will be applied to child resource scopes of every managed resource with a deny assignment. + ApplyToChildScopes *bool + + // List of role-based management operations that are excluded from the denySettings. Up to 200 actions are permitted. If the + // denySetting mode is set to 'denyWriteAndDelete', then the following actions + // are automatically appended to 'excludedActions': '*\/read' and 'Microsoft.Authorization/locks/delete'. If the denySetting + // mode is set to 'denyDelete', then the following actions are automatically + // appended to 'excludedActions': 'Microsoft.Authorization/locks/delete'. Duplicate actions will be removed. + ExcludedActions []*string + + // List of AAD principal IDs excluded from the lock. Up to 5 principals are permitted. + ExcludedPrincipals []*string +} + +// DeploymentParameter - Deployment parameter for the template. +type DeploymentParameter struct { + // Azure Key Vault parameter reference. + Reference *KeyVaultParameterReference + + // Type of the value. + Type *string + + // Input value to the parameter. + Value any +} + +// DeploymentStack - Deployment stack object. +type DeploymentStack struct { + // The location of the Deployment stack. It cannot be changed after creation. It must be one of the supported Azure locations. + Location *string + + // Deployment stack properties. + Properties *DeploymentStackProperties + + // Deployment stack resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// DeploymentStackListResult - List of Deployment stacks. +type DeploymentStackListResult struct { + // An array of Deployment stacks. + Value []*DeploymentStack + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} + +// DeploymentStackProperties - Deployment stack properties. +type DeploymentStackProperties struct { + // REQUIRED; Defines the behavior of resources that are no longer managed after the Deployment stack is updated or deleted. + ActionOnUnmanage *ActionOnUnmanage + + // REQUIRED; Defines how resources deployed by the stack are locked. + DenySettings *DenySettings + + // Flag to bypass service errors that indicate the stack resource list is not correctly synchronized. + BypassStackOutOfSyncError *bool + + // The debug setting of the deployment. + DebugSetting *DebugSetting + + // The scope at which the initial deployment should be created. If a scope is not specified, it will default to the scope + // of the deployment stack. Valid scopes are: management group (format: + // '/providers/Microsoft.Management/managementGroups/{managementGroupId}'), subscription (format: '/subscriptions/{subscriptionId}'), + // resource group (format: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'). + DeploymentScope *string + + // Deployment stack description. Max length of 4096 characters. + Description *string + + // The error detail. + Error *ErrorDetail + + // Name and value pairs that define the deployment parameters for the template. Use this element when providing the parameter + // values directly in the request, rather than linking to an existing parameter + // file. Use either the parametersLink property or the parameters property, but not both. + Parameters map[string]*DeploymentParameter + + // The URI of parameters file. Use this element to link to an existing parameters file. Use either the parametersLink property + // or the parameters property, but not both. + ParametersLink *ParametersLink + + // The template content. You use this element when you want to pass the template syntax directly in the request rather than + // link to an existing template. It can be a JObject or well-formed JSON string. + // Use either the templateLink property or the template property, but not both. + Template any + + // The URI of the template. Use either the templateLink property or the template property, but not both. + TemplateLink *TemplateLink + + // READ-ONLY; The correlation id of the last Deployment stack upsert or delete operation. It is in GUID format and is used + // for tracing. + CorrelationID *string + + // READ-ONLY; An array of resources that were deleted during the most recent Deployment stack update. Deleted means that the + // resource was removed from the template and relevant deletion operations were specified. + DeletedResources []*ResourceReference + + // READ-ONLY; The resourceId of the deployment resource created by the deployment stack. + DeploymentID *string + + // READ-ONLY; An array of resources that were detached during the most recent Deployment stack update. Detached means that + // the resource was removed from the template, but no relevant deletion operations were + // specified. So, the resource still exists while no longer being associated with the stack. + DetachedResources []*ResourceReference + + // READ-ONLY; The duration of the last successful Deployment stack update. + Duration *string + + // READ-ONLY; An array of resources that failed to reach goal state during the most recent update. Each resourceId is accompanied + // by an error message. + FailedResources []*ResourceReferenceExtended + + // READ-ONLY; The outputs of the deployment resource created by the deployment stack. + Outputs any + + // READ-ONLY; State of the deployment stack. + ProvisioningState *DeploymentStackProvisioningState + + // READ-ONLY; An array of resources currently managed by the deployment stack. + Resources []*ManagedResourceReference +} + +// DeploymentStackTemplateDefinition - Export Template specific properties of the Deployment stack. +type DeploymentStackTemplateDefinition struct { + // The template content. Use this element to pass the template syntax directly in the request rather than link to an existing + // template. It can be a JObject or well-formed JSON string. Use either the + // templateLink property or the template property, but not both. + Template any + + // The URI of the template. Use either the templateLink property or the template property, but not both. + TemplateLink *TemplateLink +} + +// DeploymentStackValidateProperties - The Deployment stack validation result details. +type DeploymentStackValidateProperties struct { + // Defines the behavior of resources that are no longer managed after the Deployment stack is updated or deleted. + ActionOnUnmanage *ActionOnUnmanage + + // The correlation id of the Deployment stack validate operation. It is in GUID format and is used for tracing. + CorrelationID *string + + // The Deployment stack deny settings. + DenySettings *DenySettings + + // The Deployment stack deployment scope. + DeploymentScope *string + + // The Deployment stack validation description. + Description *string + + // Deployment parameters. + Parameters map[string]*DeploymentParameter + + // The URI of the template. + TemplateLink *TemplateLink + + // The array of resources that were validated. + ValidatedResources []*ResourceReference +} + +// DeploymentStackValidateResult - The Deployment stack validation result. +type DeploymentStackValidateResult struct { + // The error detail. + Error *ErrorDetail + + // The validation result details. + Properties *DeploymentStackValidateProperties + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// KeyVaultParameterReference - Azure Key Vault parameter reference. +type KeyVaultParameterReference struct { + // REQUIRED; Azure Key Vault reference. + KeyVault *KeyVaultReference + + // REQUIRED; Azure Key Vault secret name. + SecretName *string + + // Azure Key Vault secret version. + SecretVersion *string +} + +// KeyVaultReference - Azure Key Vault reference. +type KeyVaultReference struct { + // REQUIRED; Azure Key Vault resourceId. + ID *string +} + +// ManagedResourceReference - The managed resource model. +type ManagedResourceReference struct { + // denyAssignment settings applied to the resource. + DenyStatus *DenyStatusMode + + // Current management state of the resource in the deployment stack. + Status *ResourceStatusMode + + // READ-ONLY; The resourceId of a resource managed by the deployment stack. + ID *string +} + +// ParametersLink - Entity representing the reference to the deployment parameters. +type ParametersLink struct { + // REQUIRED; The URI of the parameters file. + URI *string + + // If included, must match the ContentVersion in the template. + ContentVersion *string +} + +// ResourceReference - The resourceId model. +type ResourceReference struct { + // READ-ONLY; The resourceId of a resource managed by the deployment stack. + ID *string +} + +// ResourceReferenceExtended - The resourceId extended model. This is used to document failed resources with a resourceId +// and a corresponding error. +type ResourceReferenceExtended struct { + // The error detail. + Error *ErrorDetail + + // READ-ONLY; The resourceId of a resource managed by the deployment stack. + ID *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// TemplateLink - Entity representing the reference to the template. +type TemplateLink struct { + // If included, must match the ContentVersion in the template. + ContentVersion *string + + // The resourceId of a Template Spec. Use either the id or uri property, but not both. + ID *string + + // The query string (for example, a SAS token) to be used with the templateLink URI. + QueryString *string + + // The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template + // was linked with a TemplateSpec, this will reference an artifact in the + // TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath + // URIs. + RelativePath *string + + // The URI of the template to deploy. Use either the uri or id property, but not both. + URI *string +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/models_serde.go b/sdk/resourcemanager/deployments/deploymentstacks/models_serde.go new file mode 100644 index 000000000000..c700cdf8e8ec --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/models_serde.go @@ -0,0 +1,847 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentstacks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ActionOnUnmanage. +func (a ActionOnUnmanage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managementGroups", a.ManagementGroups) + populate(objectMap, "resourceGroups", a.ResourceGroups) + populate(objectMap, "resources", a.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ActionOnUnmanage. +func (a *ActionOnUnmanage) 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 "managementGroups": + err = unpopulate(val, "ManagementGroups", &a.ManagementGroups) + delete(rawMsg, key) + case "resourceGroups": + err = unpopulate(val, "ResourceGroups", &a.ResourceGroups) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &a.Resources) + 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 DebugSetting. +func (d DebugSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "detailLevel", d.DetailLevel) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DebugSetting. +func (d *DebugSetting) 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 "detailLevel": + err = unpopulate(val, "DetailLevel", &d.DetailLevel) + 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 DenySettings. +func (d DenySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyToChildScopes", d.ApplyToChildScopes) + populate(objectMap, "excludedActions", d.ExcludedActions) + populate(objectMap, "excludedPrincipals", d.ExcludedPrincipals) + populate(objectMap, "mode", d.Mode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DenySettings. +func (d *DenySettings) 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 "applyToChildScopes": + err = unpopulate(val, "ApplyToChildScopes", &d.ApplyToChildScopes) + delete(rawMsg, key) + case "excludedActions": + err = unpopulate(val, "ExcludedActions", &d.ExcludedActions) + delete(rawMsg, key) + case "excludedPrincipals": + err = unpopulate(val, "ExcludedPrincipals", &d.ExcludedPrincipals) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &d.Mode) + 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 DeploymentParameter. +func (d DeploymentParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reference", d.Reference) + populate(objectMap, "type", d.Type) + populateAny(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentParameter. +func (d *DeploymentParameter) 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 "reference": + err = unpopulate(val, "Reference", &d.Reference) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + 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 DeploymentStack. +func (d DeploymentStack) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStack. +func (d *DeploymentStack) 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 "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + 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 DeploymentStackListResult. +func (d DeploymentStackListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackListResult. +func (d *DeploymentStackListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + 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 DeploymentStackProperties. +func (d DeploymentStackProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionOnUnmanage", d.ActionOnUnmanage) + populate(objectMap, "bypassStackOutOfSyncError", d.BypassStackOutOfSyncError) + populate(objectMap, "correlationId", d.CorrelationID) + populate(objectMap, "debugSetting", d.DebugSetting) + populate(objectMap, "deletedResources", d.DeletedResources) + populate(objectMap, "denySettings", d.DenySettings) + populate(objectMap, "deploymentId", d.DeploymentID) + populate(objectMap, "deploymentScope", d.DeploymentScope) + populate(objectMap, "description", d.Description) + populate(objectMap, "detachedResources", d.DetachedResources) + populate(objectMap, "duration", d.Duration) + populate(objectMap, "error", d.Error) + populate(objectMap, "failedResources", d.FailedResources) + populateAny(objectMap, "outputs", d.Outputs) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "parametersLink", d.ParametersLink) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "resources", d.Resources) + populateAny(objectMap, "template", d.Template) + populate(objectMap, "templateLink", d.TemplateLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackProperties. +func (d *DeploymentStackProperties) 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 "actionOnUnmanage": + err = unpopulate(val, "ActionOnUnmanage", &d.ActionOnUnmanage) + delete(rawMsg, key) + case "bypassStackOutOfSyncError": + err = unpopulate(val, "BypassStackOutOfSyncError", &d.BypassStackOutOfSyncError) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &d.CorrelationID) + delete(rawMsg, key) + case "debugSetting": + err = unpopulate(val, "DebugSetting", &d.DebugSetting) + delete(rawMsg, key) + case "deletedResources": + err = unpopulate(val, "DeletedResources", &d.DeletedResources) + delete(rawMsg, key) + case "denySettings": + err = unpopulate(val, "DenySettings", &d.DenySettings) + delete(rawMsg, key) + case "deploymentId": + err = unpopulate(val, "DeploymentID", &d.DeploymentID) + delete(rawMsg, key) + case "deploymentScope": + err = unpopulate(val, "DeploymentScope", &d.DeploymentScope) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "detachedResources": + err = unpopulate(val, "DetachedResources", &d.DetachedResources) + delete(rawMsg, key) + case "duration": + err = unpopulate(val, "Duration", &d.Duration) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &d.Error) + delete(rawMsg, key) + case "failedResources": + err = unpopulate(val, "FailedResources", &d.FailedResources) + delete(rawMsg, key) + case "outputs": + err = unpopulate(val, "Outputs", &d.Outputs) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "parametersLink": + err = unpopulate(val, "ParametersLink", &d.ParametersLink) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &d.Resources) + delete(rawMsg, key) + case "template": + err = unpopulate(val, "Template", &d.Template) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + 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 DeploymentStackTemplateDefinition. +func (d DeploymentStackTemplateDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "template", d.Template) + populate(objectMap, "templateLink", d.TemplateLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackTemplateDefinition. +func (d *DeploymentStackTemplateDefinition) 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 "template": + err = unpopulate(val, "Template", &d.Template) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + 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 DeploymentStackValidateProperties. +func (d DeploymentStackValidateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionOnUnmanage", d.ActionOnUnmanage) + populate(objectMap, "correlationId", d.CorrelationID) + populate(objectMap, "denySettings", d.DenySettings) + populate(objectMap, "deploymentScope", d.DeploymentScope) + populate(objectMap, "description", d.Description) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "templateLink", d.TemplateLink) + populate(objectMap, "validatedResources", d.ValidatedResources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackValidateProperties. +func (d *DeploymentStackValidateProperties) 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 "actionOnUnmanage": + err = unpopulate(val, "ActionOnUnmanage", &d.ActionOnUnmanage) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &d.CorrelationID) + delete(rawMsg, key) + case "denySettings": + err = unpopulate(val, "DenySettings", &d.DenySettings) + delete(rawMsg, key) + case "deploymentScope": + err = unpopulate(val, "DeploymentScope", &d.DeploymentScope) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + delete(rawMsg, key) + case "validatedResources": + err = unpopulate(val, "ValidatedResources", &d.ValidatedResources) + 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 DeploymentStackValidateResult. +func (d DeploymentStackValidateResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", d.Error) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackValidateResult. +func (d *DeploymentStackValidateResult) 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 "error": + err = unpopulate(val, "Error", &d.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + 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) + populateAny(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 KeyVaultParameterReference. +func (k KeyVaultParameterReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyVault", k.KeyVault) + populate(objectMap, "secretName", k.SecretName) + populate(objectMap, "secretVersion", k.SecretVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultParameterReference. +func (k *KeyVaultParameterReference) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyVault": + err = unpopulate(val, "KeyVault", &k.KeyVault) + delete(rawMsg, key) + case "secretName": + err = unpopulate(val, "SecretName", &k.SecretName) + delete(rawMsg, key) + case "secretVersion": + err = unpopulate(val, "SecretVersion", &k.SecretVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultReference. +func (k KeyVaultReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", k.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultReference. +func (k *KeyVaultReference) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedResourceReference. +func (m ManagedResourceReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "denyStatus", m.DenyStatus) + populate(objectMap, "id", m.ID) + populate(objectMap, "status", m.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedResourceReference. +func (m *ManagedResourceReference) 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 "denyStatus": + err = unpopulate(val, "DenyStatus", &m.DenyStatus) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &m.Status) + 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 ParametersLink. +func (p ParametersLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentVersion", p.ContentVersion) + populate(objectMap, "uri", p.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParametersLink. +func (p *ParametersLink) 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 "contentVersion": + err = unpopulate(val, "ContentVersion", &p.ContentVersion) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &p.URI) + 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 ResourceReference. +func (r ResourceReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReference. +func (r *ResourceReference) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReferenceExtended. +func (r ResourceReferenceExtended) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", r.Error) + populate(objectMap, "id", r.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceExtended. +func (r *ResourceReferenceExtended) 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 "error": + err = unpopulate(val, "Error", &r.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + 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 SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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 "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + 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 TemplateLink. +func (t TemplateLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentVersion", t.ContentVersion) + populate(objectMap, "id", t.ID) + populate(objectMap, "queryString", t.QueryString) + populate(objectMap, "relativePath", t.RelativePath) + populate(objectMap, "uri", t.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateLink. +func (t *TemplateLink) 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 "contentVersion": + err = unpopulate(val, "ContentVersion", &t.ContentVersion) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "queryString": + err = unpopulate(val, "QueryString", &t.QueryString) + delete(rawMsg, key) + case "relativePath": + err = unpopulate(val, "RelativePath", &t.RelativePath) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &t.URI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, 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 populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + 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/deployments/deploymentstacks/options.go b/sdk/resourcemanager/deployments/deploymentstacks/options.go new file mode 100644 index 000000000000..c82221c56cbf --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/options.go @@ -0,0 +1,151 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentstacks + +// ClientBeginCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtManagementGroup +// method. +type ClientBeginCreateOrUpdateAtManagementGroupOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtResourceGroup +// method. +type ClientBeginCreateOrUpdateAtResourceGroupOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtSubscription +// method. +type ClientBeginCreateOrUpdateAtSubscriptionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteAtManagementGroupOptions contains the optional parameters for the Client.BeginDeleteAtManagementGroup +// method. +type ClientBeginDeleteAtManagementGroupOptions struct { + // Flag to bypass service errors that indicate the stack resource list is not correctly synchronized. + BypassStackOutOfSyncError *bool + + // Resumes the long-running operation from the provided token. + ResumeToken string + + // Flag to indicate delete rather than detach for unmanaged management groups. + UnmanageActionManagementGroups *UnmanageActionManagementGroupMode + + // Flag to indicate delete rather than detach for unmanaged resource groups. + UnmanageActionResourceGroups *UnmanageActionResourceGroupMode + + // Flag to indicate delete rather than detach for unmanaged resources. + UnmanageActionResources *UnmanageActionResourceMode +} + +// ClientBeginDeleteAtResourceGroupOptions contains the optional parameters for the Client.BeginDeleteAtResourceGroup method. +type ClientBeginDeleteAtResourceGroupOptions struct { + // Flag to bypass service errors that indicate the stack resource list is not correctly synchronized. + BypassStackOutOfSyncError *bool + + // Resumes the long-running operation from the provided token. + ResumeToken string + + // Flag to indicate delete rather than detach for unmanaged management groups. + UnmanageActionManagementGroups *UnmanageActionManagementGroupMode + + // Flag to indicate delete rather than detach for unmanaged resource groups. + UnmanageActionResourceGroups *UnmanageActionResourceGroupMode + + // Flag to indicate delete rather than detach for unmanaged resources. + UnmanageActionResources *UnmanageActionResourceMode +} + +// ClientBeginDeleteAtSubscriptionOptions contains the optional parameters for the Client.BeginDeleteAtSubscription method. +type ClientBeginDeleteAtSubscriptionOptions struct { + // Flag to bypass service errors that indicate the stack resource list is not correctly synchronized. + BypassStackOutOfSyncError *bool + + // Resumes the long-running operation from the provided token. + ResumeToken string + + // Flag to indicate delete rather than detach for unmanaged management groups. + UnmanageActionManagementGroups *UnmanageActionManagementGroupMode + + // Flag to indicate delete rather than detach for unmanaged resource groups. + UnmanageActionResourceGroups *UnmanageActionResourceGroupMode + + // Flag to indicate delete rather than detach for unmanaged resources. + UnmanageActionResources *UnmanageActionResourceMode +} + +// ClientBeginValidateStackAtManagementGroupOptions contains the optional parameters for the Client.BeginValidateStackAtManagementGroup +// method. +type ClientBeginValidateStackAtManagementGroupOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginValidateStackAtResourceGroupOptions contains the optional parameters for the Client.BeginValidateStackAtResourceGroup +// method. +type ClientBeginValidateStackAtResourceGroupOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginValidateStackAtSubscriptionOptions contains the optional parameters for the Client.BeginValidateStackAtSubscription +// method. +type ClientBeginValidateStackAtSubscriptionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientExportTemplateAtManagementGroupOptions contains the optional parameters for the Client.ExportTemplateAtManagementGroup +// method. +type ClientExportTemplateAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtResourceGroupOptions contains the optional parameters for the Client.ExportTemplateAtResourceGroup +// method. +type ClientExportTemplateAtResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtSubscriptionOptions contains the optional parameters for the Client.ExportTemplateAtSubscription +// method. +type ClientExportTemplateAtSubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtManagementGroupOptions contains the optional parameters for the Client.GetAtManagementGroup method. +type ClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtResourceGroupOptions contains the optional parameters for the Client.GetAtResourceGroup method. +type ClientGetAtResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtSubscriptionOptions contains the optional parameters for the Client.GetAtSubscription method. +type ClientGetAtSubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ClientListAtManagementGroupOptions contains the optional parameters for the Client.NewListAtManagementGroupPager method. +type ClientListAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListAtResourceGroupOptions contains the optional parameters for the Client.NewListAtResourceGroupPager method. +type ClientListAtResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListAtSubscriptionOptions contains the optional parameters for the Client.NewListAtSubscriptionPager method. +type ClientListAtSubscriptionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/deployments/deploymentstacks/responses.go b/sdk/resourcemanager/deployments/deploymentstacks/responses.go new file mode 100644 index 000000000000..e31748f64704 --- /dev/null +++ b/sdk/resourcemanager/deployments/deploymentstacks/responses.go @@ -0,0 +1,111 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package deploymentstacks + +// ClientCreateOrUpdateAtManagementGroupResponse contains the response from method Client.BeginCreateOrUpdateAtManagementGroup. +type ClientCreateOrUpdateAtManagementGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientCreateOrUpdateAtResourceGroupResponse contains the response from method Client.BeginCreateOrUpdateAtResourceGroup. +type ClientCreateOrUpdateAtResourceGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientCreateOrUpdateAtSubscriptionResponse contains the response from method Client.BeginCreateOrUpdateAtSubscription. +type ClientCreateOrUpdateAtSubscriptionResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientDeleteAtManagementGroupResponse contains the response from method Client.BeginDeleteAtManagementGroup. +type ClientDeleteAtManagementGroupResponse struct { + // placeholder for future response values +} + +// ClientDeleteAtResourceGroupResponse contains the response from method Client.BeginDeleteAtResourceGroup. +type ClientDeleteAtResourceGroupResponse struct { + // placeholder for future response values +} + +// ClientDeleteAtSubscriptionResponse contains the response from method Client.BeginDeleteAtSubscription. +type ClientDeleteAtSubscriptionResponse struct { + // placeholder for future response values +} + +// ClientExportTemplateAtManagementGroupResponse contains the response from method Client.ExportTemplateAtManagementGroup. +type ClientExportTemplateAtManagementGroupResponse struct { + // Export Template specific properties of the Deployment stack. + DeploymentStackTemplateDefinition +} + +// ClientExportTemplateAtResourceGroupResponse contains the response from method Client.ExportTemplateAtResourceGroup. +type ClientExportTemplateAtResourceGroupResponse struct { + // Export Template specific properties of the Deployment stack. + DeploymentStackTemplateDefinition +} + +// ClientExportTemplateAtSubscriptionResponse contains the response from method Client.ExportTemplateAtSubscription. +type ClientExportTemplateAtSubscriptionResponse struct { + // Export Template specific properties of the Deployment stack. + DeploymentStackTemplateDefinition +} + +// ClientGetAtManagementGroupResponse contains the response from method Client.GetAtManagementGroup. +type ClientGetAtManagementGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientGetAtResourceGroupResponse contains the response from method Client.GetAtResourceGroup. +type ClientGetAtResourceGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientGetAtSubscriptionResponse contains the response from method Client.GetAtSubscription. +type ClientGetAtSubscriptionResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientListAtManagementGroupResponse contains the response from method Client.NewListAtManagementGroupPager. +type ClientListAtManagementGroupResponse struct { + // List of Deployment stacks. + DeploymentStackListResult +} + +// ClientListAtResourceGroupResponse contains the response from method Client.NewListAtResourceGroupPager. +type ClientListAtResourceGroupResponse struct { + // List of Deployment stacks. + DeploymentStackListResult +} + +// ClientListAtSubscriptionResponse contains the response from method Client.NewListAtSubscriptionPager. +type ClientListAtSubscriptionResponse struct { + // List of Deployment stacks. + DeploymentStackListResult +} + +// ClientValidateStackAtManagementGroupResponse contains the response from method Client.BeginValidateStackAtManagementGroup. +type ClientValidateStackAtManagementGroupResponse struct { + // The Deployment stack validation result. + DeploymentStackValidateResult +} + +// ClientValidateStackAtResourceGroupResponse contains the response from method Client.BeginValidateStackAtResourceGroup. +type ClientValidateStackAtResourceGroupResponse struct { + // The Deployment stack validation result. + DeploymentStackValidateResult +} + +// ClientValidateStackAtSubscriptionResponse contains the response from method Client.BeginValidateStackAtSubscription. +type ClientValidateStackAtSubscriptionResponse struct { + // The Deployment stack validation result. + DeploymentStackValidateResult +} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/time_rfc3339.go b/sdk/resourcemanager/deployments/deploymentstacks/time_rfc3339.go similarity index 97% rename from sdk/resourcemanager/databoundaries/armdataboundaries/fake/time_rfc3339.go rename to sdk/resourcemanager/deployments/deploymentstacks/time_rfc3339.go index 81f308b0d343..74d025b27f2d 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/time_rfc3339.go +++ b/sdk/resourcemanager/deployments/deploymentstacks/time_rfc3339.go @@ -1,12 +1,9 @@ -//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. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package fake +package deploymentstacks import ( "encoding/json" @@ -60,6 +57,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } tzOffset := tzOffsetRegex.Match(data) hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") var layout string diff --git a/sdk/resourcemanager/deployments/templatespecs/CHANGELOG.md b/sdk/resourcemanager/deployments/templatespecs/CHANGELOG.md new file mode 100644 index 000000000000..374b8b0ca3e5 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-04-28) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/templatespecs` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/templatespecs/LICENSE.txt b/sdk/resourcemanager/deployments/templatespecs/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/templatespecs/README.md b/sdk/resourcemanager/deployments/templatespecs/README.md new file mode 100644 index 000000000000..5acd188cc908 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/README.md @@ -0,0 +1,90 @@ +# Azure Deployments Module for Go + +The `templatespecs` module provides operations for working with Azure Deployments. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/deployments/templatespecs) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Deployments module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/templatespecs +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Deployments. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +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). + +## Client Factory + +Azure Deployments module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := templatespecs.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 { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := templatespecs.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() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Deployments` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/templatespecs/autorest.md b/sdk/resourcemanager/deployments/templatespecs/autorest.md new file mode 100644 index 000000000000..d372d0af4531 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/templateSpecs/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/Microsoft.Resources/templateSpecs/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/deployments/templatespecs/build.go b/sdk/resourcemanager/deployments/templatespecs/build.go new file mode 100644 index 000000000000..f028d532f622 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/deployments/templatespecs + +package templatespecs diff --git a/sdk/resourcemanager/deployments/templatespecs/ci.yml b/sdk/resourcemanager/deployments/templatespecs/ci.yml new file mode 100644 index 000000000000..6f8ae6145959 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/templatespecs/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/deployments/templatespecs/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/deployments/templatespecs' diff --git a/sdk/resourcemanager/deployments/templatespecs/client.go b/sdk/resourcemanager/deployments/templatespecs/client.go new file mode 100644 index 000000000000..0696afee93a4 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/client.go @@ -0,0 +1,529 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// Client contains the methods for the TemplateSpecs group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - Subscription Id which forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a Template Spec. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - templateSpec - Template Spec supplied to the operation. +// - options - ClientCreateOrUpdateOptions contains the optional parameters for the Client.CreateOrUpdate method. +func (client *Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpec TemplateSpec, options *ClientCreateOrUpdateOptions) (ClientCreateOrUpdateResponse, error) { + var err error + const operationName = "Client.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, templateSpecName, templateSpec, options) + if err != nil { + return ClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpec TemplateSpec, _ *ClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, templateSpec); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *Client) createOrUpdateHandleResponse(resp *http.Response) (ClientCreateOrUpdateResponse, error) { + result := ClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpec); err != nil { + return ClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a Template Spec by name. When operation completes, status code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. +func (client *Client) Delete(ctx context.Context, resourceGroupName string, templateSpecName string, options *ClientDeleteOptions) (ClientDeleteResponse, error) { + var err error + const operationName = "Client.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, templateSpecName, options) + if err != nil { + return ClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ClientDeleteResponse{}, err + } + return ClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, _ *ClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a Template Spec with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, templateSpecName string, options *ClientGetOptions) (ClientGetResponse, error) { + var err error + const operationName = "Client.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, templateSpecName, options) + if err != nil { + return ClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, options *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpec); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// GetBuiltIn - Gets a built-in Template Spec with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - 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) { + var err error + const operationName = "Client.GetBuiltIn" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBuiltInCreateRequest(ctx, templateSpecName, options) + if err != nil { + return ClientGetBuiltInResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetBuiltInResponse{}, err + } + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err +} + +// 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.internal.Endpoint(), 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["Accept"] = []string{"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. +// +// Generated from API version 2022-02-01 +// - options - ClientListBuiltInsOptions contains the optional parameters for the Client.NewListBuiltInsPager method. +func (client *Client) NewListBuiltInsPager(options *ClientListBuiltInsOptions) *runtime.Pager[ClientListBuiltInsResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListBuiltInsResponse]{ + More: func(page ClientListBuiltInsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListBuiltInsResponse) (ClientListBuiltInsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListBuiltInsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBuiltInsCreateRequest(ctx, options) + }, nil) + if err != nil { + return ClientListBuiltInsResponse{}, err + } + return client.listBuiltInsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// 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.internal.Endpoint(), 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["Accept"] = []string{"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. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager +// method. +func (client *Client) NewListByResourceGroupPager(resourceGroupName string, options *ClientListByResourceGroupOptions) *runtime.Pager[ClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListByResourceGroupResponse]{ + More: func(page ClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListByResourceGroupResponse) (ClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + 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.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (ClientListByResourceGroupResponse, error) { + result := ClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil { + return ClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists all the Template Specs within the specified subscriptions. +// +// Generated from API version 2022-02-01 +// - options - ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. +func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListBySubscriptionResponse]{ + More: func(page ClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListBySubscriptionResponse) (ClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return ClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, options *ClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/templateSpecs/" + if client.subscriptionID == "" { + 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.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *Client) listBySubscriptionHandleResponse(resp *http.Response) (ClientListBySubscriptionResponse, error) { + result := ClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil { + return ClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Updates Template Spec tags with specified values. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - templateSpec - Template Spec resource with the tags to be updated. +// - options - ClientUpdateOptions contains the optional parameters for the Client.Update method. +func (client *Client) Update(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpec TemplateSpecUpdateModel, options *ClientUpdateOptions) (ClientUpdateResponse, error) { + var err error + const operationName = "Client.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, templateSpecName, templateSpec, options) + if err != nil { + return ClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpec TemplateSpecUpdateModel, _ *ClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, templateSpec); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *Client) updateHandleResponse(resp *http.Response) (ClientUpdateResponse, error) { + result := ClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpec); err != nil { + return ClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/deployments/templatespecs/client_factory.go b/sdk/resourcemanager/deployments/templatespecs/client_factory.go new file mode 100644 index 000000000000..31bb101e2204 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/client_factory.go @@ -0,0 +1,50 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +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 + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Subscription Id which forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewTemplateSpecVersionsClient creates a new instance of TemplateSpecVersionsClient. +func (c *ClientFactory) NewTemplateSpecVersionsClient() *TemplateSpecVersionsClient { + return &TemplateSpecVersionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/deployments/templatespecs/constants.go b/sdk/resourcemanager/deployments/templatespecs/constants.go new file mode 100644 index 000000000000..10d48c989f7c --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/constants.go @@ -0,0 +1,45 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/templatespecs" + moduleVersion = "v0.1.0" +) + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +type TemplateSpecExpandKind string + +const ( + // TemplateSpecExpandKindVersions - Includes version information with the Template Spec. + TemplateSpecExpandKindVersions TemplateSpecExpandKind = "versions" +) + +// PossibleTemplateSpecExpandKindValues returns the possible values for the TemplateSpecExpandKind const type. +func PossibleTemplateSpecExpandKindValues() []TemplateSpecExpandKind { + return []TemplateSpecExpandKind{ + TemplateSpecExpandKindVersions, + } +} diff --git a/sdk/resourcemanager/deployments/templatespecs/fake/internal.go b/sdk/resourcemanager/deployments/templatespecs/fake/internal.go new file mode 100644 index 000000000000..486a30a014e6 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/fake/internal.go @@ -0,0 +1,74 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/deployments/templatespecs/fake/server.go b/sdk/resourcemanager/deployments/templatespecs/fake/server.go new file mode 100644 index 000000000000..d26ef28961df --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/fake/server.go @@ -0,0 +1,466 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/templatespecs" + "net/http" + "net/url" + "regexp" +) + +// Server is a fake server for instances of the templatespecs.Client type. +type Server struct { + // CreateOrUpdate is the fake for method Client.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpec templatespecs.TemplateSpec, options *templatespecs.ClientCreateOrUpdateOptions) (resp azfake.Responder[templatespecs.ClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method Client.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, templateSpecName string, options *templatespecs.ClientDeleteOptions) (resp azfake.Responder[templatespecs.ClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method Client.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, templateSpecName string, options *templatespecs.ClientGetOptions) (resp azfake.Responder[templatespecs.ClientGetResponse], errResp azfake.ErrorResponder) + + // GetBuiltIn is the fake for method Client.GetBuiltIn + // HTTP status codes to indicate success: http.StatusOK + GetBuiltIn func(ctx context.Context, templateSpecName string, options *templatespecs.ClientGetBuiltInOptions) (resp azfake.Responder[templatespecs.ClientGetBuiltInResponse], errResp azfake.ErrorResponder) + + // NewListBuiltInsPager is the fake for method Client.NewListBuiltInsPager + // HTTP status codes to indicate success: http.StatusOK + NewListBuiltInsPager func(options *templatespecs.ClientListBuiltInsOptions) (resp azfake.PagerResponder[templatespecs.ClientListBuiltInsResponse]) + + // NewListByResourceGroupPager is the fake for method Client.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *templatespecs.ClientListByResourceGroupOptions) (resp azfake.PagerResponder[templatespecs.ClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method Client.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *templatespecs.ClientListBySubscriptionOptions) (resp azfake.PagerResponder[templatespecs.ClientListBySubscriptionResponse]) + + // Update is the fake for method Client.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpec templatespecs.TemplateSpecUpdateModel, options *templatespecs.ClientUpdateOptions) (resp azfake.Responder[templatespecs.ClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of templatespecs.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + newListBuiltInsPager: newTracker[azfake.PagerResponder[templatespecs.ClientListBuiltInsResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[templatespecs.ClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[templatespecs.ClientListBySubscriptionResponse]](), + } +} + +// ServerTransport connects instances of templatespecs.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + newListBuiltInsPager *tracker[azfake.PagerResponder[templatespecs.ClientListBuiltInsResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[templatespecs.ClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[templatespecs.ClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.CreateOrUpdate": + res.resp, res.err = s.dispatchCreateOrUpdate(req) + case "Client.Delete": + res.resp, res.err = s.dispatchDelete(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.GetBuiltIn": + res.resp, res.err = s.dispatchGetBuiltIn(req) + case "Client.NewListBuiltInsPager": + res.resp, res.err = s.dispatchNewListBuiltInsPager(req) + case "Client.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "Client.NewListBySubscriptionPager": + res.resp, res.err = s.dispatchNewListBySubscriptionPager(req) + case "Client.Update": + res.resp, res.err = s.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[templatespecs.TemplateSpec](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, templateSpecNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpec, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), resourceGroupNameParam, templateSpecNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(templatespecs.TemplateSpecExpandKind(expandUnescaped)) + var options *templatespecs.ClientGetOptions + if expandParam != nil { + options = &templatespecs.ClientGetOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, templateSpecNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpec, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchGetBuiltIn(req *http.Request) (*http.Response, error) { + if s.srv.GetBuiltIn == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBuiltIn not implemented")} + } + const regexStr = `/providers/Microsoft\.Resources/builtInTemplateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(templatespecs.TemplateSpecExpandKind(expandUnescaped)) + var options *templatespecs.ClientGetBuiltInOptions + if expandParam != nil { + options = &templatespecs.ClientGetBuiltInOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetBuiltIn(req.Context(), templateSpecNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpec, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListBuiltInsPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBuiltInsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBuiltInsPager not implemented")} + } + newListBuiltInsPager := s.newListBuiltInsPager.get(req) + if newListBuiltInsPager == nil { + qp := req.URL.Query() + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(templatespecs.TemplateSpecExpandKind(expandUnescaped)) + var options *templatespecs.ClientListBuiltInsOptions + if expandParam != nil { + options = &templatespecs.ClientListBuiltInsOptions{ + Expand: expandParam, + } + } + resp := s.srv.NewListBuiltInsPager(options) + newListBuiltInsPager = &resp + s.newListBuiltInsPager.add(req, newListBuiltInsPager) + server.PagerResponderInjectNextLinks(newListBuiltInsPager, req, func(page *templatespecs.ClientListBuiltInsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBuiltInsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBuiltInsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBuiltInsPager) { + s.newListBuiltInsPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := s.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(templatespecs.TemplateSpecExpandKind(expandUnescaped)) + var options *templatespecs.ClientListByResourceGroupOptions + if expandParam != nil { + options = &templatespecs.ClientListByResourceGroupOptions{ + Expand: expandParam, + } + } + resp := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + newListByResourceGroupPager = &resp + s.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *templatespecs.ClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + s.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := s.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(templatespecs.TemplateSpecExpandKind(expandUnescaped)) + var options *templatespecs.ClientListBySubscriptionOptions + if expandParam != nil { + options = &templatespecs.ClientListBySubscriptionOptions{ + Expand: expandParam, + } + } + resp := s.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + s.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *templatespecs.ClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + s.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if s.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[templatespecs.TemplateSpecUpdateModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Update(req.Context(), resourceGroupNameParam, templateSpecNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpec, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/deployments/templatespecs/fake/server_factory.go b/sdk/resourcemanager/deployments/templatespecs/fake/server_factory.go new file mode 100644 index 000000000000..4ac6786d4853 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/fake/server_factory.go @@ -0,0 +1,82 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the templatespecs.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server + + // TemplateSpecVersionsServer contains the fakes for client TemplateSpecVersionsClient + TemplateSpecVersionsServer TemplateSpecVersionsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of templatespecs.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of templatespecs.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trTemplateSpecVersionsServer *TemplateSpecVersionsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "TemplateSpecVersionsClient": + initServer(s, &s.trTemplateSpecVersionsServer, func() *TemplateSpecVersionsServerTransport { + return NewTemplateSpecVersionsServerTransport(&s.srv.TemplateSpecVersionsServer) + }) + resp, err = s.trTemplateSpecVersionsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/deployments/templatespecs/fake/templatespecversions_server.go b/sdk/resourcemanager/deployments/templatespecs/fake/templatespecversions_server.go new file mode 100644 index 000000000000..95547b4fff5b --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/fake/templatespecversions_server.go @@ -0,0 +1,399 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/templatespecs" + "net/http" + "net/url" + "regexp" +) + +// TemplateSpecVersionsServer is a fake server for instances of the templatespecs.TemplateSpecVersionsClient type. +type TemplateSpecVersionsServer struct { + // CreateOrUpdate is the fake for method TemplateSpecVersionsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, templateSpecVersionModel templatespecs.TemplateSpecVersion, options *templatespecs.TemplateSpecVersionsClientCreateOrUpdateOptions) (resp azfake.Responder[templatespecs.TemplateSpecVersionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TemplateSpecVersionsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, options *templatespecs.TemplateSpecVersionsClientDeleteOptions) (resp azfake.Responder[templatespecs.TemplateSpecVersionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TemplateSpecVersionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, options *templatespecs.TemplateSpecVersionsClientGetOptions) (resp azfake.Responder[templatespecs.TemplateSpecVersionsClientGetResponse], errResp azfake.ErrorResponder) + + // GetBuiltIn is the fake for method TemplateSpecVersionsClient.GetBuiltIn + // HTTP status codes to indicate success: http.StatusOK + GetBuiltIn func(ctx context.Context, templateSpecName string, templateSpecVersion string, options *templatespecs.TemplateSpecVersionsClientGetBuiltInOptions) (resp azfake.Responder[templatespecs.TemplateSpecVersionsClientGetBuiltInResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TemplateSpecVersionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, templateSpecName string, options *templatespecs.TemplateSpecVersionsClientListOptions) (resp azfake.PagerResponder[templatespecs.TemplateSpecVersionsClientListResponse]) + + // NewListBuiltInsPager is the fake for method TemplateSpecVersionsClient.NewListBuiltInsPager + // HTTP status codes to indicate success: http.StatusOK + NewListBuiltInsPager func(templateSpecName string, options *templatespecs.TemplateSpecVersionsClientListBuiltInsOptions) (resp azfake.PagerResponder[templatespecs.TemplateSpecVersionsClientListBuiltInsResponse]) + + // Update is the fake for method TemplateSpecVersionsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, templateSpecVersionUpdateModel templatespecs.TemplateSpecVersionUpdateModel, options *templatespecs.TemplateSpecVersionsClientUpdateOptions) (resp azfake.Responder[templatespecs.TemplateSpecVersionsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTemplateSpecVersionsServerTransport creates a new instance of TemplateSpecVersionsServerTransport with the provided implementation. +// The returned TemplateSpecVersionsServerTransport instance is connected to an instance of templatespecs.TemplateSpecVersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTemplateSpecVersionsServerTransport(srv *TemplateSpecVersionsServer) *TemplateSpecVersionsServerTransport { + return &TemplateSpecVersionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[templatespecs.TemplateSpecVersionsClientListResponse]](), + newListBuiltInsPager: newTracker[azfake.PagerResponder[templatespecs.TemplateSpecVersionsClientListBuiltInsResponse]](), + } +} + +// TemplateSpecVersionsServerTransport connects instances of templatespecs.TemplateSpecVersionsClient to instances of TemplateSpecVersionsServer. +// Don't use this type directly, use NewTemplateSpecVersionsServerTransport instead. +type TemplateSpecVersionsServerTransport struct { + srv *TemplateSpecVersionsServer + newListPager *tracker[azfake.PagerResponder[templatespecs.TemplateSpecVersionsClientListResponse]] + newListBuiltInsPager *tracker[azfake.PagerResponder[templatespecs.TemplateSpecVersionsClientListBuiltInsResponse]] +} + +// Do implements the policy.Transporter interface for TemplateSpecVersionsServerTransport. +func (t *TemplateSpecVersionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TemplateSpecVersionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if templateSpecVersionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = templateSpecVersionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TemplateSpecVersionsClient.CreateOrUpdate": + res.resp, res.err = t.dispatchCreateOrUpdate(req) + case "TemplateSpecVersionsClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TemplateSpecVersionsClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TemplateSpecVersionsClient.GetBuiltIn": + res.resp, res.err = t.dispatchGetBuiltIn(req) + case "TemplateSpecVersionsClient.NewListPager": + res.resp, res.err = t.dispatchNewListPager(req) + case "TemplateSpecVersionsClient.NewListBuiltInsPager": + res.resp, res.err = t.dispatchNewListBuiltInsPager(req) + case "TemplateSpecVersionsClient.Update": + res.resp, res.err = t.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TemplateSpecVersionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[templatespecs.TemplateSpecVersion](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + templateSpecVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, templateSpecNameParam, templateSpecVersionParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpecVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TemplateSpecVersionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + templateSpecVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, templateSpecNameParam, templateSpecVersionParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TemplateSpecVersionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + templateSpecVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, templateSpecNameParam, templateSpecVersionParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpecVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TemplateSpecVersionsServerTransport) dispatchGetBuiltIn(req *http.Request) (*http.Response, error) { + if t.srv.GetBuiltIn == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBuiltIn not implemented")} + } + const regexStr = `/providers/Microsoft\.Resources/builtInTemplateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + templateSpecVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.GetBuiltIn(req.Context(), templateSpecNameParam, templateSpecVersionParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpecVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TemplateSpecVersionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := t.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameParam, templateSpecNameParam, nil) + newListPager = &resp + t.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *templatespecs.TemplateSpecVersionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + t.newListPager.remove(req) + } + return resp, nil +} + +func (t *TemplateSpecVersionsServerTransport) dispatchNewListBuiltInsPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListBuiltInsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBuiltInsPager not implemented")} + } + newListBuiltInsPager := t.newListBuiltInsPager.get(req) + if newListBuiltInsPager == nil { + const regexStr = `/providers/Microsoft\.Resources/builtInTemplateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListBuiltInsPager(templateSpecNameParam, nil) + newListBuiltInsPager = &resp + t.newListBuiltInsPager.add(req, newListBuiltInsPager) + server.PagerResponderInjectNextLinks(newListBuiltInsPager, req, func(page *templatespecs.TemplateSpecVersionsClientListBuiltInsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBuiltInsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListBuiltInsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBuiltInsPager) { + t.newListBuiltInsPager.remove(req) + } + return resp, nil +} + +func (t *TemplateSpecVersionsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if t.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/templateSpecs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[templatespecs.TemplateSpecVersionUpdateModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + templateSpecNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecName")]) + if err != nil { + return nil, err + } + templateSpecVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("templateSpecVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Update(req.Context(), resourceGroupNameParam, templateSpecNameParam, templateSpecVersionParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TemplateSpecVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to TemplateSpecVersionsServerTransport +var templateSpecVersionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/deployments/templatespecs/go.mod b/sdk/resourcemanager/deployments/templatespecs/go.mod new file mode 100644 index 000000000000..2f0145ee5cf6 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deployments/templatespecs + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/deployments/templatespecs/go.sum b/sdk/resourcemanager/deployments/templatespecs/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/deployments/templatespecs/models.go b/sdk/resourcemanager/deployments/templatespecs/models.go new file mode 100644 index 000000000000..cc5d92bfa7c3 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/models.go @@ -0,0 +1,188 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +import "time" + +// LinkedTemplateArtifact - Represents a Template Spec artifact containing an embedded Azure Resource Manager template for +// use as a linked template. +type LinkedTemplateArtifact struct { + // REQUIRED; A filesystem safe relative path of the artifact. + Path *string + + // REQUIRED; The Azure Resource Manager template. + Template any +} + +// ListResult - List of Template Specs. +type ListResult struct { + // An array of Template Specs. + Value []*TemplateSpec + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// TemplateSpec - Template Spec object. +type TemplateSpec struct { + // REQUIRED; The location of the Template Spec. It cannot be changed after Template Spec creation. It must be one of the supported + // Azure locations. + Location *string + + // Template Spec properties. + Properties *TemplateSpecProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// TemplateSpecProperties - Template Spec properties. +type TemplateSpecProperties struct { + // Template Spec description. + Description *string + + // Template Spec display name. + DisplayName *string + + // The Template Spec metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. + Metadata any + + // READ-ONLY; High-level information about the versions within this Template Spec. The keys are the version names. Only populated + // if the $expand query parameter is set to 'versions'. + Versions map[string]*TemplateSpecVersionInfo +} + +// TemplateSpecUpdateModel - Template Spec properties to be updated (only tags are currently supported). +type TemplateSpecUpdateModel struct { + // Resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// TemplateSpecVersion - Template Spec Version object. +type TemplateSpecVersion struct { + // REQUIRED; The location of the Template Spec Version. It must match the location of the parent Template Spec. + Location *string + + // REQUIRED; Template Spec Version properties. + Properties *TemplateSpecVersionProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// TemplateSpecVersionInfo - High-level information about a Template Spec version. +type TemplateSpecVersionInfo struct { + // READ-ONLY; Template Spec version description. + Description *string + + // READ-ONLY; The timestamp of when the version was created. + TimeCreated *time.Time + + // READ-ONLY; The timestamp of when the version was last modified. + TimeModified *time.Time +} + +// TemplateSpecVersionProperties - Template Spec Version properties. +type TemplateSpecVersionProperties struct { + // Template Spec version description. + Description *string + + // An array of linked template artifacts. + LinkedTemplates []*LinkedTemplateArtifact + + // The main Azure Resource Manager template content. + MainTemplate any + + // The version metadata. Metadata is an open-ended object and is typically a collection of key-value pairs. + Metadata any + + // The Azure Resource Manager template UI definition content. + UIFormDefinition any +} + +// TemplateSpecVersionUpdateModel - Template Spec Version properties to be updated (only tags are currently supported). +type TemplateSpecVersionUpdateModel struct { + // Resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// TemplateSpecVersionsListResult - List of Template Specs versions +type TemplateSpecVersionsListResult struct { + // An array of Template Spec versions. + Value []*TemplateSpecVersion + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} diff --git a/sdk/resourcemanager/deployments/templatespecs/models_serde.go b/sdk/resourcemanager/deployments/templatespecs/models_serde.go new file mode 100644 index 000000000000..128d80f41951 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/models_serde.go @@ -0,0 +1,488 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type LinkedTemplateArtifact. +func (l LinkedTemplateArtifact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "path", l.Path) + populateAny(objectMap, "template", l.Template) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkedTemplateArtifact. +func (l *LinkedTemplateArtifact) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "path": + err = unpopulate(val, "Path", &l.Path) + delete(rawMsg, key) + case "template": + err = unpopulate(val, "Template", &l.Template) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListResult. +func (l ListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListResult. +func (l *ListResult) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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 "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + 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 TemplateSpec. +func (t TemplateSpec) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateSpec. +func (t *TemplateSpec) 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 "location": + err = unpopulate(val, "Location", &t.Location) + 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 "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 TemplateSpecProperties. +func (t TemplateSpecProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", t.Description) + populate(objectMap, "displayName", t.DisplayName) + populateAny(objectMap, "metadata", t.Metadata) + populate(objectMap, "versions", t.Versions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateSpecProperties. +func (t *TemplateSpecProperties) 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 "description": + err = unpopulate(val, "Description", &t.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &t.DisplayName) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &t.Metadata) + delete(rawMsg, key) + case "versions": + err = unpopulate(val, "Versions", &t.Versions) + 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 TemplateSpecUpdateModel. +func (t TemplateSpecUpdateModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateSpecUpdateModel. +func (t *TemplateSpecUpdateModel) 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 "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 TemplateSpecVersion. +func (t TemplateSpecVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateSpecVersion. +func (t *TemplateSpecVersion) 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 "location": + err = unpopulate(val, "Location", &t.Location) + 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 "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 TemplateSpecVersionInfo. +func (t TemplateSpecVersionInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", t.Description) + populateDateTimeRFC3339(objectMap, "timeCreated", t.TimeCreated) + populateDateTimeRFC3339(objectMap, "timeModified", t.TimeModified) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateSpecVersionInfo. +func (t *TemplateSpecVersionInfo) 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 "description": + err = unpopulate(val, "Description", &t.Description) + delete(rawMsg, key) + case "timeCreated": + err = unpopulateDateTimeRFC3339(val, "TimeCreated", &t.TimeCreated) + delete(rawMsg, key) + case "timeModified": + err = unpopulateDateTimeRFC3339(val, "TimeModified", &t.TimeModified) + 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 TemplateSpecVersionProperties. +func (t TemplateSpecVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", t.Description) + populate(objectMap, "linkedTemplates", t.LinkedTemplates) + populateAny(objectMap, "mainTemplate", t.MainTemplate) + populateAny(objectMap, "metadata", t.Metadata) + populateAny(objectMap, "uiFormDefinition", t.UIFormDefinition) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateSpecVersionProperties. +func (t *TemplateSpecVersionProperties) 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 "description": + err = unpopulate(val, "Description", &t.Description) + delete(rawMsg, key) + case "linkedTemplates": + err = unpopulate(val, "LinkedTemplates", &t.LinkedTemplates) + delete(rawMsg, key) + case "mainTemplate": + err = unpopulate(val, "MainTemplate", &t.MainTemplate) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &t.Metadata) + delete(rawMsg, key) + case "uiFormDefinition": + err = unpopulate(val, "UIFormDefinition", &t.UIFormDefinition) + 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 TemplateSpecVersionUpdateModel. +func (t TemplateSpecVersionUpdateModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateSpecVersionUpdateModel. +func (t *TemplateSpecVersionUpdateModel) 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 "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 TemplateSpecVersionsListResult. +func (t TemplateSpecVersionsListResult) 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 TemplateSpecVersionsListResult. +func (t *TemplateSpecVersionsListResult) 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 +} + +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 populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + 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/deployments/templatespecs/options.go b/sdk/resourcemanager/deployments/templatespecs/options.go new file mode 100644 index 000000000000..6448f41fc072 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/options.go @@ -0,0 +1,90 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +// ClientCreateOrUpdateOptions contains the optional parameters for the Client.CreateOrUpdate method. +type ClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ClientDeleteOptions contains the optional parameters for the Client.Delete method. +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.NewListBuiltInsPager 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.NewListByResourceGroupPager method. +type ClientListByResourceGroupOptions struct { + // Allows for expansion of additional Template Spec details in the response. Optional. + Expand *TemplateSpecExpandKind +} + +// ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. +type ClientListBySubscriptionOptions struct { + // Allows for expansion of additional Template Spec details in the response. Optional. + Expand *TemplateSpecExpandKind +} + +// ClientUpdateOptions contains the optional parameters for the Client.Update method. +type ClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// TemplateSpecVersionsClientCreateOrUpdateOptions contains the optional parameters for the TemplateSpecVersionsClient.CreateOrUpdate +// method. +type TemplateSpecVersionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// TemplateSpecVersionsClientDeleteOptions contains the optional parameters for the TemplateSpecVersionsClient.Delete method. +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.NewListBuiltInsPager +// method. +type TemplateSpecVersionsClientListBuiltInsOptions struct { + // placeholder for future optional parameters +} + +// TemplateSpecVersionsClientListOptions contains the optional parameters for the TemplateSpecVersionsClient.NewListPager +// method. +type TemplateSpecVersionsClientListOptions struct { + // placeholder for future optional parameters +} + +// TemplateSpecVersionsClientUpdateOptions contains the optional parameters for the TemplateSpecVersionsClient.Update method. +type TemplateSpecVersionsClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/deployments/templatespecs/responses.go b/sdk/resourcemanager/deployments/templatespecs/responses.go new file mode 100644 index 000000000000..bc9ccef7db57 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/responses.go @@ -0,0 +1,94 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +// ClientCreateOrUpdateResponse contains the response from method Client.CreateOrUpdate. +type ClientCreateOrUpdateResponse struct { + // Template Spec object. + TemplateSpec +} + +// ClientDeleteResponse contains the response from method Client.Delete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientGetBuiltInResponse contains the response from method Client.GetBuiltIn. +type ClientGetBuiltInResponse struct { + // Template Spec object. + TemplateSpec +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // Template Spec object. + TemplateSpec +} + +// ClientListBuiltInsResponse contains the response from method Client.NewListBuiltInsPager. +type ClientListBuiltInsResponse struct { + // List of Template Specs. + ListResult +} + +// ClientListByResourceGroupResponse contains the response from method Client.NewListByResourceGroupPager. +type ClientListByResourceGroupResponse struct { + // List of Template Specs. + ListResult +} + +// ClientListBySubscriptionResponse contains the response from method Client.NewListBySubscriptionPager. +type ClientListBySubscriptionResponse struct { + // List of Template Specs. + ListResult +} + +// ClientUpdateResponse contains the response from method Client.Update. +type ClientUpdateResponse struct { + // Template Spec object. + TemplateSpec +} + +// TemplateSpecVersionsClientCreateOrUpdateResponse contains the response from method TemplateSpecVersionsClient.CreateOrUpdate. +type TemplateSpecVersionsClientCreateOrUpdateResponse struct { + // Template Spec Version object. + TemplateSpecVersion +} + +// TemplateSpecVersionsClientDeleteResponse contains the response from method TemplateSpecVersionsClient.Delete. +type TemplateSpecVersionsClientDeleteResponse struct { + // placeholder for future response values +} + +// TemplateSpecVersionsClientGetBuiltInResponse contains the response from method TemplateSpecVersionsClient.GetBuiltIn. +type TemplateSpecVersionsClientGetBuiltInResponse struct { + // Template Spec Version object. + TemplateSpecVersion +} + +// TemplateSpecVersionsClientGetResponse contains the response from method TemplateSpecVersionsClient.Get. +type TemplateSpecVersionsClientGetResponse struct { + // Template Spec Version object. + TemplateSpecVersion +} + +// TemplateSpecVersionsClientListBuiltInsResponse contains the response from method TemplateSpecVersionsClient.NewListBuiltInsPager. +type TemplateSpecVersionsClientListBuiltInsResponse struct { + // List of Template Specs versions + TemplateSpecVersionsListResult +} + +// TemplateSpecVersionsClientListResponse contains the response from method TemplateSpecVersionsClient.NewListPager. +type TemplateSpecVersionsClientListResponse struct { + // List of Template Specs versions + TemplateSpecVersionsListResult +} + +// TemplateSpecVersionsClientUpdateResponse contains the response from method TemplateSpecVersionsClient.Update. +type TemplateSpecVersionsClientUpdateResponse struct { + // Template Spec Version object. + TemplateSpecVersion +} diff --git a/sdk/resourcemanager/deployments/templatespecs/templatespecversions_client.go b/sdk/resourcemanager/deployments/templatespecs/templatespecversions_client.go new file mode 100644 index 000000000000..a8f258d0b207 --- /dev/null +++ b/sdk/resourcemanager/deployments/templatespecs/templatespecversions_client.go @@ -0,0 +1,501 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package templatespecs + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// TemplateSpecVersionsClient contains the methods for the TemplateSpecVersions group. +// Don't use this type directly, use NewTemplateSpecVersionsClient() instead. +type TemplateSpecVersionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTemplateSpecVersionsClient creates a new instance of TemplateSpecVersionsClient with the specified values. +// - subscriptionID - Subscription Id which forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewTemplateSpecVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TemplateSpecVersionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TemplateSpecVersionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a Template Spec version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - templateSpecVersion - The version of the Template Spec. +// - templateSpecVersionModel - Template Spec Version supplied to the operation. +// - options - TemplateSpecVersionsClientCreateOrUpdateOptions contains the optional parameters for the TemplateSpecVersionsClient.CreateOrUpdate +// method. +func (client *TemplateSpecVersionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, templateSpecVersionModel TemplateSpecVersion, options *TemplateSpecVersionsClientCreateOrUpdateOptions) (TemplateSpecVersionsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "TemplateSpecVersionsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, templateSpecName, templateSpecVersion, templateSpecVersionModel, options) + if err != nil { + return TemplateSpecVersionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TemplateSpecVersionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return TemplateSpecVersionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TemplateSpecVersionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, templateSpecVersionModel TemplateSpecVersion, _ *TemplateSpecVersionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, templateSpecVersionModel); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TemplateSpecVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (TemplateSpecVersionsClientCreateOrUpdateResponse, error) { + result := TemplateSpecVersionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpecVersion); err != nil { + return TemplateSpecVersionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - templateSpecVersion - The version of the Template Spec. +// - options - TemplateSpecVersionsClientDeleteOptions contains the optional parameters for the TemplateSpecVersionsClient.Delete +// method. +func (client *TemplateSpecVersionsClient) Delete(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, options *TemplateSpecVersionsClientDeleteOptions) (TemplateSpecVersionsClientDeleteResponse, error) { + var err error + const operationName = "TemplateSpecVersionsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, templateSpecName, templateSpecVersion, options) + if err != nil { + return TemplateSpecVersionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TemplateSpecVersionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TemplateSpecVersionsClientDeleteResponse{}, err + } + return TemplateSpecVersionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TemplateSpecVersionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, _ *TemplateSpecVersionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a Template Spec version from a specific Template Spec. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - templateSpecVersion - The version of the Template Spec. +// - options - TemplateSpecVersionsClientGetOptions contains the optional parameters for the TemplateSpecVersionsClient.Get +// method. +func (client *TemplateSpecVersionsClient) Get(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, options *TemplateSpecVersionsClientGetOptions) (TemplateSpecVersionsClientGetResponse, error) { + var err error + const operationName = "TemplateSpecVersionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, templateSpecName, templateSpecVersion, options) + if err != nil { + return TemplateSpecVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TemplateSpecVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TemplateSpecVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TemplateSpecVersionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, _ *TemplateSpecVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TemplateSpecVersionsClient) getHandleResponse(resp *http.Response) (TemplateSpecVersionsClientGetResponse, error) { + result := TemplateSpecVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpecVersion); err != nil { + return TemplateSpecVersionsClientGetResponse{}, err + } + 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. +// +// Generated from API version 2022-02-01 +// - 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) { + var err error + const operationName = "TemplateSpecVersionsClient.GetBuiltIn" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBuiltInCreateRequest(ctx, templateSpecName, templateSpecVersion, options) + if err != nil { + return TemplateSpecVersionsClientGetBuiltInResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TemplateSpecVersionsClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TemplateSpecVersionsClientGetBuiltInResponse{}, err + } + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err +} + +// getBuiltInCreateRequest creates the GetBuiltIn request. +func (client *TemplateSpecVersionsClient) getBuiltInCreateRequest(ctx context.Context, templateSpecName string, templateSpecVersion string, _ *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.internal.Endpoint(), 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["Accept"] = []string{"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. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - options - TemplateSpecVersionsClientListOptions contains the optional parameters for the TemplateSpecVersionsClient.NewListPager +// method. +func (client *TemplateSpecVersionsClient) NewListPager(resourceGroupName string, templateSpecName string, options *TemplateSpecVersionsClientListOptions) *runtime.Pager[TemplateSpecVersionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[TemplateSpecVersionsClientListResponse]{ + More: func(page TemplateSpecVersionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TemplateSpecVersionsClientListResponse) (TemplateSpecVersionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TemplateSpecVersionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, templateSpecName, options) + }, nil) + if err != nil { + return TemplateSpecVersionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *TemplateSpecVersionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, _ *TemplateSpecVersionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TemplateSpecVersionsClient) listHandleResponse(resp *http.Response) (TemplateSpecVersionsClientListResponse, error) { + result := TemplateSpecVersionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpecVersionsListResult); err != nil { + return TemplateSpecVersionsClientListResponse{}, err + } + return result, nil +} + +// NewListBuiltInsPager - Lists all the Template Spec versions in the specified built-in Template Spec. +// +// Generated from API version 2022-02-01 +// - templateSpecName - Name of the Template Spec. +// - options - TemplateSpecVersionsClientListBuiltInsOptions contains the optional parameters for the TemplateSpecVersionsClient.NewListBuiltInsPager +// method. +func (client *TemplateSpecVersionsClient) NewListBuiltInsPager(templateSpecName string, options *TemplateSpecVersionsClientListBuiltInsOptions) *runtime.Pager[TemplateSpecVersionsClientListBuiltInsResponse] { + return runtime.NewPager(runtime.PagingHandler[TemplateSpecVersionsClientListBuiltInsResponse]{ + More: func(page TemplateSpecVersionsClientListBuiltInsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TemplateSpecVersionsClientListBuiltInsResponse) (TemplateSpecVersionsClientListBuiltInsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TemplateSpecVersionsClient.NewListBuiltInsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBuiltInsCreateRequest(ctx, templateSpecName, options) + }, nil) + if err != nil { + return TemplateSpecVersionsClientListBuiltInsResponse{}, err + } + return client.listBuiltInsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBuiltInsCreateRequest creates the ListBuiltIns request. +func (client *TemplateSpecVersionsClient) listBuiltInsCreateRequest(ctx context.Context, templateSpecName string, _ *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.internal.Endpoint(), 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["Accept"] = []string{"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. +// +// Generated from API version 2022-02-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - templateSpecName - Name of the Template Spec. +// - templateSpecVersion - The version of the Template Spec. +// - templateSpecVersionUpdateModel - Template Spec Version resource with the tags to be updated. +// - options - TemplateSpecVersionsClientUpdateOptions contains the optional parameters for the TemplateSpecVersionsClient.Update +// method. +func (client *TemplateSpecVersionsClient) Update(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, templateSpecVersionUpdateModel TemplateSpecVersionUpdateModel, options *TemplateSpecVersionsClientUpdateOptions) (TemplateSpecVersionsClientUpdateResponse, error) { + var err error + const operationName = "TemplateSpecVersionsClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, templateSpecName, templateSpecVersion, templateSpecVersionUpdateModel, options) + if err != nil { + return TemplateSpecVersionsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TemplateSpecVersionsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TemplateSpecVersionsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *TemplateSpecVersionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, templateSpecName string, templateSpecVersion string, templateSpecVersionUpdateModel TemplateSpecVersionUpdateModel, _ *TemplateSpecVersionsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/templateSpecs/{templateSpecName}/versions/{templateSpecVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), 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["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, templateSpecVersionUpdateModel); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *TemplateSpecVersionsClient) updateHandleResponse(resp *http.Response) (TemplateSpecVersionsClientUpdateResponse, error) { + result := TemplateSpecVersionsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TemplateSpecVersion); err != nil { + return TemplateSpecVersionsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armresources/fake/time_rfc3339.go b/sdk/resourcemanager/deployments/templatespecs/time_rfc3339.go similarity index 97% rename from sdk/resourcemanager/resources/armresources/fake/time_rfc3339.go rename to sdk/resourcemanager/deployments/templatespecs/time_rfc3339.go index 81f308b0d343..d3767fbc2502 100644 --- a/sdk/resourcemanager/resources/armresources/fake/time_rfc3339.go +++ b/sdk/resourcemanager/deployments/templatespecs/time_rfc3339.go @@ -1,12 +1,9 @@ -//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. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package fake +package templatespecs import ( "encoding/json" @@ -60,6 +57,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } tzOffset := tzOffsetRegex.Match(data) hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") var layout string diff --git a/sdk/resourcemanager/resources/armchanges/CHANGELOG.md b/sdk/resourcemanager/resources/armchanges/CHANGELOG.md index 7e46a86ac2b8..122685044064 100644 --- a/sdk/resourcemanager/resources/armchanges/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armchanges/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2025-04-28) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armchanges/autorest.md b/sdk/resourcemanager/resources/armchanges/autorest.md index 88dfde006675..786b757dccff 100644 --- a/sdk/resourcemanager/resources/armchanges/autorest.md +++ b/sdk/resourcemanager/resources/armchanges/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/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: 1.2.0 +module-version: 1.2.1 package-changes: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armchanges/client.go b/sdk/resourcemanager/resources/armchanges/client.go index 1bd5ada6743b..a1795519c289 100644 --- a/sdk/resourcemanager/resources/armchanges/client.go +++ b/sdk/resourcemanager/resources/armchanges/client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -77,7 +74,7 @@ func (client *Client) Get(ctx context.Context, resourceGroupName string, resourc } // getCreateRequest creates the Get request. -func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, changeResourceID string, options *ClientGetOptions) (*policy.Request, error) { +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, changeResourceID string, _ *ClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -182,13 +179,13 @@ func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(*options.Top, 10)) - } if options != nil && options.SkipToken != nil { reqQP.Set("$skipToken", *options.SkipToken) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(*options.Top, 10)) + } + reqQP.Set("api-version", "2022-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armchanges/client_example_test.go b/sdk/resourcemanager/resources/armchanges/client_example_test.go deleted file mode 100644 index ff4e4df3f929..000000000000 --- a/sdk/resourcemanager/resources/armchanges/client_example_test.go +++ /dev/null @@ -1,149 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armchanges_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armchanges" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-05-01/examples/ListChanges.json -func ExampleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchanges.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListPager("resourceGroup1", "resourceProvider1", "resourceType1", "resourceName1", &armchanges.ClientListOptions{Top: nil, - SkipToken: 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.ChangeResourceListResult = armchanges.ChangeResourceListResult{ - // Value: []*armchanges.ChangeResourceResult{ - // { - // Name: to.Ptr("a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Type: to.Ptr("Microsoft.Resources/changes"), - // ID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1/Microsoft.Resources/changes/a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Properties: &armchanges.ChangeProperties{ - // ChangeAttributes: &armchanges.ChangeAttributes{ - // ChangesCount: to.Ptr[int64](2), - // CorrelationID: to.Ptr("88420d5d-8d0e-471f-9115-10d34750c617"), - // NewResourceSnapshotID: to.Ptr("6eac9d0f-63b4-4e7f-97a5-740c73757efb"), - // PreviousResourceSnapshotID: to.Ptr("ed90e35a-1661-42cc-a44c-e27f508005be"), - // Timestamp: to.Ptr("2021-11-19T14:29:09.9210000Z"), - // }, - // ChangeType: to.Ptr(armchanges.ChangeTypeUpdate), - // Changes: map[string]*armchanges.ChangeBase{ - // "properties.provisioningState": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategorySystem), - // NewValue: to.Ptr("Succeeded"), - // PreviousValue: to.Ptr("Updating"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeUpdate), - // }, - // "tags.key1": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategoryUser), - // NewValue: to.Ptr("someValue"), - // PreviousValue: to.Ptr("null"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeInsert), - // }, - // }, - // TargetResourceID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1"), - // TargetResourceType: to.Ptr("resourceProvider1/resourceType1"), - // }, - // }, - // { - // Name: to.Ptr("a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Type: to.Ptr("Microsoft.Resources/changes"), - // ID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1/Microsoft.Resources/changes/a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Properties: &armchanges.ChangeProperties{ - // ChangeAttributes: &armchanges.ChangeAttributes{ - // ChangesCount: to.Ptr[int64](0), - // CorrelationID: to.Ptr("88420d5d-8d0e-471f-9115-10d34750c617"), - // NewResourceSnapshotID: to.Ptr("4db20fc0-de17-4cdd-92d8-fd6bf94b9fd9"), - // PreviousResourceSnapshotID: to.Ptr("b09f5e52-0b46-4d13-84a9-08653d39fed6"), - // Timestamp: to.Ptr("2021-11-19T14:29:09.9210000Z"), - // }, - // ChangeType: to.Ptr(armchanges.ChangeTypeCreate), - // Changes: map[string]*armchanges.ChangeBase{ - // }, - // TargetResourceID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1"), - // TargetResourceType: to.Ptr("resourceProvider1/resourceType1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-05-01/examples/GetChange.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchanges.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "resourceGroup1", "resourceProvider1", "resourceType1", "resourceName1", "1d58d72f-0719-4a48-9228-b7ea682885bf", 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.ChangeResourceResult = armchanges.ChangeResourceResult{ - // Name: to.Ptr("1d58d72f-0719-4a48-9228-b7ea682885bf"), - // Type: to.Ptr("Microsoft.Resources/changes"), - // ID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1/Microsoft.Resources/changes/1d58d72f-0719-4a48-9228-b7ea682885bf"), - // Properties: &armchanges.ChangeProperties{ - // ChangeAttributes: &armchanges.ChangeAttributes{ - // ChangesCount: to.Ptr[int64](2), - // CorrelationID: to.Ptr("88420d5d-8d0e-471f-9115-10d34750c617"), - // NewResourceSnapshotID: to.Ptr("6eac9d0f-63b4-4e7f-97a5-740c73757efb"), - // PreviousResourceSnapshotID: to.Ptr("ed90e35a-1661-42cc-a44c-e27f508005be"), - // Timestamp: to.Ptr("2021-11-19T14:29:09.9210000Z"), - // }, - // ChangeType: to.Ptr(armchanges.ChangeTypeUpdate), - // Changes: map[string]*armchanges.ChangeBase{ - // "properties.provisioningState": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategorySystem), - // NewValue: to.Ptr("Succeeded"), - // PreviousValue: to.Ptr("Updating"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeUpdate), - // }, - // "tags.key1": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategoryUser), - // NewValue: to.Ptr("someValue"), - // PreviousValue: to.Ptr("null"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeInsert), - // }, - // }, - // TargetResourceID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1"), - // TargetResourceType: to.Ptr("resourceProvider1/resourceType1"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armchanges/client_factory.go b/sdk/resourcemanager/resources/armchanges/client_factory.go index b1eb0676c4bd..a5362ec77cb6 100644 --- a/sdk/resourcemanager/resources/armchanges/client_factory.go +++ b/sdk/resourcemanager/resources/armchanges/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -17,8 +14,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,18 +23,20 @@ type ClientFactory struct { // - 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, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armchanges/constants.go b/sdk/resourcemanager/resources/armchanges/constants.go index 127888bd0061..4d6327ffb098 100644 --- a/sdk/resourcemanager/resources/armchanges/constants.go +++ b/sdk/resourcemanager/resources/armchanges/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,7 +7,7 @@ package armchanges const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armchanges" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // ChangeCategory - The entity that made the change diff --git a/sdk/resourcemanager/resources/armchanges/fake/internal.go b/sdk/resourcemanager/resources/armchanges/fake/internal.go index 7d2f89ba4bb2..c614f8d5643a 100644 --- a/sdk/resourcemanager/resources/armchanges/fake/internal.go +++ b/sdk/resourcemanager/resources/armchanges/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/resources/armchanges/fake/server.go b/sdk/resourcemanager/resources/armchanges/fake/server.go index 48c0bdbf5c15..29632c91be3b 100644 --- a/sdk/resourcemanager/resources/armchanges/fake/server.go +++ b/sdk/resourcemanager/resources/armchanges/fake/server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -59,23 +56,42 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "Client.Get": - resp, err = s.dispatchGet(req) - case "Client.NewListPager": - resp, err = s.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -198,3 +214,9 @@ func (s *ServerTransport) dispatchNewListPager(req *http.Request) (*http.Respons } return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armchanges/fake/server_factory.go b/sdk/resourcemanager/resources/armchanges/fake/server_factory.go index e2cccec4594e..ec7b10766d41 100644 --- a/sdk/resourcemanager/resources/armchanges/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armchanges/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,6 +16,7 @@ import ( // ServerFactory is a fake server for instances of the armchanges.ClientFactory type. type ServerFactory struct { + // Server contains the fakes for client Client Server Server } diff --git a/sdk/resourcemanager/resources/armchanges/go.mod b/sdk/resourcemanager/resources/armchanges/go.mod index ac6116576ca5..668fd0152091 100644 --- a/sdk/resourcemanager/resources/armchanges/go.mod +++ b/sdk/resourcemanager/resources/armchanges/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armchange go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armchanges/go.sum b/sdk/resourcemanager/resources/armchanges/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/resources/armchanges/go.sum +++ b/sdk/resourcemanager/resources/armchanges/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -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-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armchanges/models.go b/sdk/resourcemanager/resources/armchanges/models.go index 3627a989c4ef..08ffb6bfa147 100644 --- a/sdk/resourcemanager/resources/armchanges/models.go +++ b/sdk/resourcemanager/resources/armchanges/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armchanges/models_serde.go b/sdk/resourcemanager/resources/armchanges/models_serde.go index af114ae11505..fa377b9f0131 100644 --- a/sdk/resourcemanager/resources/armchanges/models_serde.go +++ b/sdk/resourcemanager/resources/armchanges/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -367,7 +364,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/resources/armchanges/options.go b/sdk/resourcemanager/resources/armchanges/options.go index 6f5d82ce9e98..97351302a269 100644 --- a/sdk/resourcemanager/resources/armchanges/options.go +++ b/sdk/resourcemanager/resources/armchanges/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armchanges/response_types.go b/sdk/resourcemanager/resources/armchanges/responses.go similarity index 94% rename from sdk/resourcemanager/resources/armchanges/response_types.go rename to sdk/resourcemanager/resources/armchanges/responses.go index 2f363a93984b..a53c7bd60098 100644 --- a/sdk/resourcemanager/resources/armchanges/response_types.go +++ b/sdk/resourcemanager/resources/armchanges/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md b/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md index d653480c8669..b760277019aa 100644 --- a/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2025-04-28) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armfeatures/autorest.md b/sdk/resourcemanager/resources/armfeatures/autorest.md index 1a48abbc75ad..859da4552bad 100644 --- a/sdk/resourcemanager/resources/armfeatures/autorest.md +++ b/sdk/resourcemanager/resources/armfeatures/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/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: 1.2.0 +module-version: 1.2.1 package-features: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armfeatures/client.go b/sdk/resourcemanager/resources/armfeatures/client.go index 767899bcd7e2..2def8ece6caf 100644 --- a/sdk/resourcemanager/resources/armfeatures/client.go +++ b/sdk/resourcemanager/resources/armfeatures/client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -73,7 +70,7 @@ func (client *Client) Get(ctx context.Context, resourceProviderNamespace string, } // getCreateRequest creates the Get request. -func (client *Client) getCreateRequest(ctx context.Context, resourceProviderNamespace string, featureName string, options *ClientGetOptions) (*policy.Request, error) { +func (client *Client) getCreateRequest(ctx context.Context, resourceProviderNamespace string, featureName string, _ *ClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}" if resourceProviderNamespace == "" { return nil, errors.New("parameter resourceProviderNamespace cannot be empty") @@ -136,7 +133,7 @@ func (client *Client) NewListPager(resourceProviderNamespace string, options *Cl } // listCreateRequest creates the List request. -func (client *Client) listCreateRequest(ctx context.Context, resourceProviderNamespace string, options *ClientListOptions) (*policy.Request, error) { +func (client *Client) listCreateRequest(ctx context.Context, resourceProviderNamespace string, _ *ClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features" if resourceProviderNamespace == "" { return nil, errors.New("parameter resourceProviderNamespace cannot be empty") @@ -194,7 +191,7 @@ func (client *Client) NewListAllPager(options *ClientListAllOptions) *runtime.Pa } // listAllCreateRequest creates the ListAll request. -func (client *Client) listAllCreateRequest(ctx context.Context, options *ClientListAllOptions) (*policy.Request, error) { +func (client *Client) listAllCreateRequest(ctx context.Context, _ *ClientListAllOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/features" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -250,7 +247,7 @@ func (client *Client) Register(ctx context.Context, resourceProviderNamespace st } // registerCreateRequest creates the Register request. -func (client *Client) registerCreateRequest(ctx context.Context, resourceProviderNamespace string, featureName string, options *ClientRegisterOptions) (*policy.Request, error) { +func (client *Client) registerCreateRequest(ctx context.Context, resourceProviderNamespace string, featureName string, _ *ClientRegisterOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register" if resourceProviderNamespace == "" { return nil, errors.New("parameter resourceProviderNamespace cannot be empty") @@ -314,7 +311,7 @@ func (client *Client) Unregister(ctx context.Context, resourceProviderNamespace } // unregisterCreateRequest creates the Unregister request. -func (client *Client) unregisterCreateRequest(ctx context.Context, resourceProviderNamespace string, featureName string, options *ClientUnregisterOptions) (*policy.Request, error) { +func (client *Client) unregisterCreateRequest(ctx context.Context, resourceProviderNamespace string, featureName string, _ *ClientUnregisterOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister" if resourceProviderNamespace == "" { return nil, errors.New("parameter resourceProviderNamespace cannot be empty") diff --git a/sdk/resourcemanager/resources/armfeatures/client_example_test.go b/sdk/resourcemanager/resources/armfeatures/client_example_test.go deleted file mode 100644 index 3a2e23b144cb..000000000000 --- a/sdk/resourcemanager/resources/armfeatures/client_example_test.go +++ /dev/null @@ -1,190 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armfeatures_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json -func ExampleClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListAllPager(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.FeatureOperationsListResult = armfeatures.FeatureOperationsListResult{ - // Value: []*armfeatures.FeatureResult{ - // { - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // }, - // { - // Name: to.Ptr("Feature2"), - // Type: to.Ptr("type2"), - // ID: to.Ptr("feature_id2"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("unregistered"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json -func ExampleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListPager("Resource Provider Namespace", 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.FeatureOperationsListResult = armfeatures.FeatureOperationsListResult{ - // Value: []*armfeatures.FeatureResult{ - // { - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // }, - // { - // Name: to.Ptr("Feature2"), - // Type: to.Ptr("type2"), - // ID: to.Ptr("feature_id2"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("unregistered"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "Resource Provider Namespace", "feature", 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.FeatureResult = armfeatures.FeatureResult{ - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json -func ExampleClient_Register() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Register(ctx, "Resource Provider Namespace", "feature", 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.FeatureResult = armfeatures.FeatureResult{ - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json -func ExampleClient_Unregister() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Unregister(ctx, "Resource Provider Namespace", "feature", 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.FeatureResult = armfeatures.FeatureResult{ - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("Microsoft.Features/providers/features"), - // ID: to.Ptr("/subscriptions/ff23096b-f5a2-46ea-bd62-59c3e93fef9a/providers/Microsoft.Features/providers/Microsoft.Test/features/Feature1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("unregistered"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armfeatures/client_factory.go b/sdk/resourcemanager/resources/armfeatures/client_factory.go index 9b131cfb4178..f5aaba99cc9f 100644 --- a/sdk/resourcemanager/resources/armfeatures/client_factory.go +++ b/sdk/resourcemanager/resources/armfeatures/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -17,8 +14,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,30 +23,35 @@ type ClientFactory struct { // - 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, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewFeatureClient creates a new instance of FeatureClient. func (c *ClientFactory) NewFeatureClient() *FeatureClient { - subClient, _ := NewFeatureClient(c.credential, c.options) - return subClient + return &FeatureClient{ + internal: c.internal, + } } // NewSubscriptionFeatureRegistrationsClient creates a new instance of SubscriptionFeatureRegistrationsClient. func (c *ClientFactory) NewSubscriptionFeatureRegistrationsClient() *SubscriptionFeatureRegistrationsClient { - subClient, _ := NewSubscriptionFeatureRegistrationsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SubscriptionFeatureRegistrationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armfeatures/constants.go b/sdk/resourcemanager/resources/armfeatures/constants.go index eb6e8a88741a..b85f97791d58 100644 --- a/sdk/resourcemanager/resources/armfeatures/constants.go +++ b/sdk/resourcemanager/resources/armfeatures/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,7 +7,7 @@ package armfeatures const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // SubscriptionFeatureRegistrationApprovalType - The feature approval type. diff --git a/sdk/resourcemanager/resources/armfeatures/fake/feature_server.go b/sdk/resourcemanager/resources/armfeatures/fake/feature_server.go index 9b09f20f313e..a6f64eedee24 100644 --- a/sdk/resourcemanager/resources/armfeatures/fake/feature_server.go +++ b/sdk/resourcemanager/resources/armfeatures/fake/feature_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -51,21 +48,40 @@ func (f *FeatureServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return f.dispatchToMethodFake(req, method) +} - switch method { - case "FeatureClient.NewListOperationsPager": - resp, err = f.dispatchNewListOperationsPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (f *FeatureServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if featureServerTransportInterceptor != nil { + res.resp, res.err, intercepted = featureServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "FeatureClient.NewListOperationsPager": + res.resp, res.err = f.dispatchNewListOperationsPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (f *FeatureServerTransport) dispatchNewListOperationsPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (f *FeatureServerTransport) dispatchNewListOperationsPager(req *http.Reques } return resp, nil } + +// set this to conditionally intercept incoming requests to FeatureServerTransport +var featureServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armfeatures/fake/internal.go b/sdk/resourcemanager/resources/armfeatures/fake/internal.go index 5f75802a569e..4b65adc76adb 100644 --- a/sdk/resourcemanager/resources/armfeatures/fake/internal.go +++ b/sdk/resourcemanager/resources/armfeatures/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -14,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/resources/armfeatures/fake/server.go b/sdk/resourcemanager/resources/armfeatures/fake/server.go index e6a8f07651b8..e1400cf66ec0 100644 --- a/sdk/resourcemanager/resources/armfeatures/fake/server.go +++ b/sdk/resourcemanager/resources/armfeatures/fake/server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -72,29 +69,48 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "Client.Get": - resp, err = s.dispatchGet(req) - case "Client.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "Client.NewListAllPager": - resp, err = s.dispatchNewListAllPager(req) - case "Client.Register": - resp, err = s.dispatchRegister(req) - case "Client.Unregister": - resp, err = s.dispatchUnregister(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.NewListAllPager": + res.resp, res.err = s.dispatchNewListAllPager(req) + case "Client.Register": + res.resp, res.err = s.dispatchRegister(req) + case "Client.Unregister": + res.resp, res.err = s.dispatchUnregister(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -265,3 +281,9 @@ func (s *ServerTransport) dispatchUnregister(req *http.Request) (*http.Response, } return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armfeatures/fake/server_factory.go b/sdk/resourcemanager/resources/armfeatures/fake/server_factory.go index 5494daabc0c8..24388249e251 100644 --- a/sdk/resourcemanager/resources/armfeatures/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armfeatures/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,8 +16,13 @@ import ( // ServerFactory is a fake server for instances of the armfeatures.ClientFactory type. type ServerFactory struct { - Server Server - FeatureServer FeatureServer + // Server contains the fakes for client Client + Server Server + + // FeatureServer contains the fakes for client FeatureClient + FeatureServer FeatureServer + + // SubscriptionFeatureRegistrationsServer contains the fakes for client SubscriptionFeatureRegistrationsClient SubscriptionFeatureRegistrationsServer SubscriptionFeatureRegistrationsServer } diff --git a/sdk/resourcemanager/resources/armfeatures/fake/subscriptionfeatureregistrations_server.go b/sdk/resourcemanager/resources/armfeatures/fake/subscriptionfeatureregistrations_server.go index d1f7e69ce42f..aabe530ea2df 100644 --- a/sdk/resourcemanager/resources/armfeatures/fake/subscriptionfeatureregistrations_server.go +++ b/sdk/resourcemanager/resources/armfeatures/fake/subscriptionfeatureregistrations_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -73,29 +70,48 @@ func (s *SubscriptionFeatureRegistrationsServerTransport) Do(req *http.Request) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SubscriptionFeatureRegistrationsClient.CreateOrUpdate": - resp, err = s.dispatchCreateOrUpdate(req) - case "SubscriptionFeatureRegistrationsClient.Delete": - resp, err = s.dispatchDelete(req) - case "SubscriptionFeatureRegistrationsClient.Get": - resp, err = s.dispatchGet(req) - case "SubscriptionFeatureRegistrationsClient.NewListAllBySubscriptionPager": - resp, err = s.dispatchNewListAllBySubscriptionPager(req) - case "SubscriptionFeatureRegistrationsClient.NewListBySubscriptionPager": - resp, err = s.dispatchNewListBySubscriptionPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SubscriptionFeatureRegistrationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if subscriptionFeatureRegistrationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = subscriptionFeatureRegistrationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SubscriptionFeatureRegistrationsClient.CreateOrUpdate": + res.resp, res.err = s.dispatchCreateOrUpdate(req) + case "SubscriptionFeatureRegistrationsClient.Delete": + res.resp, res.err = s.dispatchDelete(req) + case "SubscriptionFeatureRegistrationsClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "SubscriptionFeatureRegistrationsClient.NewListAllBySubscriptionPager": + res.resp, res.err = s.dispatchNewListAllBySubscriptionPager(req) + case "SubscriptionFeatureRegistrationsClient.NewListBySubscriptionPager": + res.resp, res.err = s.dispatchNewListBySubscriptionPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SubscriptionFeatureRegistrationsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -276,3 +292,9 @@ func (s *SubscriptionFeatureRegistrationsServerTransport) dispatchNewListBySubsc } return resp, nil } + +// set this to conditionally intercept incoming requests to SubscriptionFeatureRegistrationsServerTransport +var subscriptionFeatureRegistrationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armfeatures/feature_client.go b/sdk/resourcemanager/resources/armfeatures/feature_client.go index b50bb8d3e355..129f252743a8 100644 --- a/sdk/resourcemanager/resources/armfeatures/feature_client.go +++ b/sdk/resourcemanager/resources/armfeatures/feature_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -66,7 +63,7 @@ func (client *FeatureClient) NewListOperationsPager(options *FeatureClientListOp } // listOperationsCreateRequest creates the ListOperations request. -func (client *FeatureClient) listOperationsCreateRequest(ctx context.Context, options *FeatureClientListOperationsOptions) (*policy.Request, error) { +func (client *FeatureClient) listOperationsCreateRequest(ctx context.Context, _ *FeatureClientListOperationsOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Features/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/sdk/resourcemanager/resources/armfeatures/feature_client_example_test.go b/sdk/resourcemanager/resources/armfeatures/feature_client_example_test.go deleted file mode 100644 index bd2c269e9cdb..000000000000 --- a/sdk/resourcemanager/resources/armfeatures/feature_client_example_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. -// DO NOT EDIT. - -package armfeatures_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listFeaturesOperations.json -func ExampleFeatureClient_NewListOperationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFeatureClient().NewListOperationsPager(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.OperationListResult = armfeatures.OperationListResult{ - // Value: []*armfeatures.Operation{ - // { - // Name: to.Ptr("FeaturesOpeartion1"), - // Display: &armfeatures.OperationDisplay{ - // Operation: to.Ptr("Read"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource1"), - // }, - // }, - // { - // Name: to.Ptr("FeaturesOpeartion2"), - // Display: &armfeatures.OperationDisplay{ - // Operation: to.Ptr("Write"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource2"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armfeatures/go.mod b/sdk/resourcemanager/resources/armfeatures/go.mod index a445c2bbdd78..7c9312e367a6 100644 --- a/sdk/resourcemanager/resources/armfeatures/go.mod +++ b/sdk/resourcemanager/resources/armfeatures/go.mod @@ -4,13 +4,13 @@ go 1.23.0 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.10.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armfeatures/models.go b/sdk/resourcemanager/resources/armfeatures/models.go index 22ce5dfe733c..51b90e302954 100644 --- a/sdk/resourcemanager/resources/armfeatures/models.go +++ b/sdk/resourcemanager/resources/armfeatures/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armfeatures/models_serde.go b/sdk/resourcemanager/resources/armfeatures/models_serde.go index ca4a215d3bab..db173266b2ab 100644 --- a/sdk/resourcemanager/resources/armfeatures/models_serde.go +++ b/sdk/resourcemanager/resources/armfeatures/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -509,7 +506,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/resources/armfeatures/options.go b/sdk/resourcemanager/resources/armfeatures/options.go index 5092b41920c5..8d1d42e9b063 100644 --- a/sdk/resourcemanager/resources/armfeatures/options.go +++ b/sdk/resourcemanager/resources/armfeatures/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armfeatures/response_types.go b/sdk/resourcemanager/resources/armfeatures/responses.go similarity index 98% rename from sdk/resourcemanager/resources/armfeatures/response_types.go rename to sdk/resourcemanager/resources/armfeatures/responses.go index d30455ab2a55..5191e8bfe153 100644 --- a/sdk/resourcemanager/resources/armfeatures/response_types.go +++ b/sdk/resourcemanager/resources/armfeatures/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client.go b/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client.go index cc67099e7d04..5ba92bd34320 100644 --- a/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client.go +++ b/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -144,7 +141,7 @@ func (client *SubscriptionFeatureRegistrationsClient) Delete(ctx context.Context } // deleteCreateRequest creates the Delete request. -func (client *SubscriptionFeatureRegistrationsClient) deleteCreateRequest(ctx context.Context, providerNamespace string, featureName string, options *SubscriptionFeatureRegistrationsClientDeleteOptions) (*policy.Request, error) { +func (client *SubscriptionFeatureRegistrationsClient) deleteCreateRequest(ctx context.Context, providerNamespace string, featureName string, _ *SubscriptionFeatureRegistrationsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -200,7 +197,7 @@ func (client *SubscriptionFeatureRegistrationsClient) Get(ctx context.Context, p } // getCreateRequest creates the Get request. -func (client *SubscriptionFeatureRegistrationsClient) getCreateRequest(ctx context.Context, providerNamespace string, featureName string, options *SubscriptionFeatureRegistrationsClientGetOptions) (*policy.Request, error) { +func (client *SubscriptionFeatureRegistrationsClient) getCreateRequest(ctx context.Context, providerNamespace string, featureName string, _ *SubscriptionFeatureRegistrationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations/{featureName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -263,7 +260,7 @@ func (client *SubscriptionFeatureRegistrationsClient) NewListAllBySubscriptionPa } // listAllBySubscriptionCreateRequest creates the ListAllBySubscription request. -func (client *SubscriptionFeatureRegistrationsClient) listAllBySubscriptionCreateRequest(ctx context.Context, options *SubscriptionFeatureRegistrationsClientListAllBySubscriptionOptions) (*policy.Request, error) { +func (client *SubscriptionFeatureRegistrationsClient) listAllBySubscriptionCreateRequest(ctx context.Context, _ *SubscriptionFeatureRegistrationsClientListAllBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/subscriptionFeatureRegistrations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -319,7 +316,7 @@ func (client *SubscriptionFeatureRegistrationsClient) NewListBySubscriptionPager } // listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *SubscriptionFeatureRegistrationsClient) listBySubscriptionCreateRequest(ctx context.Context, providerNamespace string, options *SubscriptionFeatureRegistrationsClientListBySubscriptionOptions) (*policy.Request, error) { +func (client *SubscriptionFeatureRegistrationsClient) listBySubscriptionCreateRequest(ctx context.Context, providerNamespace string, _ *SubscriptionFeatureRegistrationsClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Features/featureProviders/{providerNamespace}/subscriptionFeatureRegistrations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client_example_test.go b/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client_example_test.go deleted file mode 100644 index ec2ff1c617b1..000000000000 --- a/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client_example_test.go +++ /dev/null @@ -1,198 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armfeatures_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationGET.json -func ExampleSubscriptionFeatureRegistrationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionFeatureRegistrationsClient().Get(ctx, "subscriptionFeatureRegistrationGroupTestRG", "testFeature", 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.SubscriptionFeatureRegistration = armfeatures.SubscriptionFeatureRegistration{ - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationPUT.json -func ExampleSubscriptionFeatureRegistrationsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionFeatureRegistrationsClient().CreateOrUpdate(ctx, "subscriptionFeatureRegistrationGroupTestRG", "testFeature", &armfeatures.SubscriptionFeatureRegistrationsClientCreateOrUpdateOptions{SubscriptionFeatureRegistrationType: &armfeatures.SubscriptionFeatureRegistration{ - Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{}, - }, - }) - 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.SubscriptionFeatureRegistration = armfeatures.SubscriptionFeatureRegistration{ - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationDELETE.json -func ExampleSubscriptionFeatureRegistrationsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSubscriptionFeatureRegistrationsClient().Delete(ctx, "subscriptionFeatureRegistrationGroupTestRG", "testFeature", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLIST.json -func ExampleSubscriptionFeatureRegistrationsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSubscriptionFeatureRegistrationsClient().NewListBySubscriptionPager("subscriptionFeatureRegistrationGroupTestRG", 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.SubscriptionFeatureRegistrationList = armfeatures.SubscriptionFeatureRegistrationList{ - // Value: []*armfeatures.SubscriptionFeatureRegistration{ - // { - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLISTALL.json -func ExampleSubscriptionFeatureRegistrationsClient_NewListAllBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSubscriptionFeatureRegistrationsClient().NewListAllBySubscriptionPager(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.SubscriptionFeatureRegistrationList = armfeatures.SubscriptionFeatureRegistrationList{ - // Value: []*armfeatures.SubscriptionFeatureRegistration{ - // { - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armfeatures/time_rfc3339.go b/sdk/resourcemanager/resources/armfeatures/time_rfc3339.go index 19d49fb2bc17..b05d23038de8 100644 --- a/sdk/resourcemanager/resources/armfeatures/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armfeatures/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,12 +16,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +41,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/resources/armlinks/CHANGELOG.md b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md index 29bb7be8f7bd..3e50cdc504c3 100644 --- a/sdk/resourcemanager/resources/armlinks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2025-04-28) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armlinks/autorest.md b/sdk/resourcemanager/resources/armlinks/autorest.md index cd3b42a8b2b7..87be6eb06de5 100644 --- a/sdk/resourcemanager/resources/armlinks/autorest.md +++ b/sdk/resourcemanager/resources/armlinks/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/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: 1.2.0 +module-version: 1.2.1 package-links: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armlinks/client_factory.go b/sdk/resourcemanager/resources/armlinks/client_factory.go index d2403f979d20..cf4b8c7e5e28 100644 --- a/sdk/resourcemanager/resources/armlinks/client_factory.go +++ b/sdk/resourcemanager/resources/armlinks/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -17,8 +14,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,24 +23,27 @@ type ClientFactory struct { // - 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, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewResourceLinksClient creates a new instance of ResourceLinksClient. func (c *ClientFactory) NewResourceLinksClient() *ResourceLinksClient { - subClient, _ := NewResourceLinksClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ResourceLinksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armlinks/constants.go b/sdk/resourcemanager/resources/armlinks/constants.go index 754be60ee9b1..89ae18a51a8d 100644 --- a/sdk/resourcemanager/resources/armlinks/constants.go +++ b/sdk/resourcemanager/resources/armlinks/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,5 +7,5 @@ package armlinks const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlinks" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) diff --git a/sdk/resourcemanager/resources/armlinks/fake/internal.go b/sdk/resourcemanager/resources/armlinks/fake/internal.go index 94e060e89dbd..486a30a014e6 100644 --- a/sdk/resourcemanager/resources/armlinks/fake/internal.go +++ b/sdk/resourcemanager/resources/armlinks/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/resources/armlinks/fake/operations_server.go b/sdk/resourcemanager/resources/armlinks/fake/operations_server.go index a99eef79d634..dd4d5db5ae84 100644 --- a/sdk/resourcemanager/resources/armlinks/fake/operations_server.go +++ b/sdk/resourcemanager/resources/armlinks/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armlinks/fake/resourcelinks_server.go b/sdk/resourcemanager/resources/armlinks/fake/resourcelinks_server.go index c476d75eefd4..6f49f23baad9 100644 --- a/sdk/resourcemanager/resources/armlinks/fake/resourcelinks_server.go +++ b/sdk/resourcemanager/resources/armlinks/fake/resourcelinks_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -72,29 +69,48 @@ func (r *ResourceLinksServerTransport) Do(req *http.Request) (*http.Response, er return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ResourceLinksClient.CreateOrUpdate": - resp, err = r.dispatchCreateOrUpdate(req) - case "ResourceLinksClient.Delete": - resp, err = r.dispatchDelete(req) - case "ResourceLinksClient.Get": - resp, err = r.dispatchGet(req) - case "ResourceLinksClient.NewListAtSourceScopePager": - resp, err = r.dispatchNewListAtSourceScopePager(req) - case "ResourceLinksClient.NewListAtSubscriptionPager": - resp, err = r.dispatchNewListAtSubscriptionPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ResourceLinksServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if resourceLinksServerTransportInterceptor != nil { + res.resp, res.err, intercepted = resourceLinksServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ResourceLinksClient.CreateOrUpdate": + res.resp, res.err = r.dispatchCreateOrUpdate(req) + case "ResourceLinksClient.Delete": + res.resp, res.err = r.dispatchDelete(req) + case "ResourceLinksClient.Get": + res.resp, res.err = r.dispatchGet(req) + case "ResourceLinksClient.NewListAtSourceScopePager": + res.resp, res.err = r.dispatchNewListAtSourceScopePager(req) + case "ResourceLinksClient.NewListAtSubscriptionPager": + res.resp, res.err = r.dispatchNewListAtSubscriptionPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ResourceLinksServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -281,3 +297,9 @@ func (r *ResourceLinksServerTransport) dispatchNewListAtSubscriptionPager(req *h } return resp, nil } + +// set this to conditionally intercept incoming requests to ResourceLinksServerTransport +var resourceLinksServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armlinks/fake/server_factory.go b/sdk/resourcemanager/resources/armlinks/fake/server_factory.go index 1284a867b5f4..4faaecdc48e3 100644 --- a/sdk/resourcemanager/resources/armlinks/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armlinks/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,7 +16,10 @@ import ( // ServerFactory is a fake server for instances of the armlinks.ClientFactory type. type ServerFactory struct { - OperationsServer OperationsServer + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // ResourceLinksServer contains the fakes for client ResourceLinksClient ResourceLinksServer ResourceLinksServer } diff --git a/sdk/resourcemanager/resources/armlinks/models.go b/sdk/resourcemanager/resources/armlinks/models.go index 8afa39bdbbd5..ef491e52a96f 100644 --- a/sdk/resourcemanager/resources/armlinks/models.go +++ b/sdk/resourcemanager/resources/armlinks/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armlinks/models_serde.go b/sdk/resourcemanager/resources/armlinks/models_serde.go index acdd748cf488..c73df837a56a 100644 --- a/sdk/resourcemanager/resources/armlinks/models_serde.go +++ b/sdk/resourcemanager/resources/armlinks/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -269,7 +266,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/resources/armlinks/operations_client.go b/sdk/resourcemanager/resources/armlinks/operations_client.go index 41f4d008c925..4a7bc285789f 100644 --- a/sdk/resourcemanager/resources/armlinks/operations_client.go +++ b/sdk/resourcemanager/resources/armlinks/operations_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -65,7 +62,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/sdk/resourcemanager/resources/armlinks/options.go b/sdk/resourcemanager/resources/armlinks/options.go index 229b750e8583..239561ad2d8d 100644 --- a/sdk/resourcemanager/resources/armlinks/options.go +++ b/sdk/resourcemanager/resources/armlinks/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go b/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go index 97406714ec9d..ea363890a571 100644 --- a/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go +++ b/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -77,7 +74,7 @@ func (client *ResourceLinksClient) CreateOrUpdate(ctx context.Context, linkID st } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ResourceLinksClient) createOrUpdateCreateRequest(ctx context.Context, linkID string, parameters ResourceLink, options *ResourceLinksClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ResourceLinksClient) createOrUpdateCreateRequest(ctx context.Context, linkID string, parameters ResourceLink, _ *ResourceLinksClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{linkId}" urlPath = strings.ReplaceAll(urlPath, "{linkId}", linkID) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -134,7 +131,7 @@ func (client *ResourceLinksClient) Delete(ctx context.Context, linkID string, op } // deleteCreateRequest creates the Delete request. -func (client *ResourceLinksClient) deleteCreateRequest(ctx context.Context, linkID string, options *ResourceLinksClientDeleteOptions) (*policy.Request, error) { +func (client *ResourceLinksClient) deleteCreateRequest(ctx context.Context, linkID string, _ *ResourceLinksClientDeleteOptions) (*policy.Request, error) { urlPath := "/{linkId}" urlPath = strings.ReplaceAll(urlPath, "{linkId}", linkID) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -176,7 +173,7 @@ func (client *ResourceLinksClient) Get(ctx context.Context, linkID string, optio } // getCreateRequest creates the Get request. -func (client *ResourceLinksClient) getCreateRequest(ctx context.Context, linkID string, options *ResourceLinksClientGetOptions) (*policy.Request, error) { +func (client *ResourceLinksClient) getCreateRequest(ctx context.Context, linkID string, _ *ResourceLinksClientGetOptions) (*policy.Request, error) { urlPath := "/{linkId}" urlPath = strings.ReplaceAll(urlPath, "{linkId}", linkID) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) diff --git a/sdk/resourcemanager/resources/armlinks/response_types.go b/sdk/resourcemanager/resources/armlinks/responses.go similarity index 97% rename from sdk/resourcemanager/resources/armlinks/response_types.go rename to sdk/resourcemanager/resources/armlinks/responses.go index 4e5421d02af3..0f8d262d1fa7 100644 --- a/sdk/resourcemanager/resources/armlinks/response_types.go +++ b/sdk/resourcemanager/resources/armlinks/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armlocks/CHANGELOG.md b/sdk/resourcemanager/resources/armlocks/CHANGELOG.md index f642f9e83509..6e93cc5844d6 100644 --- a/sdk/resourcemanager/resources/armlocks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armlocks/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2025-04-28) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armlocks/authorizationoperations_client.go b/sdk/resourcemanager/resources/armlocks/authorizationoperations_client.go index 8175cad10457..b181c8fd7a62 100644 --- a/sdk/resourcemanager/resources/armlocks/authorizationoperations_client.go +++ b/sdk/resourcemanager/resources/armlocks/authorizationoperations_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -66,7 +63,7 @@ func (client *AuthorizationOperationsClient) NewListPager(options *Authorization } // listCreateRequest creates the List request. -func (client *AuthorizationOperationsClient) listCreateRequest(ctx context.Context, options *AuthorizationOperationsClientListOptions) (*policy.Request, error) { +func (client *AuthorizationOperationsClient) listCreateRequest(ctx context.Context, _ *AuthorizationOperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Authorization/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/sdk/resourcemanager/resources/armlocks/authorizationoperations_client_example_test.go b/sdk/resourcemanager/resources/armlocks/authorizationoperations_client_example_test.go deleted file mode 100644 index 8113cd1323bc..000000000000 --- a/sdk/resourcemanager/resources/armlocks/authorizationoperations_client_example_test.go +++ /dev/null @@ -1,54 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armlocks_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json -func ExampleAuthorizationOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAuthorizationOperationsClient().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.OperationListResult = armlocks.OperationListResult{ - // Value: []*armlocks.Operation{ - // { - // Name: to.Ptr("Microsoft.Authorization/locks/read"), - // Display: &armlocks.OperationDisplay{ - // Operation: to.Ptr("read"), - // Provider: to.Ptr("Microsoft.Authorization"), - // Resource: to.Ptr("locks"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armlocks/autorest.md b/sdk/resourcemanager/resources/armlocks/autorest.md index 7217053d37ca..b09e7157848e 100644 --- a/sdk/resourcemanager/resources/armlocks/autorest.md +++ b/sdk/resourcemanager/resources/armlocks/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/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: 1.2.0 +module-version: 1.2.1 package-locks: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armlocks/client_factory.go b/sdk/resourcemanager/resources/armlocks/client_factory.go index ede49372b654..8b02fea96462 100644 --- a/sdk/resourcemanager/resources/armlocks/client_factory.go +++ b/sdk/resourcemanager/resources/armlocks/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -17,8 +14,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,24 +23,27 @@ type ClientFactory struct { // - 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, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAuthorizationOperationsClient creates a new instance of AuthorizationOperationsClient. func (c *ClientFactory) NewAuthorizationOperationsClient() *AuthorizationOperationsClient { - subClient, _ := NewAuthorizationOperationsClient(c.credential, c.options) - return subClient + return &AuthorizationOperationsClient{ + internal: c.internal, + } } // NewManagementLocksClient creates a new instance of ManagementLocksClient. func (c *ClientFactory) NewManagementLocksClient() *ManagementLocksClient { - subClient, _ := NewManagementLocksClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ManagementLocksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armlocks/constants.go b/sdk/resourcemanager/resources/armlocks/constants.go index f54d3758f0cd..62c605e133a1 100644 --- a/sdk/resourcemanager/resources/armlocks/constants.go +++ b/sdk/resourcemanager/resources/armlocks/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,7 +7,7 @@ package armlocks const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/resources/armlocks/fake/authorizationoperations_server.go b/sdk/resourcemanager/resources/armlocks/fake/authorizationoperations_server.go index e0f2f136ad2a..c4a55c4b4c72 100644 --- a/sdk/resourcemanager/resources/armlocks/fake/authorizationoperations_server.go +++ b/sdk/resourcemanager/resources/armlocks/fake/authorizationoperations_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -51,21 +48,40 @@ func (a *AuthorizationOperationsServerTransport) Do(req *http.Request) (*http.Re return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AuthorizationOperationsClient.NewListPager": - resp, err = a.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AuthorizationOperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if authorizationOperationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = authorizationOperationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AuthorizationOperationsClient.NewListPager": + res.resp, res.err = a.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AuthorizationOperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (a *AuthorizationOperationsServerTransport) dispatchNewListPager(req *http. } return resp, nil } + +// set this to conditionally intercept incoming requests to AuthorizationOperationsServerTransport +var authorizationOperationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armlocks/fake/internal.go b/sdk/resourcemanager/resources/armlocks/fake/internal.go index 94e060e89dbd..486a30a014e6 100644 --- a/sdk/resourcemanager/resources/armlocks/fake/internal.go +++ b/sdk/resourcemanager/resources/armlocks/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/resources/armlocks/fake/managementlocks_server.go b/sdk/resourcemanager/resources/armlocks/fake/managementlocks_server.go index 8141d36c4c4f..5725f8ba3a0f 100644 --- a/sdk/resourcemanager/resources/armlocks/fake/managementlocks_server.go +++ b/sdk/resourcemanager/resources/armlocks/fake/managementlocks_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -120,51 +117,70 @@ func (m *ManagementLocksServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel": - resp, err = m.dispatchCreateOrUpdateAtResourceGroupLevel(req) - case "ManagementLocksClient.CreateOrUpdateAtResourceLevel": - resp, err = m.dispatchCreateOrUpdateAtResourceLevel(req) - case "ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel": - resp, err = m.dispatchCreateOrUpdateAtSubscriptionLevel(req) - case "ManagementLocksClient.CreateOrUpdateByScope": - resp, err = m.dispatchCreateOrUpdateByScope(req) - case "ManagementLocksClient.DeleteAtResourceGroupLevel": - resp, err = m.dispatchDeleteAtResourceGroupLevel(req) - case "ManagementLocksClient.DeleteAtResourceLevel": - resp, err = m.dispatchDeleteAtResourceLevel(req) - case "ManagementLocksClient.DeleteAtSubscriptionLevel": - resp, err = m.dispatchDeleteAtSubscriptionLevel(req) - case "ManagementLocksClient.DeleteByScope": - resp, err = m.dispatchDeleteByScope(req) - case "ManagementLocksClient.GetAtResourceGroupLevel": - resp, err = m.dispatchGetAtResourceGroupLevel(req) - case "ManagementLocksClient.GetAtResourceLevel": - resp, err = m.dispatchGetAtResourceLevel(req) - case "ManagementLocksClient.GetAtSubscriptionLevel": - resp, err = m.dispatchGetAtSubscriptionLevel(req) - case "ManagementLocksClient.GetByScope": - resp, err = m.dispatchGetByScope(req) - case "ManagementLocksClient.NewListAtResourceGroupLevelPager": - resp, err = m.dispatchNewListAtResourceGroupLevelPager(req) - case "ManagementLocksClient.NewListAtResourceLevelPager": - resp, err = m.dispatchNewListAtResourceLevelPager(req) - case "ManagementLocksClient.NewListAtSubscriptionLevelPager": - resp, err = m.dispatchNewListAtSubscriptionLevelPager(req) - case "ManagementLocksClient.NewListByScopePager": - resp, err = m.dispatchNewListByScopePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return m.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (m *ManagementLocksServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - return resp, nil + go func() { + var intercepted bool + var res result + if managementLocksServerTransportInterceptor != nil { + res.resp, res.err, intercepted = managementLocksServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ManagementLocksClient.CreateOrUpdateAtResourceGroupLevel": + res.resp, res.err = m.dispatchCreateOrUpdateAtResourceGroupLevel(req) + case "ManagementLocksClient.CreateOrUpdateAtResourceLevel": + res.resp, res.err = m.dispatchCreateOrUpdateAtResourceLevel(req) + case "ManagementLocksClient.CreateOrUpdateAtSubscriptionLevel": + res.resp, res.err = m.dispatchCreateOrUpdateAtSubscriptionLevel(req) + case "ManagementLocksClient.CreateOrUpdateByScope": + res.resp, res.err = m.dispatchCreateOrUpdateByScope(req) + case "ManagementLocksClient.DeleteAtResourceGroupLevel": + res.resp, res.err = m.dispatchDeleteAtResourceGroupLevel(req) + case "ManagementLocksClient.DeleteAtResourceLevel": + res.resp, res.err = m.dispatchDeleteAtResourceLevel(req) + case "ManagementLocksClient.DeleteAtSubscriptionLevel": + res.resp, res.err = m.dispatchDeleteAtSubscriptionLevel(req) + case "ManagementLocksClient.DeleteByScope": + res.resp, res.err = m.dispatchDeleteByScope(req) + case "ManagementLocksClient.GetAtResourceGroupLevel": + res.resp, res.err = m.dispatchGetAtResourceGroupLevel(req) + case "ManagementLocksClient.GetAtResourceLevel": + res.resp, res.err = m.dispatchGetAtResourceLevel(req) + case "ManagementLocksClient.GetAtSubscriptionLevel": + res.resp, res.err = m.dispatchGetAtSubscriptionLevel(req) + case "ManagementLocksClient.GetByScope": + res.resp, res.err = m.dispatchGetByScope(req) + case "ManagementLocksClient.NewListAtResourceGroupLevelPager": + res.resp, res.err = m.dispatchNewListAtResourceGroupLevelPager(req) + case "ManagementLocksClient.NewListAtResourceLevelPager": + res.resp, res.err = m.dispatchNewListAtResourceLevelPager(req) + case "ManagementLocksClient.NewListAtSubscriptionLevelPager": + res.resp, res.err = m.dispatchNewListAtSubscriptionLevelPager(req) + case "ManagementLocksClient.NewListByScopePager": + res.resp, res.err = m.dispatchNewListByScopePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (m *ManagementLocksServerTransport) dispatchCreateOrUpdateAtResourceGroupLevel(req *http.Request) (*http.Response, error) { @@ -822,3 +838,9 @@ func (m *ManagementLocksServerTransport) dispatchNewListByScopePager(req *http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to ManagementLocksServerTransport +var managementLocksServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armlocks/fake/server_factory.go b/sdk/resourcemanager/resources/armlocks/fake/server_factory.go index e6f9788dcf71..2a9e21265626 100644 --- a/sdk/resourcemanager/resources/armlocks/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armlocks/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,8 +16,11 @@ import ( // ServerFactory is a fake server for instances of the armlocks.ClientFactory type. type ServerFactory struct { + // AuthorizationOperationsServer contains the fakes for client AuthorizationOperationsClient AuthorizationOperationsServer AuthorizationOperationsServer - ManagementLocksServer ManagementLocksServer + + // ManagementLocksServer contains the fakes for client ManagementLocksClient + ManagementLocksServer ManagementLocksServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. diff --git a/sdk/resourcemanager/resources/armlocks/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armlocks/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/resources/armlocks/fake/time_rfc3339.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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) - -const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { - layout = dateTimeJSON - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/resources/armlocks/go.mod b/sdk/resourcemanager/resources/armlocks/go.mod index 0cb7f9e254d9..83db411f2653 100644 --- a/sdk/resourcemanager/resources/armlocks/go.mod +++ b/sdk/resourcemanager/resources/armlocks/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armlocks/go.sum b/sdk/resourcemanager/resources/armlocks/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/resources/armlocks/go.sum +++ b/sdk/resourcemanager/resources/armlocks/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -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-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armlocks/managementlocks_client.go b/sdk/resourcemanager/resources/armlocks/managementlocks_client.go index 18e526b25d0c..fb6e500eece0 100644 --- a/sdk/resourcemanager/resources/armlocks/managementlocks_client.go +++ b/sdk/resourcemanager/resources/armlocks/managementlocks_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -78,7 +75,7 @@ func (client *ManagementLocksClient) CreateOrUpdateAtResourceGroupLevel(ctx cont } // createOrUpdateAtResourceGroupLevelCreateRequest creates the CreateOrUpdateAtResourceGroupLevel request. -func (client *ManagementLocksClient) createOrUpdateAtResourceGroupLevelCreateRequest(ctx context.Context, resourceGroupName string, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) createOrUpdateAtResourceGroupLevelCreateRequest(ctx context.Context, resourceGroupName string, lockName string, parameters ManagementLockObject, _ *ManagementLocksClientCreateOrUpdateAtResourceGroupLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -154,7 +151,7 @@ func (client *ManagementLocksClient) CreateOrUpdateAtResourceLevel(ctx context.C } // createOrUpdateAtResourceLevelCreateRequest creates the CreateOrUpdateAtResourceLevel request. -func (client *ManagementLocksClient) createOrUpdateAtResourceLevelCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateAtResourceLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) createOrUpdateAtResourceLevelCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, parameters ManagementLockObject, _ *ManagementLocksClientCreateOrUpdateAtResourceLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -235,7 +232,7 @@ func (client *ManagementLocksClient) CreateOrUpdateAtSubscriptionLevel(ctx conte } // createOrUpdateAtSubscriptionLevelCreateRequest creates the CreateOrUpdateAtSubscriptionLevel request. -func (client *ManagementLocksClient) createOrUpdateAtSubscriptionLevelCreateRequest(ctx context.Context, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) createOrUpdateAtSubscriptionLevelCreateRequest(ctx context.Context, lockName string, parameters ManagementLockObject, _ *ManagementLocksClientCreateOrUpdateAtSubscriptionLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" if lockName == "" { return nil, errors.New("parameter lockName cannot be empty") @@ -304,7 +301,7 @@ func (client *ManagementLocksClient) CreateOrUpdateByScope(ctx context.Context, } // createOrUpdateByScopeCreateRequest creates the CreateOrUpdateByScope request. -func (client *ManagementLocksClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, lockName string, parameters ManagementLockObject, options *ManagementLocksClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, lockName string, parameters ManagementLockObject, _ *ManagementLocksClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Authorization/locks/{lockName}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -369,7 +366,7 @@ func (client *ManagementLocksClient) DeleteAtResourceGroupLevel(ctx context.Cont } // deleteAtResourceGroupLevelCreateRequest creates the DeleteAtResourceGroupLevel request. -func (client *ManagementLocksClient) deleteAtResourceGroupLevelCreateRequest(ctx context.Context, resourceGroupName string, lockName string, options *ManagementLocksClientDeleteAtResourceGroupLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) deleteAtResourceGroupLevelCreateRequest(ctx context.Context, resourceGroupName string, lockName string, _ *ManagementLocksClientDeleteAtResourceGroupLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -430,7 +427,7 @@ func (client *ManagementLocksClient) DeleteAtResourceLevel(ctx context.Context, } // deleteAtResourceLevelCreateRequest creates the DeleteAtResourceLevel request. -func (client *ManagementLocksClient) deleteAtResourceLevelCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, options *ManagementLocksClientDeleteAtResourceLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) deleteAtResourceLevelCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, _ *ManagementLocksClientDeleteAtResourceLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -496,7 +493,7 @@ func (client *ManagementLocksClient) DeleteAtSubscriptionLevel(ctx context.Conte } // deleteAtSubscriptionLevelCreateRequest creates the DeleteAtSubscriptionLevel request. -func (client *ManagementLocksClient) deleteAtSubscriptionLevelCreateRequest(ctx context.Context, lockName string, options *ManagementLocksClientDeleteAtSubscriptionLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) deleteAtSubscriptionLevelCreateRequest(ctx context.Context, lockName string, _ *ManagementLocksClientDeleteAtSubscriptionLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" if lockName == "" { return nil, errors.New("parameter lockName cannot be empty") @@ -547,7 +544,7 @@ func (client *ManagementLocksClient) DeleteByScope(ctx context.Context, scope st } // deleteByScopeCreateRequest creates the DeleteByScope request. -func (client *ManagementLocksClient) deleteByScopeCreateRequest(ctx context.Context, scope string, lockName string, options *ManagementLocksClientDeleteByScopeOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) deleteByScopeCreateRequest(ctx context.Context, scope string, lockName string, _ *ManagementLocksClientDeleteByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Authorization/locks/{lockName}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -599,7 +596,7 @@ func (client *ManagementLocksClient) GetAtResourceGroupLevel(ctx context.Context } // getAtResourceGroupLevelCreateRequest creates the GetAtResourceGroupLevel request. -func (client *ManagementLocksClient) getAtResourceGroupLevelCreateRequest(ctx context.Context, resourceGroupName string, lockName string, options *ManagementLocksClientGetAtResourceGroupLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) getAtResourceGroupLevelCreateRequest(ctx context.Context, resourceGroupName string, lockName string, _ *ManagementLocksClientGetAtResourceGroupLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -668,7 +665,7 @@ func (client *ManagementLocksClient) GetAtResourceLevel(ctx context.Context, res } // getAtResourceLevelCreateRequest creates the GetAtResourceLevel request. -func (client *ManagementLocksClient) getAtResourceLevelCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, options *ManagementLocksClientGetAtResourceLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) getAtResourceLevelCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, lockName string, _ *ManagementLocksClientGetAtResourceLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -742,7 +739,7 @@ func (client *ManagementLocksClient) GetAtSubscriptionLevel(ctx context.Context, } // getAtSubscriptionLevelCreateRequest creates the GetAtSubscriptionLevel request. -func (client *ManagementLocksClient) getAtSubscriptionLevelCreateRequest(ctx context.Context, lockName string, options *ManagementLocksClientGetAtSubscriptionLevelOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) getAtSubscriptionLevelCreateRequest(ctx context.Context, lockName string, _ *ManagementLocksClientGetAtSubscriptionLevelOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}" if lockName == "" { return nil, errors.New("parameter lockName cannot be empty") @@ -803,7 +800,7 @@ func (client *ManagementLocksClient) GetByScope(ctx context.Context, scope strin } // getByScopeCreateRequest creates the GetByScope request. -func (client *ManagementLocksClient) getByScopeCreateRequest(ctx context.Context, scope string, lockName string, options *ManagementLocksClientGetByScopeOptions) (*policy.Request, error) { +func (client *ManagementLocksClient) getByScopeCreateRequest(ctx context.Context, scope string, lockName string, _ *ManagementLocksClientGetByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Authorization/locks/{lockName}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") diff --git a/sdk/resourcemanager/resources/armlocks/managementlocks_client_example_test.go b/sdk/resourcemanager/resources/armlocks/managementlocks_client_example_test.go deleted file mode 100644 index 1458096d49a9..000000000000 --- a/sdk/resourcemanager/resources/armlocks/managementlocks_client_example_test.go +++ /dev/null @@ -1,471 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armlocks_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/armlocks" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json -func ExampleManagementLocksClient_DeleteAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json -func ExampleManagementLocksClient_GetAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json -func ExampleManagementLocksClient_CreateOrUpdateByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateByScope(ctx, "subscriptions/subscriptionId", "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json -func ExampleManagementLocksClient_DeleteByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteByScope(ctx, "subscriptions/subscriptionId", "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json -func ExampleManagementLocksClient_GetByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetByScope(ctx, "subscriptions/subscriptionId", "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json -func ExampleManagementLocksClient_DeleteAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json -func ExampleManagementLocksClient_GetAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtSubscriptionLevel(ctx, "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json -func ExampleManagementLocksClient_DeleteAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteAtSubscriptionLevel(ctx, "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json -func ExampleManagementLocksClient_GetAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetAtSubscriptionLevel(ctx, "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json -func ExampleManagementLocksClient_NewListAtResourceGroupLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListAtResourceGroupLevelPager("resourcegroupname", &armlocks.ManagementLocksClientListAtResourceGroupLevelOptions{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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json -func ExampleManagementLocksClient_NewListAtResourceLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListAtResourceLevelPager("resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", &armlocks.ManagementLocksClientListAtResourceLevelOptions{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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json -func ExampleManagementLocksClient_NewListAtSubscriptionLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListAtSubscriptionLevelPager(&armlocks.ManagementLocksClientListAtSubscriptionLevelOptions{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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json -func ExampleManagementLocksClient_NewListByScopePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListByScopePager("subscriptions/subscriptionId", &armlocks.ManagementLocksClientListByScopeOptions{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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armlocks/models.go b/sdk/resourcemanager/resources/armlocks/models.go index 59b3b07c7d91..00e5cd4d4116 100644 --- a/sdk/resourcemanager/resources/armlocks/models.go +++ b/sdk/resourcemanager/resources/armlocks/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armlocks/models_serde.go b/sdk/resourcemanager/resources/armlocks/models_serde.go index 238ddc6ac501..0711c0abab80 100644 --- a/sdk/resourcemanager/resources/armlocks/models_serde.go +++ b/sdk/resourcemanager/resources/armlocks/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -417,7 +414,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/resources/armlocks/options.go b/sdk/resourcemanager/resources/armlocks/options.go index 2e4b37ceb684..c75d011b9188 100644 --- a/sdk/resourcemanager/resources/armlocks/options.go +++ b/sdk/resourcemanager/resources/armlocks/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armlocks/response_types.go b/sdk/resourcemanager/resources/armlocks/responses.go similarity index 99% rename from sdk/resourcemanager/resources/armlocks/response_types.go rename to sdk/resourcemanager/resources/armlocks/responses.go index 15ee181e7c0e..cb3d23629135 100644 --- a/sdk/resourcemanager/resources/armlocks/response_types.go +++ b/sdk/resourcemanager/resources/armlocks/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armlocks/time_rfc3339.go b/sdk/resourcemanager/resources/armlocks/time_rfc3339.go index 043a6952fc7a..3bb6e37daf89 100644 --- a/sdk/resourcemanager/resources/armlocks/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armlocks/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,12 +16,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +41,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/resources/armmanagedapplications/CHANGELOG.md b/sdk/resourcemanager/resources/armmanagedapplications/CHANGELOG.md index 2bb309ae12ac..6a80b0a37706 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armmanagedapplications/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2025-04-28) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armmanagedapplications/README.md b/sdk/resourcemanager/resources/armmanagedapplications/README.md index 4dd0dd71e8c4..b6b1e00a2971 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/README.md +++ b/sdk/resourcemanager/resources/armmanagedapplications/README.md @@ -55,7 +55,7 @@ clientFactory, err := armmanagedapplications.NewClientFactory(, 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.NewApplicationClient() +client := clientFactory.NewApplicationDefinitionsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/resources/armmanagedapplications/application_client.go b/sdk/resourcemanager/resources/armmanagedapplications/application_client.go index 97bb7ef77aec..30b08f397675 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/application_client.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/application_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -66,7 +63,7 @@ func (client *ApplicationClient) NewListOperationsPager(options *ApplicationClie } // listOperationsCreateRequest creates the ListOperations request. -func (client *ApplicationClient) listOperationsCreateRequest(ctx context.Context, options *ApplicationClientListOperationsOptions) (*policy.Request, error) { +func (client *ApplicationClient) listOperationsCreateRequest(ctx context.Context, _ *ApplicationClientListOperationsOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Solutions/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/sdk/resourcemanager/resources/armmanagedapplications/application_client_example_test.go b/sdk/resourcemanager/resources/armmanagedapplications/application_client_example_test.go deleted file mode 100644 index a65aa4faf1de..000000000000 --- a/sdk/resourcemanager/resources/armmanagedapplications/application_client_example_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. -// DO NOT EDIT. - -package armmanagedapplications_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listSolutionsOperations.json -func ExampleApplicationClient_NewListOperationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationClient().NewListOperationsPager(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.OperationListResult = armmanagedapplications.OperationListResult{ - // Value: []*armmanagedapplications.Operation{ - // { - // Name: to.Ptr("SolutionsOpeartion1"), - // Display: &armmanagedapplications.OperationDisplay{ - // Operation: to.Ptr("Read"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource1"), - // }, - // }, - // { - // Name: to.Ptr("SolutionssOpeartion2"), - // Display: &armmanagedapplications.OperationDisplay{ - // Operation: to.Ptr("Write"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource2"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client.go b/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client.go index 35f9720d0ab7..567191464c93 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -95,7 +92,7 @@ func (client *ApplicationDefinitionsClient) createOrUpdate(ctx context.Context, } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ApplicationDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, _ *ApplicationDefinitionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -175,7 +172,7 @@ func (client *ApplicationDefinitionsClient) createOrUpdateByID(ctx context.Conte } // createOrUpdateByIDCreateRequest creates the CreateOrUpdateByID request. -func (client *ApplicationDefinitionsClient) createOrUpdateByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientBeginCreateOrUpdateByIDOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) createOrUpdateByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, _ *ApplicationDefinitionsClientBeginCreateOrUpdateByIDOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -254,7 +251,7 @@ func (client *ApplicationDefinitionsClient) deleteOperation(ctx context.Context, } // deleteCreateRequest creates the Delete request. -func (client *ApplicationDefinitionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, _ *ApplicationDefinitionsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -330,7 +327,7 @@ func (client *ApplicationDefinitionsClient) deleteByID(ctx context.Context, reso } // deleteByIDCreateRequest creates the DeleteByID request. -func (client *ApplicationDefinitionsClient) deleteByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientBeginDeleteByIDOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) deleteByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, _ *ApplicationDefinitionsClientBeginDeleteByIDOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -386,7 +383,7 @@ func (client *ApplicationDefinitionsClient) Get(ctx context.Context, resourceGro } // getCreateRequest creates the Get request. -func (client *ApplicationDefinitionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientGetOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, _ *ApplicationDefinitionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -451,7 +448,7 @@ func (client *ApplicationDefinitionsClient) GetByID(ctx context.Context, resourc } // getByIDCreateRequest creates the GetByID request. -func (client *ApplicationDefinitionsClient) getByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientGetByIDOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) getByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, _ *ApplicationDefinitionsClientGetByIDOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -515,7 +512,7 @@ func (client *ApplicationDefinitionsClient) NewListByResourceGroupPager(resource } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *ApplicationDefinitionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ApplicationDefinitionsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ApplicationDefinitionsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") diff --git a/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client_example_test.go b/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client_example_test.go deleted file mode 100644 index 2cc2e38b19b3..000000000000 --- a/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client_example_test.go +++ /dev/null @@ -1,237 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmanagedapplications_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/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json -func ExampleApplicationDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationDefinitionsClient().Get(ctx, "rg", "myManagedApplicationDef", 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.ApplicationDefinition = armmanagedapplications.ApplicationDefinition{ - // Name: to.Ptr("myManagedApplicationDef"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef"), - // Location: to.Ptr("East US 2"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json -func ExampleApplicationDefinitionsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationDefinitionsClient().BeginDelete(ctx, "rg", "myManagedApplicationDef", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json -func ExampleApplicationDefinitionsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationDefinitionsClient().BeginCreateOrUpdate(ctx, "rg", "myManagedApplicationDef", armmanagedapplications.ApplicationDefinition{ - Location: to.Ptr("East US 2"), - Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - Description: to.Ptr("myManagedApplicationDef description"), - Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - { - PrincipalID: to.Ptr("validprincipalguid"), - RoleDefinitionID: to.Ptr("validroleguid"), - }}, - DisplayName: to.Ptr("myManagedApplicationDef"), - LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - }, - }, 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.ApplicationDefinition = armmanagedapplications.ApplicationDefinition{ - // Name: to.Ptr("myManagedApplicationDef"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef"), - // Location: to.Ptr("East US 2"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationDefinitionsByResourceGroup.json -func ExampleApplicationDefinitionsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationDefinitionsClient().NewListByResourceGroupPager("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.ApplicationDefinitionListResult = armmanagedapplications.ApplicationDefinitionListResult{ - // Value: []*armmanagedapplications.ApplicationDefinition{ - // { - // Name: to.Ptr("myManagedApplicationDef"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef"), - // Location: to.Ptr("East US 2"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // }, - // { - // Name: to.Ptr("myManagedApplicationDef2"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef2"), - // Location: to.Ptr("West US"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef2 description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef2"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/applications_client.go b/sdk/resourcemanager/resources/armmanagedapplications/applications_client.go index f5d597d08b32..992f9afc998f 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/applications_client.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/applications_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -95,7 +92,7 @@ func (client *ApplicationsClient) createOrUpdate(ctx context.Context, resourceGr } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ApplicationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, parameters Application, options *ApplicationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ApplicationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, parameters Application, _ *ApplicationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -176,7 +173,7 @@ func (client *ApplicationsClient) createOrUpdateByID(ctx context.Context, applic } // createOrUpdateByIDCreateRequest creates the CreateOrUpdateByID request. -func (client *ApplicationsClient) createOrUpdateByIDCreateRequest(ctx context.Context, applicationID string, parameters Application, options *ApplicationsClientBeginCreateOrUpdateByIDOptions) (*policy.Request, error) { +func (client *ApplicationsClient) createOrUpdateByIDCreateRequest(ctx context.Context, applicationID string, parameters Application, _ *ApplicationsClientBeginCreateOrUpdateByIDOptions) (*policy.Request, error) { urlPath := "/{applicationId}" urlPath = strings.ReplaceAll(urlPath, "{applicationId}", applicationID) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -244,7 +241,7 @@ func (client *ApplicationsClient) deleteOperation(ctx context.Context, resourceG } // deleteCreateRequest creates the Delete request. -func (client *ApplicationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, options *ApplicationsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *ApplicationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, _ *ApplicationsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -321,7 +318,7 @@ func (client *ApplicationsClient) deleteByID(ctx context.Context, applicationID } // deleteByIDCreateRequest creates the DeleteByID request. -func (client *ApplicationsClient) deleteByIDCreateRequest(ctx context.Context, applicationID string, options *ApplicationsClientBeginDeleteByIDOptions) (*policy.Request, error) { +func (client *ApplicationsClient) deleteByIDCreateRequest(ctx context.Context, applicationID string, _ *ApplicationsClientBeginDeleteByIDOptions) (*policy.Request, error) { urlPath := "/{applicationId}" urlPath = strings.ReplaceAll(urlPath, "{applicationId}", applicationID) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -365,7 +362,7 @@ func (client *ApplicationsClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *ApplicationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, options *ApplicationsClientGetOptions) (*policy.Request, error) { +func (client *ApplicationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, _ *ApplicationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -430,7 +427,7 @@ func (client *ApplicationsClient) GetByID(ctx context.Context, applicationID str } // getByIDCreateRequest creates the GetByID request. -func (client *ApplicationsClient) getByIDCreateRequest(ctx context.Context, applicationID string, options *ApplicationsClientGetByIDOptions) (*policy.Request, error) { +func (client *ApplicationsClient) getByIDCreateRequest(ctx context.Context, applicationID string, _ *ApplicationsClientGetByIDOptions) (*policy.Request, error) { urlPath := "/{applicationId}" urlPath = strings.ReplaceAll(urlPath, "{applicationId}", applicationID) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -483,7 +480,7 @@ func (client *ApplicationsClient) NewListByResourceGroupPager(resourceGroupName } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *ApplicationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ApplicationsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *ApplicationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ApplicationsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -542,7 +539,7 @@ func (client *ApplicationsClient) NewListBySubscriptionPager(options *Applicatio } // listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *ApplicationsClient) listBySubscriptionCreateRequest(ctx context.Context, options *ApplicationsClientListBySubscriptionOptions) (*policy.Request, error) { +func (client *ApplicationsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *ApplicationsClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/resources/armmanagedapplications/applications_client_example_test.go b/sdk/resourcemanager/resources/armmanagedapplications/applications_client_example_test.go deleted file mode 100644 index 63b8f7224a2c..000000000000 --- a/sdk/resourcemanager/resources/armmanagedapplications/applications_client_example_test.go +++ /dev/null @@ -1,381 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmanagedapplications_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/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplication.json -func ExampleApplicationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().Get(ctx, "rg", "myManagedApplication", 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplication.json -func ExampleApplicationsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginDelete(ctx, "rg", "myManagedApplication", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplication.json -func ExampleApplicationsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginCreateOrUpdate(ctx, "rg", "myManagedApplication", armmanagedapplications.Application{ - Location: to.Ptr("East US 2"), - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplication.json -func ExampleApplicationsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().Update(ctx, "rg", "myManagedApplication", &armmanagedapplications.ApplicationsClientUpdateOptions{Parameters: &armmanagedapplications.ApplicationPatchable{ - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationPropertiesPatchable{ - ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, - }) - 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsByResourceGroup.json -func ExampleApplicationsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationsClient().NewListByResourceGroupPager("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.ApplicationListResult = armmanagedapplications.ApplicationListResult{ - // Value: []*armmanagedapplications.Application{ - // { - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("myManagedApplication2"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication2"), - // Location: to.Ptr("West US"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsBySubscription.json -func ExampleApplicationsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationsClient().NewListBySubscriptionPager(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.ApplicationListResult = armmanagedapplications.ApplicationListResult{ - // Value: []*armmanagedapplications.Application{ - // { - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("myManagedApplication2"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication2"), - // Location: to.Ptr("West US"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationById.json -func ExampleApplicationsClient_GetByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().GetByID(ctx, "myApplicationId", 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationById.json -func ExampleApplicationsClient_BeginDeleteByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginDeleteByID(ctx, "myApplicationId", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationById.json -func ExampleApplicationsClient_BeginCreateOrUpdateByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginCreateOrUpdateByID(ctx, "myApplicationId", armmanagedapplications.Application{ - Location: to.Ptr("East US 2"), - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplicationById.json -func ExampleApplicationsClient_UpdateByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().UpdateByID(ctx, "myApplicationId", &armmanagedapplications.ApplicationsClientUpdateByIDOptions{Parameters: &armmanagedapplications.Application{ - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, - }) - 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/autorest.md b/sdk/resourcemanager/resources/armmanagedapplications/autorest.md index 24d811660b16..18eb6db063f2 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/autorest.md +++ b/sdk/resourcemanager/resources/armmanagedapplications/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/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: 1.2.0 +module-version: 1.2.1 package-managedapplications: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armmanagedapplications/client_factory.go b/sdk/resourcemanager/resources/armmanagedapplications/client_factory.go index 7dd85ca82e2b..e2fa119075d2 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/client_factory.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -17,8 +14,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,30 +23,35 @@ type ClientFactory struct { // - 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, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewApplicationClient creates a new instance of ApplicationClient. func (c *ClientFactory) NewApplicationClient() *ApplicationClient { - subClient, _ := NewApplicationClient(c.credential, c.options) - return subClient + return &ApplicationClient{ + internal: c.internal, + } } // NewApplicationDefinitionsClient creates a new instance of ApplicationDefinitionsClient. func (c *ClientFactory) NewApplicationDefinitionsClient() *ApplicationDefinitionsClient { - subClient, _ := NewApplicationDefinitionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ApplicationDefinitionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewApplicationsClient creates a new instance of ApplicationsClient. func (c *ClientFactory) NewApplicationsClient() *ApplicationsClient { - subClient, _ := NewApplicationsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ApplicationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armmanagedapplications/constants.go b/sdk/resourcemanager/resources/armmanagedapplications/constants.go index 0af828198ae9..91a350414542 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/constants.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,7 +7,7 @@ package armmanagedapplications const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armmanagedapplications" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // ApplicationArtifactType - The managed application artifact type. diff --git a/sdk/resourcemanager/resources/armmanagedapplications/fake/application_server.go b/sdk/resourcemanager/resources/armmanagedapplications/fake/application_server.go index 06be689b57d8..6a98222c6d32 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/fake/application_server.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/fake/application_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -51,21 +48,40 @@ func (a *ApplicationServerTransport) Do(req *http.Request) (*http.Response, erro return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "ApplicationClient.NewListOperationsPager": - resp, err = a.dispatchNewListOperationsPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *ApplicationServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if applicationServerTransportInterceptor != nil { + res.resp, res.err, intercepted = applicationServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ApplicationClient.NewListOperationsPager": + res.resp, res.err = a.dispatchNewListOperationsPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *ApplicationServerTransport) dispatchNewListOperationsPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (a *ApplicationServerTransport) dispatchNewListOperationsPager(req *http.Re } return resp, nil } + +// set this to conditionally intercept incoming requests to ApplicationServerTransport +var applicationServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/fake/applicationdefinitions_server.go b/sdk/resourcemanager/resources/armmanagedapplications/fake/applicationdefinitions_server.go index 07e47980ad55..417694ea7a29 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/fake/applicationdefinitions_server.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/fake/applicationdefinitions_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -86,33 +83,52 @@ func (a *ApplicationDefinitionsServerTransport) Do(req *http.Request) (*http.Res return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "ApplicationDefinitionsClient.BeginCreateOrUpdate": - resp, err = a.dispatchBeginCreateOrUpdate(req) - case "ApplicationDefinitionsClient.BeginCreateOrUpdateByID": - resp, err = a.dispatchBeginCreateOrUpdateByID(req) - case "ApplicationDefinitionsClient.BeginDelete": - resp, err = a.dispatchBeginDelete(req) - case "ApplicationDefinitionsClient.BeginDeleteByID": - resp, err = a.dispatchBeginDeleteByID(req) - case "ApplicationDefinitionsClient.Get": - resp, err = a.dispatchGet(req) - case "ApplicationDefinitionsClient.GetByID": - resp, err = a.dispatchGetByID(req) - case "ApplicationDefinitionsClient.NewListByResourceGroupPager": - resp, err = a.dispatchNewListByResourceGroupPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return a.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (a *ApplicationDefinitionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - return resp, nil + go func() { + var intercepted bool + var res result + if applicationDefinitionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = applicationDefinitionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ApplicationDefinitionsClient.BeginCreateOrUpdate": + res.resp, res.err = a.dispatchBeginCreateOrUpdate(req) + case "ApplicationDefinitionsClient.BeginCreateOrUpdateByID": + res.resp, res.err = a.dispatchBeginCreateOrUpdateByID(req) + case "ApplicationDefinitionsClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "ApplicationDefinitionsClient.BeginDeleteByID": + res.resp, res.err = a.dispatchBeginDeleteByID(req) + case "ApplicationDefinitionsClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "ApplicationDefinitionsClient.GetByID": + res.resp, res.err = a.dispatchGetByID(req) + case "ApplicationDefinitionsClient.NewListByResourceGroupPager": + res.resp, res.err = a.dispatchNewListByResourceGroupPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *ApplicationDefinitionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -401,3 +417,9 @@ func (a *ApplicationDefinitionsServerTransport) dispatchNewListByResourceGroupPa } return resp, nil } + +// set this to conditionally intercept incoming requests to ApplicationDefinitionsServerTransport +var applicationDefinitionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/fake/applications_server.go b/sdk/resourcemanager/resources/armmanagedapplications/fake/applications_server.go index 941da38a7af8..de47d53a7758 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/fake/applications_server.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/fake/applications_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -34,11 +31,11 @@ type ApplicationsServer struct { BeginCreateOrUpdateByID func(ctx context.Context, applicationID string, parameters armmanagedapplications.Application, options *armmanagedapplications.ApplicationsClientBeginCreateOrUpdateByIDOptions) (resp azfake.PollerResponder[armmanagedapplications.ApplicationsClientCreateOrUpdateByIDResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method ApplicationsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, applicationName string, options *armmanagedapplications.ApplicationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armmanagedapplications.ApplicationsClientDeleteResponse], errResp azfake.ErrorResponder) // BeginDeleteByID is the fake for method ApplicationsClient.BeginDeleteByID - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginDeleteByID func(ctx context.Context, applicationID string, options *armmanagedapplications.ApplicationsClientBeginDeleteByIDOptions) (resp azfake.PollerResponder[armmanagedapplications.ApplicationsClientDeleteByIDResponse], errResp azfake.ErrorResponder) // Get is the fake for method ApplicationsClient.Get @@ -101,39 +98,58 @@ func (a *ApplicationsServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "ApplicationsClient.BeginCreateOrUpdate": - resp, err = a.dispatchBeginCreateOrUpdate(req) - case "ApplicationsClient.BeginCreateOrUpdateByID": - resp, err = a.dispatchBeginCreateOrUpdateByID(req) - case "ApplicationsClient.BeginDelete": - resp, err = a.dispatchBeginDelete(req) - case "ApplicationsClient.BeginDeleteByID": - resp, err = a.dispatchBeginDeleteByID(req) - case "ApplicationsClient.Get": - resp, err = a.dispatchGet(req) - case "ApplicationsClient.GetByID": - resp, err = a.dispatchGetByID(req) - case "ApplicationsClient.NewListByResourceGroupPager": - resp, err = a.dispatchNewListByResourceGroupPager(req) - case "ApplicationsClient.NewListBySubscriptionPager": - resp, err = a.dispatchNewListBySubscriptionPager(req) - case "ApplicationsClient.Update": - resp, err = a.dispatchUpdate(req) - case "ApplicationsClient.UpdateByID": - resp, err = a.dispatchUpdateByID(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return a.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (a *ApplicationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - return resp, nil + go func() { + var intercepted bool + var res result + if applicationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = applicationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ApplicationsClient.BeginCreateOrUpdate": + res.resp, res.err = a.dispatchBeginCreateOrUpdate(req) + case "ApplicationsClient.BeginCreateOrUpdateByID": + res.resp, res.err = a.dispatchBeginCreateOrUpdateByID(req) + case "ApplicationsClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "ApplicationsClient.BeginDeleteByID": + res.resp, res.err = a.dispatchBeginDeleteByID(req) + case "ApplicationsClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "ApplicationsClient.GetByID": + res.resp, res.err = a.dispatchGetByID(req) + case "ApplicationsClient.NewListByResourceGroupPager": + res.resp, res.err = a.dispatchNewListByResourceGroupPager(req) + case "ApplicationsClient.NewListBySubscriptionPager": + res.resp, res.err = a.dispatchNewListBySubscriptionPager(req) + case "ApplicationsClient.Update": + res.resp, res.err = a.dispatchUpdate(req) + case "ApplicationsClient.UpdateByID": + res.resp, res.err = a.dispatchUpdateByID(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *ApplicationsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -261,9 +277,9 @@ func (a *ApplicationsServerTransport) dispatchBeginDelete(req *http.Request) (*h return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { a.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { a.beginDelete.remove(req) @@ -301,9 +317,9 @@ func (a *ApplicationsServerTransport) dispatchBeginDeleteByID(req *http.Request) return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { a.beginDeleteByID.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDeleteByID) { a.beginDeleteByID.remove(req) @@ -525,3 +541,9 @@ func (a *ApplicationsServerTransport) dispatchUpdateByID(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to ApplicationsServerTransport +var applicationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/fake/internal.go b/sdk/resourcemanager/resources/armmanagedapplications/fake/internal.go index 5f75802a569e..4b65adc76adb 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/fake/internal.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -14,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/resources/armmanagedapplications/fake/server_factory.go b/sdk/resourcemanager/resources/armmanagedapplications/fake/server_factory.go index 338089490ef7..788a8be95735 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,9 +16,14 @@ import ( // ServerFactory is a fake server for instances of the armmanagedapplications.ClientFactory type. type ServerFactory struct { - ApplicationServer ApplicationServer + // ApplicationServer contains the fakes for client ApplicationClient + ApplicationServer ApplicationServer + + // ApplicationDefinitionsServer contains the fakes for client ApplicationDefinitionsClient ApplicationDefinitionsServer ApplicationDefinitionsServer - ApplicationsServer ApplicationsServer + + // ApplicationsServer contains the fakes for client ApplicationsClient + ApplicationsServer ApplicationsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. diff --git a/sdk/resourcemanager/resources/armmanagedapplications/go.mod b/sdk/resourcemanager/resources/armmanagedapplications/go.mod index 690481847b26..a6cbf0d1b17c 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/go.mod +++ b/sdk/resourcemanager/resources/armmanagedapplications/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armmanage go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armmanagedapplications/go.sum b/sdk/resourcemanager/resources/armmanagedapplications/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/go.sum +++ b/sdk/resourcemanager/resources/armmanagedapplications/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -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-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armmanagedapplications/models.go b/sdk/resourcemanager/resources/armmanagedapplications/models.go index cd94c10bef67..6403ce685130 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/models.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -263,7 +260,8 @@ type GenericResource struct { // Identity for the resource. type Identity struct { - // The identity type. + // CONSTANT; The identity type. + // Field has constant value "SystemAssigned", any specified value is ignored. Type *string // READ-ONLY; The principal ID of resource identity. diff --git a/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go b/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go index bf63041d30f9..888f3e5bbd4d 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -900,7 +897,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/resources/armmanagedapplications/options.go b/sdk/resourcemanager/resources/armmanagedapplications/options.go index 5c7cfd62992f..21148182a6b4 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/options.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -17,28 +14,28 @@ type ApplicationClientListOperationsOptions struct { // ApplicationDefinitionsClientBeginCreateOrUpdateByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginCreateOrUpdateByID // method. type ApplicationDefinitionsClientBeginCreateOrUpdateByIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ApplicationDefinitionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginCreateOrUpdate // method. type ApplicationDefinitionsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ApplicationDefinitionsClientBeginDeleteByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginDeleteByID // method. type ApplicationDefinitionsClientBeginDeleteByIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ApplicationDefinitionsClientBeginDeleteOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginDelete // method. type ApplicationDefinitionsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -62,26 +59,26 @@ type ApplicationDefinitionsClientListByResourceGroupOptions struct { // ApplicationsClientBeginCreateOrUpdateByIDOptions contains the optional parameters for the ApplicationsClient.BeginCreateOrUpdateByID // method. type ApplicationsClientBeginCreateOrUpdateByIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ApplicationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ApplicationsClient.BeginCreateOrUpdate // method. type ApplicationsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ApplicationsClientBeginDeleteByIDOptions contains the optional parameters for the ApplicationsClient.BeginDeleteByID method. type ApplicationsClientBeginDeleteByIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ApplicationsClientBeginDeleteOptions contains the optional parameters for the ApplicationsClient.BeginDelete method. type ApplicationsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } diff --git a/sdk/resourcemanager/resources/armmanagedapplications/response_types.go b/sdk/resourcemanager/resources/armmanagedapplications/responses.go similarity index 99% rename from sdk/resourcemanager/resources/armmanagedapplications/response_types.go rename to sdk/resourcemanager/resources/armmanagedapplications/responses.go index d23fd86392f3..6b5ed7f2e482 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/response_types.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md index 668050965304..3ab8a7b00213 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,96 @@ # Release History +## 1.0.0 (2025-04-28) +### Breaking Changes + +- Enum `AliasPathAttributes` has been removed +- Enum `AliasPathTokenType` has been removed +- Enum `AliasPatternType` has been removed +- Enum `AliasType` has been removed +- Enum `AssignmentScopeValidation` has been removed +- Enum `ExemptionCategory` has been removed +- Function `*ClientFactory.NewDataPolicyManifestsClient` has been removed +- Function `*ClientFactory.NewExemptionsClient` has been removed +- Function `*ClientFactory.NewVariableValuesClient` has been removed +- Function `*ClientFactory.NewVariablesClient` has been removed +- Function `NewDataPolicyManifestsClient` has been removed +- Function `*DataPolicyManifestsClient.GetByPolicyMode` has been removed +- Function `*DataPolicyManifestsClient.NewListPager` has been removed +- Function `NewExemptionsClient` has been removed +- Function `*ExemptionsClient.CreateOrUpdate` has been removed +- Function `*ExemptionsClient.Delete` has been removed +- Function `*ExemptionsClient.Get` has been removed +- Function `*ExemptionsClient.NewListForManagementGroupPager` has been removed +- Function `*ExemptionsClient.NewListForResourceGroupPager` has been removed +- Function `*ExemptionsClient.NewListForResourcePager` has been removed +- Function `*ExemptionsClient.NewListPager` has been removed +- Function `*ExemptionsClient.Update` has been removed +- Function `NewVariableValuesClient` has been removed +- Function `*VariableValuesClient.CreateOrUpdate` has been removed +- Function `*VariableValuesClient.CreateOrUpdateAtManagementGroup` has been removed +- Function `*VariableValuesClient.Delete` has been removed +- Function `*VariableValuesClient.DeleteAtManagementGroup` has been removed +- Function `*VariableValuesClient.Get` has been removed +- Function `*VariableValuesClient.GetAtManagementGroup` has been removed +- Function `*VariableValuesClient.NewListForManagementGroupPager` has been removed +- Function `*VariableValuesClient.NewListPager` has been removed +- Function `NewVariablesClient` has been removed +- Function `*VariablesClient.CreateOrUpdate` has been removed +- Function `*VariablesClient.CreateOrUpdateAtManagementGroup` has been removed +- Function `*VariablesClient.Delete` has been removed +- Function `*VariablesClient.DeleteAtManagementGroup` has been removed +- Function `*VariablesClient.Get` has been removed +- Function `*VariablesClient.GetAtManagementGroup` has been removed +- Function `*VariablesClient.NewListForManagementGroupPager` has been removed +- Function `*VariablesClient.NewListPager` has been removed +- Struct `Alias` has been removed +- Struct `AliasPath` has been removed +- Struct `AliasPathMetadata` has been removed +- Struct `AliasPattern` has been removed +- Struct `DataEffect` has been removed +- Struct `DataManifestCustomResourceFunctionDefinition` has been removed +- Struct `DataManifestResourceFunctionsDefinition` has been removed +- Struct `DataPolicyManifest` has been removed +- Struct `DataPolicyManifestListResult` has been removed +- Struct `DataPolicyManifestProperties` has been removed +- Struct `Exemption` has been removed +- Struct `ExemptionListResult` has been removed +- Struct `ExemptionProperties` has been removed +- Struct `ExemptionUpdate` has been removed +- Struct `ExemptionUpdateProperties` has been removed +- Struct `ResourceTypeAliases` has been removed +- Struct `Variable` has been removed +- Struct `VariableColumn` has been removed +- Struct `VariableListResult` has been removed +- Struct `VariableProperties` has been removed +- Struct `VariableValue` has been removed +- Struct `VariableValueColumnValue` has been removed +- Struct `VariableValueListResult` has been removed +- Struct `VariableValueProperties` has been removed +- Field `Expand` of struct `AssignmentsClientGetByIDOptions` has been removed + +### Features Added + +- New value `EnforcementModeEnroll` added to enum type `EnforcementMode` +- New value `OverrideKindDefinitionVersion` added to enum type `OverrideKind` +- New enum type `AssignmentType` with values `AssignmentTypeCustom`, `AssignmentTypeNotSpecified`, `AssignmentTypeSystem`, `AssignmentTypeSystemHidden` +- New enum type `ExternalEndpointResult` with values `ExternalEndpointResultFailed`, `ExternalEndpointResultSucceeded` +- New enum type `PolicyTokenResult` with values `PolicyTokenResultFailed`, `PolicyTokenResultSucceeded` +- New function `*ClientFactory.NewTokensClient() *TokensClient` +- New function `NewTokensClient(string, azcore.TokenCredential, *arm.ClientOptions) (*TokensClient, error)` +- New function `*TokensClient.BeginAcquire(context.Context, TokenRequest, *TokensClientBeginAcquireOptions) (*runtime.Poller[TokensClientAcquireResponse], error)` +- New struct `ExternalEvaluationEndpointInvocationResult` +- New struct `ExternalEvaluationEndpointSettings` +- New struct `ExternalEvaluationEnforcementSettings` +- New struct `LogInfo` +- New struct `TokenOperation` +- New struct `TokenRequest` +- New struct `TokenResponse` +- New field `AssignmentType`, `InstanceID` in struct `AssignmentProperties` +- New field `ExternalEvaluationEnforcementSettings` in struct `DefinitionProperties` +- New field `ExternalEvaluationEnforcementSettings` in struct `DefinitionVersionProperties` + + ## 0.10.0 (2025-03-18) ### Features Added diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client.go b/sdk/resourcemanager/resources/armpolicy/assignments_client.go index fe18754ab99d..e0fcee1e0453 100644 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client.go +++ b/sdk/resourcemanager/resources/armpolicy/assignments_client.go @@ -46,7 +46,7 @@ func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredenti // resource group scope, that policy applies to all resources in the group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -90,7 +90,7 @@ func (client *AssignmentsClient) createCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -118,7 +118,7 @@ func (client *AssignmentsClient) createHandleResponse(resp *http.Response) (Assi // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyAssignmentID - The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - parameters - Parameters for policy assignment. // - options - AssignmentsClientCreateByIDOptions contains the optional parameters for the AssignmentsClient.CreateByID method. @@ -153,7 +153,7 @@ func (client *AssignmentsClient) createByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -176,7 +176,7 @@ func (client *AssignmentsClient) createByIDHandleResponse(resp *http.Response) ( // '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -219,7 +219,7 @@ func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -243,7 +243,7 @@ func (client *AssignmentsClient) deleteHandleResponse(resp *http.Response) (Assi // (resource). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyAssignmentID - The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - options - AssignmentsClientDeleteByIDOptions contains the optional parameters for the AssignmentsClient.DeleteByID method. func (client *AssignmentsClient) DeleteByID(ctx context.Context, policyAssignmentID string, options *AssignmentsClientDeleteByIDOptions) (AssignmentsClientDeleteByIDResponse, error) { @@ -277,7 +277,7 @@ func (client *AssignmentsClient) deleteByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -295,7 +295,7 @@ func (client *AssignmentsClient) deleteByIDHandleResponse(resp *http.Response) ( // Get - This operation retrieves a single policy assignment, given its name and the scope it was created at. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -341,7 +341,7 @@ func (client *AssignmentsClient) getCreateRequest(ctx context.Context, scope str if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -364,7 +364,7 @@ func (client *AssignmentsClient) getHandleResponse(resp *http.Response) (Assignm // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyAssignmentID - The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - options - AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method. func (client *AssignmentsClient) GetByID(ctx context.Context, policyAssignmentID string, options *AssignmentsClientGetByIDOptions) (AssignmentsClientGetByIDResponse, error) { @@ -390,7 +390,7 @@ func (client *AssignmentsClient) GetByID(ctx context.Context, policyAssignmentID } // getByIDCreateRequest creates the GetByID request. -func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, policyAssignmentID string, options *AssignmentsClientGetByIDOptions) (*policy.Request, error) { +func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, policyAssignmentID string, _ *AssignmentsClientGetByIDOptions) (*policy.Request, error) { urlPath := "/{policyAssignmentId}" urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentId}", policyAssignmentID) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -398,10 +398,7 @@ func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, polic return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) - } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -428,7 +425,7 @@ func (client *AssignmentsClient) getByIDHandleResponse(resp *http.Response) (Ass // is provided, the returned list includes all policy assignments of the policy // definition whose id is {value}. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. func (client *AssignmentsClient) NewListPager(options *AssignmentsClientListOptions) *runtime.Pager[AssignmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentsClientListResponse]{ @@ -471,7 +468,7 @@ func (client *AssignmentsClient) listCreateRequest(ctx context.Context, options if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -499,7 +496,7 @@ func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (Assign // If $filter=policyDefinitionId eq '{value}' is provided, the returned list // includes all policy assignments of the policy definition whose id is {value} that apply to the management group. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - options - AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager // method. @@ -544,7 +541,7 @@ func (client *AssignmentsClient) listForManagementGroupCreateRequest(ctx context if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -586,7 +583,7 @@ func (client *AssignmentsClient) listForManagementGroupHandleResponse(resp *http // format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, // {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - resourceGroupName - The name of the resource group containing the resource. // - resourceProviderNamespace - The namespace of the resource provider. For example, the namespace of a virtual machine is // Microsoft.Compute (from Microsoft.Compute/virtualMachines) @@ -650,7 +647,7 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -682,7 +679,7 @@ func (client *AssignmentsClient) listForResourceHandleResponse(resp *http.Respon // is provided, the returned list includes all policy assignments of the // policy definition whose id is {value} that apply to the resource group. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - resourceGroupName - The name of the resource group that contains policy assignments. // - options - AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager // method. @@ -731,7 +728,7 @@ func (client *AssignmentsClient) listForResourceGroupCreateRequest(ctx context.C if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -756,7 +753,7 @@ func (client *AssignmentsClient) listForResourceGroupHandleResponse(resp *http.R // group scope, that policy applies to all resources in the group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -800,7 +797,7 @@ func (client *AssignmentsClient) updateCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -828,7 +825,7 @@ func (client *AssignmentsClient) updateHandleResponse(resp *http.Response) (Assi // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyAssignmentID - The ID of the policy assignment to update. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - parameters - Parameters for policy assignment patch request. // - options - AssignmentsClientUpdateByIDOptions contains the optional parameters for the AssignmentsClient.UpdateByID method. @@ -863,7 +860,7 @@ func (client *AssignmentsClient) updateByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go deleted file mode 100644 index 477ec1246499..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go +++ /dev/null @@ -1,1405 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyAssignment.json -func ExampleAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Delete(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignment.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - }}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Foo Bar", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}, - }, - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Foo Bar", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentNonComplianceMessages.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "securityInitAssignment", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - DisplayName: to.Ptr("Enforce security policies"), - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr("Resources must comply with all internal security policies. See for more info."), - }, - { - Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - PolicyDefinitionReferenceID: to.Ptr("10420126870854049575"), - }, - { - Message: to.Ptr("Storage accounts must have firewall rules configured."), - PolicyDefinitionReferenceID: to.Ptr("8572513655450389710"), - }}, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithOverrides() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Limit the resource location and resource SKU"), - DisplayName: to.Ptr("Limit the resource location and resource SKU"), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - Overrides: []*armpolicy.Override{ - { - Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("Limit_Skus"), - to.Ptr("Limit_Locations")}, - Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - }}, - Value: to.Ptr("Audit"), - }}, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Limit the resource location and resource SKU"), - DisplayName: to.Ptr("Limit the resource location and resource SKU"), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithoutEnforcement.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDoNotEnforce), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignment.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", &armpolicy.AssignmentsClientGetOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithASystemAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", &armpolicy.AssignmentsClientGetOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("westus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithAUserAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", &armpolicy.AssignmentsClientGetOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - // "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{ - // ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // }, - // }, - // }, - // Location: to.Ptr("westus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithOverrides() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", &armpolicy.AssignmentsClientGetOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Overrides: []*armpolicy.Override{ - // { - // Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("Limit_Skus"), - // to.Ptr("Limit_Locations")}, - // Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - // }}, - // Value: to.Ptr("Audit"), - // }}, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", &armpolicy.AssignmentsClientGetOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithASystemAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithAUserAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}, - }, - }, - Location: to.Ptr("eastus"), - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - // "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{ - // ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // }, - // }, - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithOverrides() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.AssignmentUpdate{ - Properties: &armpolicy.AssignmentUpdateProperties{ - Overrides: []*armpolicy.Override{ - { - Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("Limit_Skus"), - to.Ptr("Limit_Locations")}, - Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - }}, - Value: to.Ptr("Audit"), - }}, - }, - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Overrides: []*armpolicy.Override{ - // { - // Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("Limit_Skus"), - // to.Ptr("Limit_Locations")}, - // Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - // }}, - // Value: to.Ptr("Audit"), - // }}, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.AssignmentUpdate{ - Properties: &armpolicy.AssignmentUpdateProperties{ - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignmentsForResourceGroup.json -func ExampleAssignmentsClient_NewListForResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.AssignmentsClientListForResourceGroupOptions{Filter: to.Ptr("atScope()"), - Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion"), - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("TestCostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Storage Cost Management"), - // EffectiveDefinitionVersion: to.Ptr("1.0.0"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // EffectiveDefinitionVersion: to.Ptr("1.0.0"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignmentsForResource.json -func ExampleAssignmentsClient_NewListForResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForResourcePager("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", "MyTestComputer.cloudapp.net", &armpolicy.AssignmentsClientListForResourceOptions{Filter: nil, - Expand: nil, - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("TestCostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("VM Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/vmSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignmentsForManagementGroup.json -func ExampleAssignmentsClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForManagementGroupPager("TestManagementGroup", &armpolicy.AssignmentsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()"), - Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion"), - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("TestCostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Storage Cost Management"), - // EffectiveDefinitionVersion: to.Ptr("1.0.0"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"), - // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // EffectiveDefinitionVersion: to.Ptr("1.0.0"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyAssignments.json -func ExampleAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListPager(&armpolicy.AssignmentsClientListOptions{Filter: to.Ptr("atScope()"), - Expand: to.Ptr("LatestDefinitionVersion, EffectiveDefinitionVersion"), - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Storage Cost Management"), - // EffectiveDefinitionVersion: to.Ptr("1.0.0"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // }, - // { - // Name: to.Ptr("TagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/TagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // EffectiveDefinitionVersion: to.Ptr("1.0.0"), - // LatestDefinitionVersion: to.Ptr("1.0.0"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyAssignmentById.json -func ExampleAssignmentsClient_DeleteByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().DeleteByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentById.json -func ExampleAssignmentsClient_CreateByID_createOrUpdatePolicyAssignmentById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().CreateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - DefinitionVersion: to.Ptr("1.*.*"), - DisplayName: to.Ptr("Enforce storage account SKU"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Cheapskate Boss", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_CreateByID_createOrUpdatePolicyAssignmentWithAManagedIdentityById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().CreateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - DefinitionVersion: to.Ptr("1.*.*"), - DisplayName: to.Ptr("Enforce storage account SKU"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Cheapskate Boss", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentById.json -func ExampleAssignmentsClient_GetByID_retrieveAPolicyAssignmentById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().GetByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", &armpolicy.AssignmentsClientGetByIDOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_GetByID_retrieveAPolicyAssignmentWithAManagedIdentityById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().GetByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", &armpolicy.AssignmentsClientGetByIDOptions{Expand: 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("westus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/updatePolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_UpdateByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().UpdateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DefinitionVersion: to.Ptr("1.*.*"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armpolicy/autorest.md b/sdk/resourcemanager/resources/armpolicy/autorest.md index c39acb0a4cd8..9cc6a7d96ac3 100644 --- a/sdk/resourcemanager/resources/armpolicy/autorest.md +++ b/sdk/resourcemanager/resources/armpolicy/autorest.md @@ -5,10 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/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.10.0 +module-version: 1.0.0 package-policy: true -tag: package-policy-2023-04 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armpolicy/client_factory.go b/sdk/resourcemanager/resources/armpolicy/client_factory.go index 0f7b551eb66a..4ab893365c7f 100644 --- a/sdk/resourcemanager/resources/armpolicy/client_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/client_factory.go @@ -41,13 +41,6 @@ func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient { } } -// NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient. -func (c *ClientFactory) NewDataPolicyManifestsClient() *DataPolicyManifestsClient { - return &DataPolicyManifestsClient{ - internal: c.internal, - } -} - // NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient. func (c *ClientFactory) NewDefinitionVersionsClient() *DefinitionVersionsClient { return &DefinitionVersionsClient{ @@ -64,14 +57,6 @@ func (c *ClientFactory) NewDefinitionsClient() *DefinitionsClient { } } -// NewExemptionsClient creates a new instance of ExemptionsClient. -func (c *ClientFactory) NewExemptionsClient() *ExemptionsClient { - return &ExemptionsClient{ - subscriptionID: c.subscriptionID, - internal: c.internal, - } -} - // NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient. func (c *ClientFactory) NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient { return &SetDefinitionVersionsClient{ @@ -88,17 +73,9 @@ func (c *ClientFactory) NewSetDefinitionsClient() *SetDefinitionsClient { } } -// NewVariableValuesClient creates a new instance of VariableValuesClient. -func (c *ClientFactory) NewVariableValuesClient() *VariableValuesClient { - return &VariableValuesClient{ - subscriptionID: c.subscriptionID, - internal: c.internal, - } -} - -// NewVariablesClient creates a new instance of VariablesClient. -func (c *ClientFactory) NewVariablesClient() *VariablesClient { - return &VariablesClient{ +// NewTokensClient creates a new instance of TokensClient. +func (c *ClientFactory) NewTokensClient() *TokensClient { + return &TokensClient{ subscriptionID: c.subscriptionID, internal: c.internal, } diff --git a/sdk/resourcemanager/resources/armpolicy/constants.go b/sdk/resourcemanager/resources/armpolicy/constants.go index fdb2d10201a5..9e44b0ccf8c2 100644 --- a/sdk/resourcemanager/resources/armpolicy/constants.go +++ b/sdk/resourcemanager/resources/armpolicy/constants.go @@ -7,118 +7,26 @@ package armpolicy const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - moduleVersion = "v0.10.0" + moduleVersion = "v1.0.0" ) -// AliasPathAttributes - The attributes of the token that the alias path is referring to. -type AliasPathAttributes string +// AssignmentType - The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. +type AssignmentType string const ( - // AliasPathAttributesModifiable - The token that the alias path is referring to is modifiable by policies with 'modify' effect. - AliasPathAttributesModifiable AliasPathAttributes = "Modifiable" - // AliasPathAttributesNone - The token that the alias path is referring to has no attributes. - AliasPathAttributesNone AliasPathAttributes = "None" + AssignmentTypeCustom AssignmentType = "Custom" + AssignmentTypeNotSpecified AssignmentType = "NotSpecified" + AssignmentTypeSystem AssignmentType = "System" + AssignmentTypeSystemHidden AssignmentType = "SystemHidden" ) -// PossibleAliasPathAttributesValues returns the possible values for the AliasPathAttributes const type. -func PossibleAliasPathAttributesValues() []AliasPathAttributes { - return []AliasPathAttributes{ - AliasPathAttributesModifiable, - AliasPathAttributesNone, - } -} - -// AliasPathTokenType - The type of the token that the alias path is referring to. -type AliasPathTokenType string - -const ( - // AliasPathTokenTypeAny - The token type can be anything. - AliasPathTokenTypeAny AliasPathTokenType = "Any" - // AliasPathTokenTypeArray - The token type is array. - AliasPathTokenTypeArray AliasPathTokenType = "Array" - // AliasPathTokenTypeBoolean - The token type is boolean. - AliasPathTokenTypeBoolean AliasPathTokenType = "Boolean" - // AliasPathTokenTypeInteger - The token type is integer. - AliasPathTokenTypeInteger AliasPathTokenType = "Integer" - // AliasPathTokenTypeNotSpecified - The token type is not specified. - AliasPathTokenTypeNotSpecified AliasPathTokenType = "NotSpecified" - // AliasPathTokenTypeNumber - The token type is number. - AliasPathTokenTypeNumber AliasPathTokenType = "Number" - // AliasPathTokenTypeObject - The token type is object. - AliasPathTokenTypeObject AliasPathTokenType = "Object" - // AliasPathTokenTypeString - The token type is string. - AliasPathTokenTypeString AliasPathTokenType = "String" -) - -// PossibleAliasPathTokenTypeValues returns the possible values for the AliasPathTokenType const type. -func PossibleAliasPathTokenTypeValues() []AliasPathTokenType { - return []AliasPathTokenType{ - AliasPathTokenTypeAny, - AliasPathTokenTypeArray, - AliasPathTokenTypeBoolean, - AliasPathTokenTypeInteger, - AliasPathTokenTypeNotSpecified, - AliasPathTokenTypeNumber, - AliasPathTokenTypeObject, - AliasPathTokenTypeString, - } -} - -// AliasPatternType - The type of alias pattern -type AliasPatternType string - -const ( - // AliasPatternTypeExtract - Extract is the only allowed value. - AliasPatternTypeExtract AliasPatternType = "Extract" - // AliasPatternTypeNotSpecified - NotSpecified is not allowed. - AliasPatternTypeNotSpecified AliasPatternType = "NotSpecified" -) - -// PossibleAliasPatternTypeValues returns the possible values for the AliasPatternType const type. -func PossibleAliasPatternTypeValues() []AliasPatternType { - return []AliasPatternType{ - AliasPatternTypeExtract, - AliasPatternTypeNotSpecified, - } -} - -// AliasType - The type of the alias. -type AliasType string - -const ( - // AliasTypeMask - Alias value is secret. - AliasTypeMask AliasType = "Mask" - // AliasTypeNotSpecified - Alias type is unknown (same as not providing alias type). - AliasTypeNotSpecified AliasType = "NotSpecified" - // AliasTypePlainText - Alias value is not secret. - AliasTypePlainText AliasType = "PlainText" -) - -// PossibleAliasTypeValues returns the possible values for the AliasType const type. -func PossibleAliasTypeValues() []AliasType { - return []AliasType{ - AliasTypeMask, - AliasTypeNotSpecified, - AliasTypePlainText, - } -} - -// AssignmentScopeValidation - The option whether validate the exemption is at or under the assignment scope. -type AssignmentScopeValidation string - -const ( - // AssignmentScopeValidationDefault - This option will validate the exemption is at or under the assignment scope. - AssignmentScopeValidationDefault AssignmentScopeValidation = "Default" - // AssignmentScopeValidationDoNotValidate - This option will bypass the validation the exemption scope is at or under the - // policy assignment scope. - AssignmentScopeValidationDoNotValidate AssignmentScopeValidation = "DoNotValidate" -) - -// PossibleAssignmentScopeValidationValues returns the possible values for the AssignmentScopeValidation const type. -func PossibleAssignmentScopeValidationValues() []AssignmentScopeValidation { - return []AssignmentScopeValidation{ - AssignmentScopeValidationDefault, - AssignmentScopeValidationDoNotValidate, +// PossibleAssignmentTypeValues returns the possible values for the AssignmentType const type. +func PossibleAssignmentTypeValues() []AssignmentType { + return []AssignmentType{ + AssignmentTypeCustom, + AssignmentTypeNotSpecified, + AssignmentTypeSystem, + AssignmentTypeSystemHidden, } } @@ -142,7 +50,7 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } -// EnforcementMode - The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. +// EnforcementMode - The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll type EnforcementMode string const ( @@ -150,6 +58,9 @@ const ( EnforcementModeDefault EnforcementMode = "Default" // EnforcementModeDoNotEnforce - The policy effect is not enforced during resource creation or update. EnforcementModeDoNotEnforce EnforcementMode = "DoNotEnforce" + // EnforcementModeEnroll - The policy effect is not enforced during resource creation or update until the resource or scope + // of the resource is enrolled to the assignment instance. Enrollment occurs upon deployment of the policy enrollment resource. + EnforcementModeEnroll EnforcementMode = "Enroll" ) // PossibleEnforcementModeValues returns the possible values for the EnforcementMode const type. @@ -157,25 +68,23 @@ func PossibleEnforcementModeValues() []EnforcementMode { return []EnforcementMode{ EnforcementModeDefault, EnforcementModeDoNotEnforce, + EnforcementModeEnroll, } } -// ExemptionCategory - The policy exemption category. Possible values are Waiver and Mitigated. -type ExemptionCategory string +// ExternalEndpointResult - The result of the external endpoint. Possible values are Succeeded and Failed. +type ExternalEndpointResult string const ( - // ExemptionCategoryMitigated - This category of exemptions usually means the mitigation actions have been applied to the - // scope. - ExemptionCategoryMitigated ExemptionCategory = "Mitigated" - // ExemptionCategoryWaiver - This category of exemptions usually means the scope is not applicable for the policy. - ExemptionCategoryWaiver ExemptionCategory = "Waiver" + ExternalEndpointResultFailed ExternalEndpointResult = "Failed" + ExternalEndpointResultSucceeded ExternalEndpointResult = "Succeeded" ) -// PossibleExemptionCategoryValues returns the possible values for the ExemptionCategory const type. -func PossibleExemptionCategoryValues() []ExemptionCategory { - return []ExemptionCategory{ - ExemptionCategoryMitigated, - ExemptionCategoryWaiver, +// PossibleExternalEndpointResultValues returns the possible values for the ExternalEndpointResult const type. +func PossibleExternalEndpointResultValues() []ExternalEndpointResult { + return []ExternalEndpointResult{ + ExternalEndpointResultFailed, + ExternalEndpointResultSucceeded, } } @@ -183,6 +92,8 @@ func PossibleExemptionCategoryValues() []ExemptionCategory { type OverrideKind string const ( + // OverrideKindDefinitionVersion - It will override the definition version property value of the policy assignment. + OverrideKindDefinitionVersion OverrideKind = "definitionVersion" // OverrideKindPolicyEffect - It will override the policy effect type. OverrideKindPolicyEffect OverrideKind = "policyEffect" ) @@ -190,6 +101,7 @@ const ( // PossibleOverrideKindValues returns the possible values for the OverrideKind const type. func PossibleOverrideKindValues() []OverrideKind { return []OverrideKind{ + OverrideKindDefinitionVersion, OverrideKindPolicyEffect, } } @@ -220,6 +132,22 @@ func PossibleParameterTypeValues() []ParameterType { } } +// PolicyTokenResult - The result of the completed token acquisition operation. Possible values are Succeeded and Failed. +type PolicyTokenResult string + +const ( + PolicyTokenResultFailed PolicyTokenResult = "Failed" + PolicyTokenResultSucceeded PolicyTokenResult = "Succeeded" +) + +// PossiblePolicyTokenResultValues returns the possible values for the PolicyTokenResult const type. +func PossiblePolicyTokenResultValues() []PolicyTokenResult { + return []PolicyTokenResult{ + PolicyTokenResultFailed, + PolicyTokenResultSucceeded, + } +} + // PolicyType - The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. type PolicyType string diff --git a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go deleted file mode 100644 index 33e794033acd..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go +++ /dev/null @@ -1,154 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// DataPolicyManifestsClient contains the methods for the DataPolicyManifests group. -// Don't use this type directly, use NewDataPolicyManifestsClient() instead. -type DataPolicyManifestsClient struct { - internal *arm.Client -} - -// NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewDataPolicyManifestsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DataPolicyManifestsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &DataPolicyManifestsClient{ - internal: cl, - } - return client, nil -} - -// GetByPolicyMode - This operation retrieves the data policy manifest with the given policy mode. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-09-01 -// - policyMode - The policy mode of the data policy manifest to get. -// - options - DataPolicyManifestsClientGetByPolicyModeOptions contains the optional parameters for the DataPolicyManifestsClient.GetByPolicyMode -// method. -func (client *DataPolicyManifestsClient) GetByPolicyMode(ctx context.Context, policyMode string, options *DataPolicyManifestsClientGetByPolicyModeOptions) (DataPolicyManifestsClientGetByPolicyModeResponse, error) { - var err error - const operationName = "DataPolicyManifestsClient.GetByPolicyMode" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getByPolicyModeCreateRequest(ctx, policyMode, options) - if err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - resp, err := client.getByPolicyModeHandleResponse(httpResp) - return resp, err -} - -// getByPolicyModeCreateRequest creates the GetByPolicyMode request. -func (client *DataPolicyManifestsClient) getByPolicyModeCreateRequest(ctx context.Context, policyMode string, _ *DataPolicyManifestsClientGetByPolicyModeOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}" - if policyMode == "" { - return nil, errors.New("parameter policyMode cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyMode}", url.PathEscape(policyMode)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-09-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByPolicyModeHandleResponse handles the GetByPolicyMode response. -func (client *DataPolicyManifestsClient) getByPolicyModeHandleResponse(resp *http.Response) (DataPolicyManifestsClientGetByPolicyModeResponse, error) { - result := DataPolicyManifestsClientGetByPolicyModeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifest); err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves a list of all the data policy manifests that match the optional given $filter. -// Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the -// unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned -// list only includes all data policy manifests that have a namespace matching -// the provided value. -// -// Generated from API version 2020-09-01 -// - options - DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.NewListPager -// method. -func (client *DataPolicyManifestsClient) NewListPager(options *DataPolicyManifestsClientListOptions) *runtime.Pager[DataPolicyManifestsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[DataPolicyManifestsClientListResponse]{ - More: func(page DataPolicyManifestsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DataPolicyManifestsClientListResponse) (DataPolicyManifestsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataPolicyManifestsClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return DataPolicyManifestsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *DataPolicyManifestsClient) listCreateRequest(ctx context.Context, options *DataPolicyManifestsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Authorization/dataPolicyManifests" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-09-01") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *DataPolicyManifestsClient) listHandleResponse(resp *http.Response) (DataPolicyManifestsClientListResponse, error) { - result := DataPolicyManifestsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifestListResult); err != nil { - return DataPolicyManifestsClientListResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go deleted file mode 100644 index 00b718d6be1b..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go +++ /dev/null @@ -1,278 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json -func ExampleDataPolicyManifestsClient_GetByPolicyMode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDataPolicyManifestsClient().GetByPolicyMode(ctx, "Microsoft.KeyVault.Data", 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.DataPolicyManifest = armpolicy.DataPolicyManifest{ - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("Audit"), - // }, - // { - // Name: to.Ptr("Deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json -func ExampleDataPolicyManifestsClient_NewListPager_listDataPolicyManifests() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDataPolicyManifestsClient().NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{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.DataPolicyManifestListResult = armpolicy.DataPolicyManifestListResult{ - // Value: []*armpolicy.DataPolicyManifest{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // }, - // { - // Name: to.Ptr("deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Kubernetes.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.Kubernetes.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // DetailsSchema: map[string]any{ - // "type": "object", - // "additionalProperties": false, - // "properties":map[string]any{ - // "constraint":map[string]any{ - // "type": "string", - // "pattern": "^(?i)(https:\\/\\/raw\\.githubusercontent\\.com\\/){1}(.+)(\\.){1}(yaml|yml){1}$", - // }, - // "constraintTemplate":map[string]any{ - // "type": "string", - // "pattern": "^(?i)(https:\\/\\/raw\\.githubusercontent\\.com\\/){1}(.+)(\\.){1}(yaml|yml){1}$", - // }, - // "values":map[string]any{ - // "type": "object", - // "additionalProperties":map[string]any{ - // }, - // "maxProperties": float64(10), - // }, - // }, - // "required":[]any{ - // "constraintTemplate", - // }, - // }, - // }}, - // IsBuiltInOnly: to.Ptr(false), - // Namespaces: []*string{ - // to.Ptr("Microsoft.Kubernetes"), - // to.Ptr("Microsoft.ContainerService")}, - // PolicyMode: to.Ptr("Microsoft.Kubernetes.Data"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json -func ExampleDataPolicyManifestsClient_NewListPager_listDataPolicyManifestsWithNamespaceFilter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDataPolicyManifestsClient().NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{Filter: to.Ptr("namespace eq 'Microsoft.KeyVault'")}) - 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.DataPolicyManifestListResult = armpolicy.DataPolicyManifestListResult{ - // Value: []*armpolicy.DataPolicyManifest{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // }, - // { - // Name: to.Ptr("deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/definitions_client.go b/sdk/resourcemanager/resources/armpolicy/definitions_client.go index b681240c5742..15dd458b6036 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/definitions_client.go @@ -44,7 +44,7 @@ func NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredenti // CreateOrUpdate - This operation creates or updates a policy definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition to create. // - parameters - The policy definition properties. // - options - DefinitionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdate @@ -87,7 +87,7 @@ func (client *DefinitionsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -109,7 +109,7 @@ func (client *DefinitionsClient) createOrUpdateHandleResponse(resp *http.Respons // the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - policyDefinitionName - The name of the policy definition to create. // - parameters - The policy definition properties. @@ -153,7 +153,7 @@ func (client *DefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -174,7 +174,7 @@ func (client *DefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(r // Delete - This operation deletes the policy definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition to delete. // - options - DefinitionsClientDeleteOptions contains the optional parameters for the DefinitionsClient.Delete method. func (client *DefinitionsClient) Delete(ctx context.Context, policyDefinitionName string, options *DefinitionsClientDeleteOptions) (DefinitionsClientDeleteResponse, error) { @@ -214,7 +214,7 @@ func (client *DefinitionsClient) deleteCreateRequest(ctx context.Context, policy return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -223,7 +223,7 @@ func (client *DefinitionsClient) deleteCreateRequest(ctx context.Context, policy // DeleteAtManagementGroup - This operation deletes the policy definition in the given management group with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - policyDefinitionName - The name of the policy definition to delete. // - options - DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup @@ -265,7 +265,7 @@ func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -274,7 +274,7 @@ func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx contex // Get - This operation retrieves the policy definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition to get. // - options - DefinitionsClientGetOptions contains the optional parameters for the DefinitionsClient.Get method. func (client *DefinitionsClient) Get(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetOptions) (DefinitionsClientGetResponse, error) { @@ -315,7 +315,7 @@ func (client *DefinitionsClient) getCreateRequest(ctx context.Context, policyDef return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -333,7 +333,7 @@ func (client *DefinitionsClient) getHandleResponse(resp *http.Response) (Definit // GetAtManagementGroup - This operation retrieves the policy definition in the given management group with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - policyDefinitionName - The name of the policy definition to get. // - options - DefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.GetAtManagementGroup @@ -376,7 +376,7 @@ func (client *DefinitionsClient) getAtManagementGroupCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -394,7 +394,7 @@ func (client *DefinitionsClient) getAtManagementGroupHandleResponse(resp *http.R // GetBuiltIn - This operation retrieves the built-in policy definition with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the built-in policy definition to get. // - options - DefinitionsClientGetBuiltInOptions contains the optional parameters for the DefinitionsClient.GetBuiltIn method. func (client *DefinitionsClient) GetBuiltIn(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetBuiltInOptions) (DefinitionsClientGetBuiltInResponse, error) { @@ -431,7 +431,7 @@ func (client *DefinitionsClient) getBuiltInCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -456,7 +456,7 @@ func (client *DefinitionsClient) getBuiltInHandleResponse(resp *http.Response) ( // are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq // {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.NewListPager method. func (client *DefinitionsClient) NewListPager(options *DefinitionsClientListOptions) *runtime.Pager[DefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DefinitionsClientListResponse]{ @@ -496,7 +496,7 @@ func (client *DefinitionsClient) listCreateRequest(ctx context.Context, options if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -522,7 +522,7 @@ func (client *DefinitionsClient) listHandleResponse(resp *http.Response) (Defini // and Static. If $filter='category -eq {value}' is provided, the returned list // only includes all built-in policy definitions whose category match the {value}. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.NewListBuiltInPager // method. func (client *DefinitionsClient) NewListBuiltInPager(options *DefinitionsClientListBuiltInOptions) *runtime.Pager[DefinitionsClientListBuiltInResponse] { @@ -559,7 +559,7 @@ func (client *DefinitionsClient) listBuiltInCreateRequest(ctx context.Context, o if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -590,7 +590,7 @@ func (client *DefinitionsClient) listBuiltInHandleResponse(resp *http.Response) // Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category // match the {value}. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - options - DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.NewListByManagementGroupPager // method. @@ -632,7 +632,7 @@ func (client *DefinitionsClient) listByManagementGroupCreateRequest(ctx context. if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { diff --git a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go deleted file mode 100644 index b1e373da8f93..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go +++ /dev/null @@ -1,850 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinition.json -func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinition() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "ResourceNaming", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json -func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinitionWithAdvancedParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "EventHubDiagnosticLogs", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised"), - DisplayName: to.Ptr("Event Hubs should have diagnostic logging enabled"), - Metadata: map[string]any{ - "category": "Event Hub", - }, - Mode: to.Ptr("Indexed"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "requiredRetentionDays": { - Type: to.Ptr(armpolicy.ParameterTypeInteger), - AllowedValues: []any{ - float64(0), - float64(30), - float64(90), - float64(180), - float64(365)}, - DefaultValue: float64(365), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("The required diagnostic logs retention in days"), - DisplayName: to.Ptr("Required retention (days)"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "equals": "Microsoft.EventHub/namespaces", - "field": "type", - }, - "then": map[string]any{ - "effect": "AuditIfNotExists", - "details": map[string]any{ - "type": "Microsoft.Insights/diagnosticSettings", - "existenceCondition": map[string]any{ - "allOf": []any{ - map[string]any{ - "equals": "true", - "field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", - }, - map[string]any{ - "equals": "[parameters('requiredRetentionDays')]", - "field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", - }, - }, - }, - }, - }, - }, - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinition.json -func ExampleDefinitionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().Delete(ctx, "ResourceNaming", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinition.json -func ExampleDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().Get(ctx, "ResourceNaming", 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.Definition = armpolicy.Definition{ - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltinPolicyDefinition.json -func ExampleDefinitionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().GetBuiltIn(ctx, "7433c107-6db4-4ad1-b57a-a76dce0154a1", 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.Definition = armpolicy.Definition{ - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json -func ExampleDefinitionsClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - }, - }, 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinitionAtManagementGroup.json -func ExampleDefinitionsClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinitionAtManagementGroup.json -func ExampleDefinitionsClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", 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.Definition = armpolicy.Definition{ - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitions.json -func ExampleDefinitionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListPager(&armpolicy.DefinitionsClientListOptions{Filter: nil, - Top: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }, - // { - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }, - // { - // Name: to.Ptr("AuditSoonToExpireCerts"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/AuditSoonToExpireCerts"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit certificates that are stored in Azure Key Vault, that expire within 'X' number of days."), - // DisplayName: to.Ptr("Audit KeyVault certificates that expire within specified number of days"), - // Metadata: map[string]any{ - // "category": "KeyVault DataPlane", - // }, - // Mode: to.Ptr("Microsoft.KeyVault.Data"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "daysToExpire": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeInteger), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The number of days for a certificate to expire."), - // DisplayName: to.Ptr("Days to expire"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn", - // "lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]", - // }, - // "then":map[string]any{ - // "effect": "audit", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicyDefinitions.json -func ExampleDefinitionsClient_NewListBuiltInPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListBuiltInPager(&armpolicy.DefinitionsClientListBuiltInOptions{Filter: nil, - Top: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("06a78e20-9358-41c9-923c-fb736d382a12"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit DB level audit setting for SQL databases"), - // DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "setting": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // AllowedValues: []any{ - // "enabled", - // "disabled"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", - // }, - // "then":map[string]any{ - // "effect": "AuditIfNotExists", - // "details":map[string]any{ - // "name": "default", - // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "[parameters('setting')]", - // "field": "Microsoft.Sql/auditingSettings.state", - // }, - // }, - // }, - // }, - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }, - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeStatic), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }, - // { - // Name: to.Ptr("abeed54a-73c5-441d-8a8c-6b5e7a0c299e"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/abeed54a-73c5-441d-8a8c-6b5e7a0c299e"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit certificates that are stored in Azure Key Vault, that expire within 'X' number of days."), - // DisplayName: to.Ptr("Audit KeyVault certificates that expire within specified number of days"), - // Metadata: map[string]any{ - // "category": "KeyVault DataPlane", - // }, - // Mode: to.Ptr("Microsoft.KeyVault.Data"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "daysToExpire": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeInteger), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The number of days for a certificate to expire."), - // DisplayName: to.Ptr("Days to expire"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn", - // "lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]", - // }, - // "then":map[string]any{ - // "effect": "audit", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitionsByManagementGroup.json -func ExampleDefinitionsClient_NewListByManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", &armpolicy.DefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }, - // { - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go index c77086c9fb53..f413fc77d68d 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go @@ -44,7 +44,7 @@ func NewDefinitionVersionsClient(subscriptionID string, credential azcore.TokenC // CreateOrUpdate - This operation creates or updates a policy definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition. // - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is // the minor version number, and z is the patch number @@ -93,7 +93,7 @@ func (client *DefinitionVersionsClient) createOrUpdateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -115,7 +115,7 @@ func (client *DefinitionVersionsClient) createOrUpdateHandleResponse(resp *http. // group with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policyDefinitionName - The name of the policy definition. // - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is @@ -165,7 +165,7 @@ func (client *DefinitionVersionsClient) createOrUpdateAtManagementGroupCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -186,7 +186,7 @@ func (client *DefinitionVersionsClient) createOrUpdateAtManagementGroupHandleRes // Delete - This operation deletes the policy definition version in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition. // - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is // the minor version number, and z is the patch number @@ -233,7 +233,7 @@ func (client *DefinitionVersionsClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -242,7 +242,7 @@ func (client *DefinitionVersionsClient) deleteCreateRequest(ctx context.Context, // DeleteAtManagementGroup - This operation deletes the policy definition in the given management group with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policyDefinitionName - The name of the policy definition. // - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is @@ -290,7 +290,7 @@ func (client *DefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -299,7 +299,7 @@ func (client *DefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx // Get - This operation retrieves the policy definition version in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition. // - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is // the minor version number, and z is the patch number @@ -346,7 +346,7 @@ func (client *DefinitionVersionsClient) getCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -365,7 +365,7 @@ func (client *DefinitionVersionsClient) getHandleResponse(resp *http.Response) ( // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policyDefinitionName - The name of the policy definition. // - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is @@ -414,7 +414,7 @@ func (client *DefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -432,7 +432,7 @@ func (client *DefinitionVersionsClient) getAtManagementGroupHandleResponse(resp // GetBuiltIn - This operation retrieves the built-in policy definition version with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition. // - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is // the minor version number, and z is the patch number @@ -476,7 +476,7 @@ func (client *DefinitionVersionsClient) getBuiltInCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -493,7 +493,7 @@ func (client *DefinitionVersionsClient) getBuiltInHandleResponse(resp *http.Resp // NewListPager - This operation retrieves a list of all the policy definition versions for the given policy definition. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition. // - options - DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager // method. @@ -539,7 +539,7 @@ func (client *DefinitionVersionsClient) listCreateRequest(ctx context.Context, p if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -557,7 +557,7 @@ func (client *DefinitionVersionsClient) listHandleResponse(resp *http.Response) // ListAll - This operation lists all the policy definition versions for all policy definitions within a subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll // method. func (client *DefinitionVersionsClient) ListAll(ctx context.Context, options *DefinitionVersionsClientListAllOptions) (DefinitionVersionsClientListAllResponse, error) { @@ -594,7 +594,7 @@ func (client *DefinitionVersionsClient) listAllCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -613,7 +613,7 @@ func (client *DefinitionVersionsClient) listAllHandleResponse(resp *http.Respons // group scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - options - DefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.ListAllAtManagementGroup // method. @@ -651,7 +651,7 @@ func (client *DefinitionVersionsClient) listAllAtManagementGroupCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -669,7 +669,7 @@ func (client *DefinitionVersionsClient) listAllAtManagementGroupHandleResponse(r // ListAllBuiltins - This operation lists all the built-in policy definition versions for all built-in policy definitions. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins // method. func (client *DefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *DefinitionVersionsClientListAllBuiltinsOptions) (DefinitionVersionsClientListAllBuiltinsResponse, error) { @@ -702,7 +702,7 @@ func (client *DefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -720,7 +720,7 @@ func (client *DefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *http // NewListBuiltInPager - This operation retrieves a list of all the built-in policy definition versions for the given policy // definition. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policyDefinitionName - The name of the policy definition. // - options - DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager // method. @@ -762,7 +762,7 @@ func (client *DefinitionVersionsClient) listBuiltInCreateRequest(ctx context.Con if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -780,7 +780,7 @@ func (client *DefinitionVersionsClient) listBuiltInHandleResponse(resp *http.Res // NewListByManagementGroupPager - This operation retrieves a list of all the policy definition versions for the given policy // definition in the given management group. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policyDefinitionName - The name of the policy definition. // - options - DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager @@ -827,7 +827,7 @@ func (client *DefinitionVersionsClient) listByManagementGroupCreateRequest(ctx c if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armpolicy/definitionversions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/definitionversions_client_example_test.go deleted file mode 100644 index 5adb85e6e6dc..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/definitionversions_client_example_test.go +++ /dev/null @@ -1,1103 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllBuiltInPolicyDefinitionVersions.json -func ExampleDefinitionVersionsClient_ListAllBuiltins() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().ListAllBuiltins(ctx, 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.DefinitionVersionListResult = armpolicy.DefinitionVersionListResult{ - // Value: []*armpolicy.DefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Audit DB level audit setting for SQL databases"), - // DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "setting": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // AllowedValues: []any{ - // "enabled", - // "disabled"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", - // }, - // "then":map[string]any{ - // "effect": "AuditIfNotExists", - // "details":map[string]any{ - // "name": "default", - // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "[parameters('setting')]", - // "field": "Microsoft.Sql/auditingSettings.state", - // }, - // }, - // }, - // }, - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // }, - // }, - // { - // Name: to.Ptr("1.0.0"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.0.0"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Audit DB level audit setting for SQL databases"), - // DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "setting": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // AllowedValues: []any{ - // "enabled", - // "disabled", - // "default"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", - // }, - // "then":map[string]any{ - // "effect": "AuditIfNotExists", - // "details":map[string]any{ - // "name": "default", - // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "[parameters('setting')]", - // "field": "Microsoft.Sql/auditingSettings.state", - // }, - // }, - // }, - // }, - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.0.0"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json -func ExampleDefinitionVersionsClient_ListAllAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().ListAllAtManagementGroup(ctx, "MyManagementGroup", 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.DefinitionVersionListResult = armpolicy.DefinitionVersionListResult{ - // Value: []*armpolicy.DefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // }, - // { - // Name: to.Ptr("1.0.0"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.0.0"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicyDefinitionVersions.json -func ExampleDefinitionVersionsClient_ListAll() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().ListAll(ctx, 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.DefinitionVersionListResult = armpolicy.DefinitionVersionListResult{ - // Value: []*armpolicy.DefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // }, - // { - // Name: to.Ptr("1.0.0"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/versions/1.0.0"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.0.0"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionVersion.json -func ExampleDefinitionVersionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().CreateOrUpdate(ctx, "ResourceNaming", "1.2.1", armpolicy.DefinitionVersion{ - Properties: &armpolicy.DefinitionVersionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - Version: to.Ptr("1.2.1"), - }, - }, 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.DefinitionVersion = armpolicy.DefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinitionVersion.json -func ExampleDefinitionVersionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionVersionsClient().Delete(ctx, "ResourceNaming", "1.2.1", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinitionVersion.json -func ExampleDefinitionVersionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().Get(ctx, "ResourceNaming", "1.2.1", 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.DefinitionVersion = armpolicy.DefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltinPolicyDefinitionVersion.json -func ExampleDefinitionVersionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().GetBuiltIn(ctx, "7433c107-6db4-4ad1-b57a-a76dce0154a1", "1.2.1", 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.DefinitionVersion = armpolicy.DefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json -func ExampleDefinitionVersionsClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", "1.2.1", armpolicy.DefinitionVersion{ - Properties: &armpolicy.DefinitionVersionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - Version: to.Ptr("1.2.1"), - }, - }, 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.DefinitionVersion = armpolicy.DefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json -func ExampleDefinitionVersionsClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionVersionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", "1.2.1", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicyDefinitionVersionAtManagementGroup.json -func ExampleDefinitionVersionsClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionVersionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "ResourceNaming", "1.2.1", 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.DefinitionVersion = armpolicy.DefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitionVersions.json -func ExampleDefinitionVersionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionVersionsClient().NewListPager("ResourceNaming", &armpolicy.DefinitionVersionsClientListOptions{Top: 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.DefinitionVersionListResult = armpolicy.DefinitionVersionListResult{ - // Value: []*armpolicy.DefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // }, - // { - // Name: to.Ptr("1.0.0"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/versions/1.0.0"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.0.0"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicyDefinitionVersions.json -func ExampleDefinitionVersionsClient_NewListBuiltInPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionVersionsClient().NewListBuiltInPager("06a78e20-9358-41c9-923c-fb736d382a12", &armpolicy.DefinitionVersionsClientListBuiltInOptions{Top: 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.DefinitionVersionListResult = armpolicy.DefinitionVersionListResult{ - // Value: []*armpolicy.DefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Audit DB level audit setting for SQL databases"), - // DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "setting": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // AllowedValues: []any{ - // "enabled", - // "disabled"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", - // }, - // "then":map[string]any{ - // "effect": "AuditIfNotExists", - // "details":map[string]any{ - // "name": "default", - // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "[parameters('setting')]", - // "field": "Microsoft.Sql/auditingSettings.state", - // }, - // }, - // }, - // }, - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // }, - // }, - // { - // Name: to.Ptr("1.0.0"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12/versions/1.0.0"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Audit DB level audit setting for SQL databases"), - // DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "setting": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // AllowedValues: []any{ - // "enabled", - // "disabled", - // "default"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", - // }, - // "then":map[string]any{ - // "effect": "AuditIfNotExists", - // "details":map[string]any{ - // "name": "default", - // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "[parameters('setting')]", - // "field": "Microsoft.Sql/auditingSettings.state", - // }, - // }, - // }, - // }, - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.0.0"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicyDefinitionVersionsByManagementGroup.json -func ExampleDefinitionVersionsClient_NewListByManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionVersionsClient().NewListByManagementGroupPager("MyManagementGroup", "ResourceNaming", &armpolicy.DefinitionVersionsClientListByManagementGroupOptions{Top: 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.DefinitionVersionListResult = armpolicy.DefinitionVersionListResult{ - // Value: []*armpolicy.DefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.2.1"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // }, - // { - // Name: to.Ptr("1.0.0"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming/versions/1.0.0"), - // Properties: &armpolicy.DefinitionVersionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '-*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go deleted file mode 100644 index f22fdbbf2149..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go +++ /dev/null @@ -1,583 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// ExemptionsClient contains the methods for the PolicyExemptions group. -// Don't use this type directly, use NewExemptionsClient() instead. -type ExemptionsClient struct { - internal *arm.Client - subscriptionID string -} - -// NewExemptionsClient creates a new instance of ExemptionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. The value must be an UUID. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewExemptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExemptionsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &ExemptionsClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a policy exemption with the given scope and name. Policy exemptions -// apply to all resources contained within their scope. For example, when you create a policy -// exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable -// resources in the resource group. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - parameters - Parameters for the policy exemption. -// - options - ExemptionsClientCreateOrUpdateOptions contains the optional parameters for the ExemptionsClient.CreateOrUpdate -// method. -func (client *ExemptionsClient) CreateOrUpdate(ctx context.Context, scope string, policyExemptionName string, parameters Exemption, options *ExemptionsClientCreateOrUpdateOptions) (ExemptionsClientCreateOrUpdateResponse, error) { - var err error - const operationName = "ExemptionsClient.CreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, scope, policyExemptionName, parameters, options) - if err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ExemptionsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, policyExemptionName string, parameters Exemption, _ *ExemptionsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ExemptionsClient) createOrUpdateHandleResponse(resp *http.Response) (ExemptionsClientCreateOrUpdateResponse, error) { - result := ExemptionsClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy -// exemption is the part of its ID preceding -// '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - options - ExemptionsClientDeleteOptions contains the optional parameters for the ExemptionsClient.Delete method. -func (client *ExemptionsClient) Delete(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientDeleteOptions) (ExemptionsClientDeleteResponse, error) { - var err error - const operationName = "ExemptionsClient.Delete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, scope, policyExemptionName, options) - if err != nil { - return ExemptionsClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientDeleteResponse{}, err - } - return ExemptionsClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ExemptionsClient) deleteCreateRequest(ctx context.Context, scope string, policyExemptionName string, _ *ExemptionsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single policy exemption, given its name and the scope it was created at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - options - ExemptionsClientGetOptions contains the optional parameters for the ExemptionsClient.Get method. -func (client *ExemptionsClient) Get(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientGetOptions) (ExemptionsClientGetResponse, error) { - var err error - const operationName = "ExemptionsClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, scope, policyExemptionName, options) - if err != nil { - return ExemptionsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *ExemptionsClient) getCreateRequest(ctx context.Context, scope string, policyExemptionName string, _ *ExemptionsClientGetOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ExemptionsClient) getHandleResponse(resp *http.Response) (ExemptionsClientGetResponse, error) { - result := ExemptionsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientGetResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all policy exemptions associated with the given subscription that match -// the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', -// 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not provided, the unfiltered list includes all policy -// exemptions associated with the subscription, including those that apply -// directly or from management groups that contain the given subscription, as well as any applied to objects contained within -// the subscription. -// -// Generated from API version 2022-07-01-preview -// - options - ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.NewListPager method. -func (client *ExemptionsClient) NewListPager(options *ExemptionsClientListOptions) *runtime.Pager[ExemptionsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListResponse]{ - More: func(page ExemptionsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListResponse) (ExemptionsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return ExemptionsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *ExemptionsClient) listCreateRequest(ctx context.Context, options *ExemptionsClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - 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.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *ExemptionsClient) listHandleResponse(resp *http.Response) (ExemptionsClientListResponse, error) { - result := ExemptionsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all policy exemptions applicable to the management -// group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', -// 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter=atScope() is provided, the returned list includes all -// policy exemptions that are assigned to the management group or the management -// group's ancestors. -// -// Generated from API version 2022-07-01-preview -// - managementGroupID - The ID of the management group. -// - options - ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.NewListForManagementGroupPager -// method. -func (client *ExemptionsClient) NewListForManagementGroupPager(managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) *runtime.Pager[ExemptionsClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForManagementGroupResponse]{ - More: func(page ExemptionsClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForManagementGroupResponse) (ExemptionsClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForManagementGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, options) - }, nil) - if err != nil { - return ExemptionsClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *ExemptionsClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *ExemptionsClient) listForManagementGroupHandleResponse(resp *http.Response) (ExemptionsClientListForManagementGroupResponse, error) { - result := ExemptionsClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForManagementGroupResponse{}, err - } - return result, nil -} - -// NewListForResourcePager - This operation retrieves the list of all policy exemptions associated with the specified resource -// in the given resource group and subscription that match the optional given $filter. Valid values for -// $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not -// provided, the unfiltered list includes all policy exemptions associated with the -// resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained -// within the resource. Three parameters plus the resource name are used to -// identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource -// path should not be provided (or provided as ”). For example a web app could -// be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == ”, {resourceType} == 'sites', -// {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, -// then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} -// == 'Microsoft.Compute', {parentResourcePath} == -// 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient -// alternative to providing the namespace and type name separately is to provide -// both in the {resourceType} parameter, format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, {resourceType} -// == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). -// -// Generated from API version 2022-07-01-preview -// - resourceGroupName - The name of the resource group containing the resource. -// - resourceProviderNamespace - The namespace of the resource provider. For example, the namespace of a virtual machine is -// Microsoft.Compute (from Microsoft.Compute/virtualMachines) -// - parentResourcePath - The parent resource path. Use empty string if there is none. -// - resourceType - The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). -// - resourceName - The name of the resource. -// - options - ExemptionsClientListForResourceOptions contains the optional parameters for the ExemptionsClient.NewListForResourcePager -// method. -func (client *ExemptionsClient) NewListForResourcePager(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) *runtime.Pager[ExemptionsClientListForResourceResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForResourceResponse]{ - More: func(page ExemptionsClientListForResourceResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceResponse) (ExemptionsClientListForResourceResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForResourcePager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, options) - }, nil) - if err != nil { - return ExemptionsClientListForResourceResponse{}, err - } - return client.listForResourceHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForResourceCreateRequest creates the ListForResource request. -func (client *ExemptionsClient) listForResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if resourceProviderNamespace == "" { - return nil, errors.New("parameter resourceProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceProviderNamespace}", url.PathEscape(resourceProviderNamespace)) - urlPath = strings.ReplaceAll(urlPath, "{parentResourcePath}", parentResourcePath) - urlPath = strings.ReplaceAll(urlPath, "{resourceType}", resourceType) - if resourceName == "" { - 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.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForResourceHandleResponse handles the ListForResource response. -func (client *ExemptionsClient) listForResourceHandleResponse(resp *http.Response) (ExemptionsClientListForResourceResponse, error) { - result := ExemptionsClientListForResourceResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForResourceResponse{}, err - } - return result, nil -} - -// NewListForResourceGroupPager - This operation retrieves the list of all policy exemptions associated with the given resource -// group in the given subscription that match the optional given $filter. Valid values for $filter are: -// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not provided, the -// unfiltered list includes all policy exemptions associated with the resource -// group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained -// within the resource group. -// -// Generated from API version 2022-07-01-preview -// - resourceGroupName - The name of the resource group containing the resource. -// - options - ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.NewListForResourceGroupPager -// method. -func (client *ExemptionsClient) NewListForResourceGroupPager(resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) *runtime.Pager[ExemptionsClientListForResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForResourceGroupResponse]{ - More: func(page ExemptionsClientListForResourceGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceGroupResponse) (ExemptionsClientListForResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForResourceGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForResourceGroupCreateRequest(ctx, resourceGroupName, options) - }, nil) - if err != nil { - return ExemptionsClientListForResourceGroupResponse{}, err - } - return client.listForResourceGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForResourceGroupCreateRequest creates the ListForResourceGroup request. -func (client *ExemptionsClient) listForResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - 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.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForResourceGroupHandleResponse handles the ListForResourceGroup response. -func (client *ExemptionsClient) listForResourceGroupHandleResponse(resp *http.Response) (ExemptionsClientListForResourceGroupResponse, error) { - result := ExemptionsClientListForResourceGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForResourceGroupResponse{}, err - } - return result, nil -} - -// Update - This operation updates a policy exemption with the given scope and name. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - parameters - Parameters for policy exemption patch request. -// - options - ExemptionsClientUpdateOptions contains the optional parameters for the ExemptionsClient.Update method. -func (client *ExemptionsClient) Update(ctx context.Context, scope string, policyExemptionName string, parameters ExemptionUpdate, options *ExemptionsClientUpdateOptions) (ExemptionsClientUpdateResponse, error) { - var err error - const operationName = "ExemptionsClient.Update" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, scope, policyExemptionName, parameters, options) - if err != nil { - return ExemptionsClientUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientUpdateResponse{}, err - } - resp, err := client.updateHandleResponse(httpResp) - return resp, err -} - -// updateCreateRequest creates the Update request. -func (client *ExemptionsClient) updateCreateRequest(ctx context.Context, scope string, policyExemptionName string, parameters ExemptionUpdate, _ *ExemptionsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// updateHandleResponse handles the Update response. -func (client *ExemptionsClient) updateHandleResponse(resp *http.Response) (ExemptionsClientUpdateResponse, error) { - result := ExemptionsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientUpdateResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go deleted file mode 100644 index 888f353ed8f8..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go +++ /dev/null @@ -1,639 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/deletePolicyExemption.json -func ExampleExemptionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExemptionsClient().Delete(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/createOrUpdatePolicyExemption.json -func ExampleExemptionsClient_CreateOrUpdate_createOrUpdateAPolicyExemption() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().CreateOrUpdate(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.Ptr("Exempt demo cluster from limit sku"), - DisplayName: to.Ptr("Exempt demo cluster"), - ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - Metadata: map[string]any{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - PolicyDefinitionReferenceIDs: []*string{ - to.Ptr("Limit_Skus")}, - }, - }, 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/createOrUpdatePolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_CreateOrUpdate_createOrUpdateAPolicyExemptionWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().CreateOrUpdate(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.Ptr("Exempt demo cluster from limit sku"), - AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - DisplayName: to.Ptr("Exempt demo cluster"), - ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - Metadata: map[string]any{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - PolicyDefinitionReferenceIDs: []*string{ - to.Ptr("Limit_Skus")}, - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/getPolicyExemption.json -func ExampleExemptionsClient_Get_retrieveAPolicyExemption() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/getPolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_Get_retrieveAPolicyExemptionWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/updatePolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.ExemptionUpdate{ - Properties: &armpolicy.ExemptionUpdateProperties{ - AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForSubscription.json -func ExampleExemptionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListPager(&armpolicy.ExemptionsClientListOptions{Filter: to.Ptr("atScope()")}) - 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("TestVMSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVMSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("TestVNetSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVNetSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json -func ExampleExemptionsClient_NewListForResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.ExemptionsClientListForResourceGroupOptions{Filter: to.Ptr("atScope()")}) - 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("TestVMSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVMSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("TestVNetRG"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyExemptions/TestVNetRG"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForResource.json -func ExampleExemptionsClient_NewListForResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForResourcePager("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", "MyTestComputer.cloudapp.net", &armpolicy.ExemptionsClientListForResourceOptions{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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("DemoExpensiveVMGroup"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVMGroup"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("jumpBoxExemption"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Compute/virtualMachines/MyTestVm/providers/Microsoft.Authorization/policyExemptions/jumpBoxExemption"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json -func ExampleExemptionsClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForManagementGroupPager("DevOrg", &armpolicy.ExemptionsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()")}) - 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("ResearchBudgetExemption"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyExemptions/ResearchBudgetExemption"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/HardwareDivision/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("VNetIsMonitored"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyExemptions/VNetIsMonitored"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/HardwareDivision/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go b/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go index fc3c46250297..036ae017ba69 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go @@ -347,23 +347,11 @@ func (a *AssignmentsServerTransport) dispatchGetByID(req *http.Request) (*http.R if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - qp := req.URL.Query() policyAssignmentIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyAssignmentId")]) if err != nil { return nil, err } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) - if err != nil { - return nil, err - } - expandParam := getOptional(expandUnescaped) - var options *armpolicy.AssignmentsClientGetByIDOptions - if expandParam != nil { - options = &armpolicy.AssignmentsClientGetByIDOptions{ - Expand: expandParam, - } - } - respr, errRespr := a.srv.GetByID(req.Context(), policyAssignmentIDParam, options) + respr, errRespr := a.srv.GetByID(req.Context(), policyAssignmentIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go b/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go deleted file mode 100644 index 358e7be95812..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go +++ /dev/null @@ -1,168 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// DataPolicyManifestsServer is a fake server for instances of the armpolicy.DataPolicyManifestsClient type. -type DataPolicyManifestsServer struct { - // GetByPolicyMode is the fake for method DataPolicyManifestsClient.GetByPolicyMode - // HTTP status codes to indicate success: http.StatusOK - GetByPolicyMode func(ctx context.Context, policyMode string, options *armpolicy.DataPolicyManifestsClientGetByPolicyModeOptions) (resp azfake.Responder[armpolicy.DataPolicyManifestsClientGetByPolicyModeResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method DataPolicyManifestsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.DataPolicyManifestsClientListOptions) (resp azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]) -} - -// NewDataPolicyManifestsServerTransport creates a new instance of DataPolicyManifestsServerTransport with the provided implementation. -// The returned DataPolicyManifestsServerTransport instance is connected to an instance of armpolicy.DataPolicyManifestsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewDataPolicyManifestsServerTransport(srv *DataPolicyManifestsServer) *DataPolicyManifestsServerTransport { - return &DataPolicyManifestsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]](), - } -} - -// DataPolicyManifestsServerTransport connects instances of armpolicy.DataPolicyManifestsClient to instances of DataPolicyManifestsServer. -// Don't use this type directly, use NewDataPolicyManifestsServerTransport instead. -type DataPolicyManifestsServerTransport struct { - srv *DataPolicyManifestsServer - newListPager *tracker[azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]] -} - -// Do implements the policy.Transporter interface for DataPolicyManifestsServerTransport. -func (d *DataPolicyManifestsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return d.dispatchToMethodFake(req, method) -} - -func (d *DataPolicyManifestsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if dataPolicyManifestsServerTransportInterceptor != nil { - res.resp, res.err, intercepted = dataPolicyManifestsServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "DataPolicyManifestsClient.GetByPolicyMode": - res.resp, res.err = d.dispatchGetByPolicyMode(req) - case "DataPolicyManifestsClient.NewListPager": - res.resp, res.err = d.dispatchNewListPager(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (d *DataPolicyManifestsServerTransport) dispatchGetByPolicyMode(req *http.Request) (*http.Response, error) { - if d.srv.GetByPolicyMode == nil { - return nil, &nonRetriableError{errors.New("fake for method GetByPolicyMode not implemented")} - } - const regexStr = `/providers/Microsoft\.Authorization/dataPolicyManifests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - policyModeParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyMode")]) - if err != nil { - return nil, err - } - respr, errRespr := d.srv.GetByPolicyMode(req.Context(), policyModeParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataPolicyManifest, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (d *DataPolicyManifestsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if d.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := d.newListPager.get(req) - if newListPager == nil { - qp := req.URL.Query() - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.DataPolicyManifestsClientListOptions - if filterParam != nil { - options = &armpolicy.DataPolicyManifestsClientListOptions{ - Filter: filterParam, - } - } - resp := d.srv.NewListPager(options) - newListPager = &resp - d.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.DataPolicyManifestsClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - d.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - d.newListPager.remove(req) - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to DataPolicyManifestsServerTransport -var dataPolicyManifestsServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go deleted file mode 100644 index c42f814585e9..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go +++ /dev/null @@ -1,490 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// ExemptionsServer is a fake server for instances of the armpolicy.ExemptionsClient type. -type ExemptionsServer struct { - // CreateOrUpdate is the fake for method ExemptionsClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, scope string, policyExemptionName string, parameters armpolicy.Exemption, options *armpolicy.ExemptionsClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.ExemptionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method ExemptionsClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, scope string, policyExemptionName string, options *armpolicy.ExemptionsClientDeleteOptions) (resp azfake.Responder[armpolicy.ExemptionsClientDeleteResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method ExemptionsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, scope string, policyExemptionName string, options *armpolicy.ExemptionsClientGetOptions) (resp azfake.Responder[armpolicy.ExemptionsClientGetResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method ExemptionsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.ExemptionsClientListOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]) - - // NewListForManagementGroupPager is the fake for method ExemptionsClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, options *armpolicy.ExemptionsClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]) - - // NewListForResourcePager is the fake for method ExemptionsClient.NewListForResourcePager - // HTTP status codes to indicate success: http.StatusOK - NewListForResourcePager func(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *armpolicy.ExemptionsClientListForResourceOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]) - - // NewListForResourceGroupPager is the fake for method ExemptionsClient.NewListForResourceGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForResourceGroupPager func(resourceGroupName string, options *armpolicy.ExemptionsClientListForResourceGroupOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]) - - // Update is the fake for method ExemptionsClient.Update - // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, scope string, policyExemptionName string, parameters armpolicy.ExemptionUpdate, options *armpolicy.ExemptionsClientUpdateOptions) (resp azfake.Responder[armpolicy.ExemptionsClientUpdateResponse], errResp azfake.ErrorResponder) -} - -// NewExemptionsServerTransport creates a new instance of ExemptionsServerTransport with the provided implementation. -// The returned ExemptionsServerTransport instance is connected to an instance of armpolicy.ExemptionsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewExemptionsServerTransport(srv *ExemptionsServer) *ExemptionsServerTransport { - return &ExemptionsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]](), - newListForResourcePager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]](), - newListForResourceGroupPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]](), - } -} - -// ExemptionsServerTransport connects instances of armpolicy.ExemptionsClient to instances of ExemptionsServer. -// Don't use this type directly, use NewExemptionsServerTransport instead. -type ExemptionsServerTransport struct { - srv *ExemptionsServer - newListPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]] - newListForResourcePager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]] - newListForResourceGroupPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]] -} - -// Do implements the policy.Transporter interface for ExemptionsServerTransport. -func (e *ExemptionsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return e.dispatchToMethodFake(req, method) -} - -func (e *ExemptionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if exemptionsServerTransportInterceptor != nil { - res.resp, res.err, intercepted = exemptionsServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "ExemptionsClient.CreateOrUpdate": - res.resp, res.err = e.dispatchCreateOrUpdate(req) - case "ExemptionsClient.Delete": - res.resp, res.err = e.dispatchDelete(req) - case "ExemptionsClient.Get": - res.resp, res.err = e.dispatchGet(req) - case "ExemptionsClient.NewListPager": - res.resp, res.err = e.dispatchNewListPager(req) - case "ExemptionsClient.NewListForManagementGroupPager": - res.resp, res.err = e.dispatchNewListForManagementGroupPager(req) - case "ExemptionsClient.NewListForResourcePager": - res.resp, res.err = e.dispatchNewListForResourcePager(req) - case "ExemptionsClient.NewListForResourceGroupPager": - res.resp, res.err = e.dispatchNewListForResourceGroupPager(req) - case "ExemptionsClient.Update": - res.resp, res.err = e.dispatchUpdate(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (e *ExemptionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if e.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Exemption](req) - if err != nil { - return nil, err - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.CreateOrUpdate(req.Context(), scopeParam, policyExemptionNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if e.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Delete(req.Context(), scopeParam, policyExemptionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if e.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Get(req.Context(), scopeParam, policyExemptionNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := e.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListPager(options) - newListPager = &resp - e.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.ExemptionsClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - e.newListPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := e.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForManagementGroupOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForManagementGroupOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForManagementGroupPager(managementGroupIDParam, options) - newListForManagementGroupPager = &resp - e.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.ExemptionsClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - e.newListForManagementGroupPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForResourcePager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForResourcePager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForResourcePager not implemented")} - } - newListForResourcePager := e.newListForResourcePager.get(req) - if newListForResourcePager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resourceProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourcePathParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourcePath")]) - if err != nil { - return nil, err - } - resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForResourceOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForResourceOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForResourcePager(resourceGroupNameParam, resourceProviderNamespaceParam, parentResourcePathParam, resourceTypeParam, resourceNameParam, options) - newListForResourcePager = &resp - e.newListForResourcePager.add(req, newListForResourcePager) - server.PagerResponderInjectNextLinks(newListForResourcePager, req, func(page *armpolicy.ExemptionsClientListForResourceResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForResourcePager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForResourcePager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForResourcePager) { - e.newListForResourcePager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForResourceGroupPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForResourceGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForResourceGroupPager not implemented")} - } - newListForResourceGroupPager := e.newListForResourceGroupPager.get(req) - if newListForResourceGroupPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForResourceGroupOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForResourceGroupOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForResourceGroupPager(resourceGroupNameParam, options) - newListForResourceGroupPager = &resp - e.newListForResourceGroupPager.add(req, newListForResourceGroupPager) - server.PagerResponderInjectNextLinks(newListForResourceGroupPager, req, func(page *armpolicy.ExemptionsClientListForResourceGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForResourceGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForResourceGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForResourceGroupPager) { - e.newListForResourceGroupPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if e.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.ExemptionUpdate](req) - if err != nil { - return nil, err - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Update(req.Context(), scopeParam, policyExemptionNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to ExemptionsServerTransport -var exemptionsServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go b/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go index 7d16b3ac430a..419176cd9d44 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go @@ -19,29 +19,20 @@ type ServerFactory struct { // AssignmentsServer contains the fakes for client AssignmentsClient AssignmentsServer AssignmentsServer - // DataPolicyManifestsServer contains the fakes for client DataPolicyManifestsClient - DataPolicyManifestsServer DataPolicyManifestsServer - // DefinitionVersionsServer contains the fakes for client DefinitionVersionsClient DefinitionVersionsServer DefinitionVersionsServer // DefinitionsServer contains the fakes for client DefinitionsClient DefinitionsServer DefinitionsServer - // ExemptionsServer contains the fakes for client ExemptionsClient - ExemptionsServer ExemptionsServer - // SetDefinitionVersionsServer contains the fakes for client SetDefinitionVersionsClient SetDefinitionVersionsServer SetDefinitionVersionsServer // SetDefinitionsServer contains the fakes for client SetDefinitionsClient SetDefinitionsServer SetDefinitionsServer - // VariableValuesServer contains the fakes for client VariableValuesClient - VariableValuesServer VariableValuesServer - - // VariablesServer contains the fakes for client VariablesClient - VariablesServer VariablesServer + // TokensServer contains the fakes for client TokensClient + TokensServer TokensServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -59,14 +50,11 @@ type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex trAssignmentsServer *AssignmentsServerTransport - trDataPolicyManifestsServer *DataPolicyManifestsServerTransport trDefinitionVersionsServer *DefinitionVersionsServerTransport trDefinitionsServer *DefinitionsServerTransport - trExemptionsServer *ExemptionsServerTransport trSetDefinitionVersionsServer *SetDefinitionVersionsServerTransport trSetDefinitionsServer *SetDefinitionsServerTransport - trVariableValuesServer *VariableValuesServerTransport - trVariablesServer *VariablesServerTransport + trTokensServer *TokensServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -85,11 +73,6 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "AssignmentsClient": initServer(s, &s.trAssignmentsServer, func() *AssignmentsServerTransport { return NewAssignmentsServerTransport(&s.srv.AssignmentsServer) }) resp, err = s.trAssignmentsServer.Do(req) - case "DataPolicyManifestsClient": - initServer(s, &s.trDataPolicyManifestsServer, func() *DataPolicyManifestsServerTransport { - return NewDataPolicyManifestsServerTransport(&s.srv.DataPolicyManifestsServer) - }) - resp, err = s.trDataPolicyManifestsServer.Do(req) case "DefinitionVersionsClient": initServer(s, &s.trDefinitionVersionsServer, func() *DefinitionVersionsServerTransport { return NewDefinitionVersionsServerTransport(&s.srv.DefinitionVersionsServer) @@ -98,9 +81,6 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "DefinitionsClient": initServer(s, &s.trDefinitionsServer, func() *DefinitionsServerTransport { return NewDefinitionsServerTransport(&s.srv.DefinitionsServer) }) resp, err = s.trDefinitionsServer.Do(req) - case "ExemptionsClient": - initServer(s, &s.trExemptionsServer, func() *ExemptionsServerTransport { return NewExemptionsServerTransport(&s.srv.ExemptionsServer) }) - resp, err = s.trExemptionsServer.Do(req) case "SetDefinitionVersionsClient": initServer(s, &s.trSetDefinitionVersionsServer, func() *SetDefinitionVersionsServerTransport { return NewSetDefinitionVersionsServerTransport(&s.srv.SetDefinitionVersionsServer) @@ -111,14 +91,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewSetDefinitionsServerTransport(&s.srv.SetDefinitionsServer) }) resp, err = s.trSetDefinitionsServer.Do(req) - case "VariableValuesClient": - initServer(s, &s.trVariableValuesServer, func() *VariableValuesServerTransport { - return NewVariableValuesServerTransport(&s.srv.VariableValuesServer) - }) - resp, err = s.trVariableValuesServer.Do(req) - case "VariablesClient": - initServer(s, &s.trVariablesServer, func() *VariablesServerTransport { return NewVariablesServerTransport(&s.srv.VariablesServer) }) - resp, err = s.trVariablesServer.Do(req) + case "TokensClient": + initServer(s, &s.trTokensServer, func() *TokensServerTransport { return NewTokensServerTransport(&s.srv.TokensServer) }) + resp, err = s.trTokensServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/resources/armpolicy/fake/tokens_server.go b/sdk/resourcemanager/resources/armpolicy/fake/tokens_server.go new file mode 100644 index 000000000000..2f2ec2b0aab4 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/fake/tokens_server.go @@ -0,0 +1,132 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "net/http" + "regexp" +) + +// TokensServer is a fake server for instances of the armpolicy.TokensClient type. +type TokensServer struct { + // BeginAcquire is the fake for method TokensClient.BeginAcquire + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginAcquire func(ctx context.Context, parameters armpolicy.TokenRequest, options *armpolicy.TokensClientBeginAcquireOptions) (resp azfake.PollerResponder[armpolicy.TokensClientAcquireResponse], errResp azfake.ErrorResponder) +} + +// NewTokensServerTransport creates a new instance of TokensServerTransport with the provided implementation. +// The returned TokensServerTransport instance is connected to an instance of armpolicy.TokensClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTokensServerTransport(srv *TokensServer) *TokensServerTransport { + return &TokensServerTransport{ + srv: srv, + beginAcquire: newTracker[azfake.PollerResponder[armpolicy.TokensClientAcquireResponse]](), + } +} + +// TokensServerTransport connects instances of armpolicy.TokensClient to instances of TokensServer. +// Don't use this type directly, use NewTokensServerTransport instead. +type TokensServerTransport struct { + srv *TokensServer + beginAcquire *tracker[azfake.PollerResponder[armpolicy.TokensClientAcquireResponse]] +} + +// Do implements the policy.Transporter interface for TokensServerTransport. +func (t *TokensServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TokensServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if tokensServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tokensServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TokensClient.BeginAcquire": + res.resp, res.err = t.dispatchBeginAcquire(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TokensServerTransport) dispatchBeginAcquire(req *http.Request) (*http.Response, error) { + if t.srv.BeginAcquire == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginAcquire not implemented")} + } + beginAcquire := t.beginAcquire.get(req) + if beginAcquire == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/acquirePolicyToken` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpolicy.TokenRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginAcquire(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginAcquire = &respr + t.beginAcquire.add(req, beginAcquire) + } + + resp, err := server.PollerResponderNext(beginAcquire, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.beginAcquire.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginAcquire) { + t.beginAcquire.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to TokensServerTransport +var tokensServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go b/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go deleted file mode 100644 index 356e862082cd..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go +++ /dev/null @@ -1,402 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// VariablesServer is a fake server for instances of the armpolicy.VariablesClient type. -type VariablesServer struct { - // CreateOrUpdate is the fake for method VariablesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, variableName string, parameters armpolicy.Variable, options *armpolicy.VariablesClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.VariablesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // CreateOrUpdateAtManagementGroup is the fake for method VariablesClient.CreateOrUpdateAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, parameters armpolicy.Variable, options *armpolicy.VariablesClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method VariablesClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, variableName string, options *armpolicy.VariablesClientDeleteOptions) (resp azfake.Responder[armpolicy.VariablesClientDeleteResponse], errResp azfake.ErrorResponder) - - // DeleteAtManagementGroup is the fake for method VariablesClient.DeleteAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, options *armpolicy.VariablesClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method VariablesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, variableName string, options *armpolicy.VariablesClientGetOptions) (resp azfake.Responder[armpolicy.VariablesClientGetResponse], errResp azfake.ErrorResponder) - - // GetAtManagementGroup is the fake for method VariablesClient.GetAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, options *armpolicy.VariablesClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method VariablesClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.VariablesClientListOptions) (resp azfake.PagerResponder[armpolicy.VariablesClientListResponse]) - - // NewListForManagementGroupPager is the fake for method VariablesClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, options *armpolicy.VariablesClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]) -} - -// NewVariablesServerTransport creates a new instance of VariablesServerTransport with the provided implementation. -// The returned VariablesServerTransport instance is connected to an instance of armpolicy.VariablesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewVariablesServerTransport(srv *VariablesServer) *VariablesServerTransport { - return &VariablesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.VariablesClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]](), - } -} - -// VariablesServerTransport connects instances of armpolicy.VariablesClient to instances of VariablesServer. -// Don't use this type directly, use NewVariablesServerTransport instead. -type VariablesServerTransport struct { - srv *VariablesServer - newListPager *tracker[azfake.PagerResponder[armpolicy.VariablesClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]] -} - -// Do implements the policy.Transporter interface for VariablesServerTransport. -func (v *VariablesServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return v.dispatchToMethodFake(req, method) -} - -func (v *VariablesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if variablesServerTransportInterceptor != nil { - res.resp, res.err, intercepted = variablesServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "VariablesClient.CreateOrUpdate": - res.resp, res.err = v.dispatchCreateOrUpdate(req) - case "VariablesClient.CreateOrUpdateAtManagementGroup": - res.resp, res.err = v.dispatchCreateOrUpdateAtManagementGroup(req) - case "VariablesClient.Delete": - res.resp, res.err = v.dispatchDelete(req) - case "VariablesClient.DeleteAtManagementGroup": - res.resp, res.err = v.dispatchDeleteAtManagementGroup(req) - case "VariablesClient.Get": - res.resp, res.err = v.dispatchGet(req) - case "VariablesClient.GetAtManagementGroup": - res.resp, res.err = v.dispatchGetAtManagementGroup(req) - case "VariablesClient.NewListPager": - res.resp, res.err = v.dispatchNewListPager(req) - case "VariablesClient.NewListForManagementGroupPager": - res.resp, res.err = v.dispatchNewListForManagementGroupPager(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (v *VariablesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Variable](req) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdate(req.Context(), variableNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdateAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Variable](req) - if err != nil { - return nil, err - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if v.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Delete(req.Context(), variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.DeleteAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method DeleteAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if v.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Get(req.Context(), variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.GetAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := v.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resp := v.srv.NewListPager(nil) - newListPager = &resp - v.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.VariablesClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - v.newListPager.remove(req) - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := v.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListForManagementGroupPager(managementGroupIDParam, nil) - newListForManagementGroupPager = &resp - v.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.VariablesClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - v.newListForManagementGroupPager.remove(req) - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to VariablesServerTransport -var variablesServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go b/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go deleted file mode 100644 index d9e5f5ed0c31..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go +++ /dev/null @@ -1,434 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - "net/http" - "net/url" - "regexp" -) - -// VariableValuesServer is a fake server for instances of the armpolicy.VariableValuesClient type. -type VariableValuesServer struct { - // CreateOrUpdate is the fake for method VariableValuesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, variableName string, variableValueName string, parameters armpolicy.VariableValue, options *armpolicy.VariableValuesClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.VariableValuesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // CreateOrUpdateAtManagementGroup is the fake for method VariableValuesClient.CreateOrUpdateAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters armpolicy.VariableValue, options *armpolicy.VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method VariableValuesClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, variableName string, variableValueName string, options *armpolicy.VariableValuesClientDeleteOptions) (resp azfake.Responder[armpolicy.VariableValuesClientDeleteResponse], errResp azfake.ErrorResponder) - - // DeleteAtManagementGroup is the fake for method VariableValuesClient.DeleteAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *armpolicy.VariableValuesClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method VariableValuesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, variableName string, variableValueName string, options *armpolicy.VariableValuesClientGetOptions) (resp azfake.Responder[armpolicy.VariableValuesClientGetResponse], errResp azfake.ErrorResponder) - - // GetAtManagementGroup is the fake for method VariableValuesClient.GetAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *armpolicy.VariableValuesClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method VariableValuesClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(variableName string, options *armpolicy.VariableValuesClientListOptions) (resp azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]) - - // NewListForManagementGroupPager is the fake for method VariableValuesClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, variableName string, options *armpolicy.VariableValuesClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]) -} - -// NewVariableValuesServerTransport creates a new instance of VariableValuesServerTransport with the provided implementation. -// The returned VariableValuesServerTransport instance is connected to an instance of armpolicy.VariableValuesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewVariableValuesServerTransport(srv *VariableValuesServer) *VariableValuesServerTransport { - return &VariableValuesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]](), - } -} - -// VariableValuesServerTransport connects instances of armpolicy.VariableValuesClient to instances of VariableValuesServer. -// Don't use this type directly, use NewVariableValuesServerTransport instead. -type VariableValuesServerTransport struct { - srv *VariableValuesServer - newListPager *tracker[azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]] -} - -// Do implements the policy.Transporter interface for VariableValuesServerTransport. -func (v *VariableValuesServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - return v.dispatchToMethodFake(req, method) -} - -func (v *VariableValuesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { - resultChan := make(chan result) - defer close(resultChan) - - go func() { - var intercepted bool - var res result - if variableValuesServerTransportInterceptor != nil { - res.resp, res.err, intercepted = variableValuesServerTransportInterceptor.Do(req) - } - if !intercepted { - switch method { - case "VariableValuesClient.CreateOrUpdate": - res.resp, res.err = v.dispatchCreateOrUpdate(req) - case "VariableValuesClient.CreateOrUpdateAtManagementGroup": - res.resp, res.err = v.dispatchCreateOrUpdateAtManagementGroup(req) - case "VariableValuesClient.Delete": - res.resp, res.err = v.dispatchDelete(req) - case "VariableValuesClient.DeleteAtManagementGroup": - res.resp, res.err = v.dispatchDeleteAtManagementGroup(req) - case "VariableValuesClient.Get": - res.resp, res.err = v.dispatchGet(req) - case "VariableValuesClient.GetAtManagementGroup": - res.resp, res.err = v.dispatchGetAtManagementGroup(req) - case "VariableValuesClient.NewListPager": - res.resp, res.err = v.dispatchNewListPager(req) - case "VariableValuesClient.NewListForManagementGroupPager": - res.resp, res.err = v.dispatchNewListForManagementGroupPager(req) - default: - res.err = fmt.Errorf("unhandled API %s", method) - } - - } - select { - case resultChan <- res: - case <-req.Context().Done(): - } - }() - - select { - case <-req.Context().Done(): - return nil, req.Context().Err() - case res := <-resultChan: - return res.resp, res.err - } -} - -func (v *VariableValuesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.VariableValue](req) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdate(req.Context(), variableNameParam, variableValueNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.CreateOrUpdateAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.VariableValue](req) - if err != nil { - return nil, err - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if v.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Delete(req.Context(), variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.DeleteAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method DeleteAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} - } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if v.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Get(req.Context(), variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.srv.GetAtManagementGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroup not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := v.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListPager(variableNameParam, nil) - newListPager = &resp - v.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.VariableValuesClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - v.newListPager.remove(req) - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := v.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListForManagementGroupPager(managementGroupIDParam, variableNameParam, nil) - newListForManagementGroupPager = &resp - v.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.VariableValuesClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - v.newListForManagementGroupPager.remove(req) - } - return resp, nil -} - -// set this to conditionally intercept incoming requests to VariableValuesServerTransport -var variableValuesServerTransportInterceptor interface { - // Do returns true if the server transport should use the returned response/error - Do(*http.Request) (*http.Response, error, bool) -} diff --git a/sdk/resourcemanager/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index b725a84d1da8..a7fa9dd1e69d 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.mod +++ b/sdk/resourcemanager/resources/armpolicy/go.mod @@ -4,13 +4,13 @@ go 1.23.0 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.10.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armpolicy/models.go b/sdk/resourcemanager/resources/armpolicy/models.go index 9d744706b094..3116b76ff316 100644 --- a/sdk/resourcemanager/resources/armpolicy/models.go +++ b/sdk/resourcemanager/resources/armpolicy/models.go @@ -7,62 +7,6 @@ package armpolicy import "time" -// Alias - The alias type. -type Alias struct { - // The default path for an alias. - DefaultPath *string - - // The default pattern for an alias. - DefaultPattern *AliasPattern - - // The alias name. - Name *string - - // The paths for an alias. - Paths []*AliasPath - - // The type of the alias. - Type *AliasType - - // READ-ONLY; The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata - DefaultMetadata *AliasPathMetadata -} - -// AliasPath - The type of the paths for alias. -type AliasPath struct { - // The API versions. - APIVersions []*string - - // The path of an alias. - Path *string - - // The pattern for an alias path. - Pattern *AliasPattern - - // READ-ONLY; The metadata of the alias path. If missing, fall back to the default metadata of the alias. - Metadata *AliasPathMetadata -} - -type AliasPathMetadata struct { - // READ-ONLY; The attributes of the token that the alias path is referring to. - Attributes *AliasPathAttributes - - // READ-ONLY; The type of the token that the alias path is referring to. - Type *AliasPathTokenType -} - -// AliasPattern - The type of the pattern for an alias path. -type AliasPattern struct { - // The alias pattern phrase. - Phrase *string - - // The type of alias pattern - Type *AliasPatternType - - // The alias pattern variable. - Variable *string -} - // Assignment - The policy assignment. type Assignment struct { // The managed identity associated with the policy assignment. @@ -98,6 +42,9 @@ type AssignmentListResult struct { // AssignmentProperties - The policy assignment properties. type AssignmentProperties struct { + // The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. + AssignmentType *AssignmentType + // The version of the policy definition to use. DefinitionVersion *string @@ -107,7 +54,7 @@ type AssignmentProperties struct { // The display name of the policy assignment. DisplayName *string - // The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. + // The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll EnforcementMode *EnforcementMode // The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. @@ -135,6 +82,10 @@ type AssignmentProperties struct { // parameter. EffectiveDefinitionVersion *string + // READ-ONLY; The instance ID of the policy assignment. This ID only and always changes when the assignment is deleted and + // recreated. + InstanceID *string + // READ-ONLY; The latest version of the policy definition available. This is only present if requested via the $expand query // parameter. LatestDefinitionVersion *string @@ -164,89 +115,6 @@ type AssignmentUpdateProperties struct { ResourceSelectors []*ResourceSelector } -// DataEffect - The data effect definition. -type DataEffect struct { - // The data effect details schema. - DetailsSchema any - - // The data effect name. - Name *string -} - -// DataManifestCustomResourceFunctionDefinition - The custom resource function definition. -type DataManifestCustomResourceFunctionDefinition struct { - // A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified - // in the policy rule eg - vault('2019-06-01'). - AllowCustomProperties *bool - - // The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and - // vault().location are supported - DefaultProperties []*string - - // The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. - FullyQualifiedResourceType *string - - // The function name as it will appear in the policy rule. eg - 'vault'. - Name *string -} - -// DataManifestResourceFunctionsDefinition - The resource functions supported by a manifest -type DataManifestResourceFunctionsDefinition struct { - // An array of data manifest custom resource definition. - Custom []*DataManifestCustomResourceFunctionDefinition - - // The standard resource functions (subscription and/or resourceGroup). - Standard []*string -} - -// DataPolicyManifest - The data policy manifest. -type DataPolicyManifest struct { - // The data policy manifest properties. - Properties *DataPolicyManifestProperties - - // READ-ONLY; The ID of the data policy manifest. - ID *string - - // READ-ONLY; The name of the data policy manifest (it's the same as the Policy Mode). - Name *string - - // READ-ONLY; The type of the resource (Microsoft.Authorization/dataPolicyManifests). - Type *string -} - -// DataPolicyManifestListResult - List of data policy manifests. -type DataPolicyManifestListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of data policy manifests. - Value []*DataPolicyManifest -} - -// DataPolicyManifestProperties - The properties of the data policy manifest. -type DataPolicyManifestProperties struct { - // The effect definition. - Effects []*DataEffect - - // The non-alias field accessor values that can be used in the policy rule. - FieldValues []*string - - // A value indicating whether policy mode is allowed only in built-in definitions. - IsBuiltInOnly *bool - - // The list of namespaces for the data policy manifest. - Namespaces []*string - - // The policy mode of the data policy manifest. - PolicyMode *string - - // The resource functions definition specified in the data manifest. - ResourceFunctions *DataManifestResourceFunctionsDefinition - - // An array of resource type aliases. - ResourceTypeAliases []*ResourceTypeAliases -} - // Definition - The policy definition. type Definition struct { // The policy definition properties. @@ -300,6 +168,9 @@ type DefinitionProperties struct { // The display name of the policy definition. DisplayName *string + // The details of the source of external evaluation results required by the policy during enforcement evaluation. + ExternalEvaluationEnforcementSettings *ExternalEvaluationEnforcementSettings + // The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. Metadata any @@ -383,6 +254,9 @@ type DefinitionVersionProperties struct { // The display name of the policy definition. DisplayName *string + // The details of the source of external evaluation results required by the policy during enforcement evaluation. + ExternalEvaluationEnforcementSettings *ExternalEvaluationEnforcementSettings + // The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. Metadata any @@ -402,76 +276,52 @@ type DefinitionVersionProperties struct { Version *string } -// Exemption - The policy exemption. -type Exemption struct { - // REQUIRED; Properties for the policy exemption. - Properties *ExemptionProperties +// ExternalEvaluationEndpointInvocationResult - The external evaluation endpoint invocation results. +type ExternalEvaluationEndpointInvocationResult struct { + // The set of claims that will be attached to the policy token as an attestation for the result of the endpoint invocation. + Claims any - // READ-ONLY; The ID of the policy exemption. - ID *string + // The expiration of the results. + Expiration *time.Time - // READ-ONLY; The name of the policy exemption. - Name *string - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData + // The status message with additional details about the invocation result. + Message *string - // READ-ONLY; The type of the resource (Microsoft.Authorization/policyExemptions). - Type *string -} + // The details of the policy requiring the external endpoint invocation. + PolicyInfo *LogInfo -// ExemptionListResult - List of policy exemptions. -type ExemptionListResult struct { - // An array of policy exemptions. - Value []*Exemption + // The result of the external endpoint. Possible values are Succeeded and Failed. + Result *ExternalEndpointResult - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string + // The date and time after which a failed endpoint invocation can be retried. + RetryAfter *time.Time } -// ExemptionProperties - The policy exemption properties. -type ExemptionProperties struct { - // REQUIRED; The policy exemption category. Possible values are Waiver and Mitigated. - ExemptionCategory *ExemptionCategory - - // REQUIRED; The ID of the policy assignment that is being exempted. - PolicyAssignmentID *string +// ExternalEvaluationEndpointSettings - The settings of an external endpoint providing evaluation results. +type ExternalEvaluationEndpointSettings struct { + // The details of the endpoint. + Details any - // The option whether validate the exemption is at or under the assignment scope. - AssignmentScopeValidation *AssignmentScopeValidation - - // The description of the policy exemption. - Description *string - - // The display name of the policy exemption. - DisplayName *string - - // The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy exemption. - ExpiresOn *time.Time - - // The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. - Metadata any - - // The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. - PolicyDefinitionReferenceIDs []*string - - // The resource selector list to filter policies by resource properties. - ResourceSelectors []*ResourceSelector + // The kind of the endpoint. + Kind *string } -// ExemptionUpdate - The policy exemption for Patch request. -type ExemptionUpdate struct { - // The policy exemption properties for Patch request. - Properties *ExemptionUpdateProperties -} +// ExternalEvaluationEnforcementSettings - The details of the source of external evaluation results required by the policy +// during enforcement evaluation. +type ExternalEvaluationEnforcementSettings struct { + // The settings of an external endpoint providing evaluation results. + EndpointSettings *ExternalEvaluationEndpointSettings -// ExemptionUpdateProperties - The policy exemption properties for Patch request. -type ExemptionUpdateProperties struct { - // The option whether validate the exemption is at or under the assignment scope. - AssignmentScopeValidation *AssignmentScopeValidation + // What to do when evaluating an enforcement policy that requires an external evaluation and the token is missing. Possible + // values are Audit and Deny and language expressions are supported. + MissingTokenAction *string - // The resource selector list to filter policies by resource properties. - ResourceSelectors []*ResourceSelector + // The lifespan of the endpoint invocation result after which it's no longer valid. Value is expected to follow the ISO 8601 + // duration format and language expressions are supported. + ResultLifespan *string + + // An array of the role definition Ids the assignment's MSI will need in order to invoke the endpoint. + RoleDefinitionIDs []*string } // Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity @@ -492,6 +342,72 @@ type Identity struct { TenantID *string } +// LogInfo - The policy log info. +type LogInfo struct { + // The management group ancestors. + Ancestors *string + + // The policy compliance reason code. + ComplianceReasonCode *string + + // The policy assignment display name. + PolicyAssignmentDisplayName *string + + // The policy assignment Id. + PolicyAssignmentID *string + + // The policy assignment name. + PolicyAssignmentName *string + + // The policy assignment scope. + PolicyAssignmentScope *string + + // The policy assignment version. + PolicyAssignmentVersion *string + + // The policy definition display name. + PolicyDefinitionDisplayName *string + + // The policy definition action. + PolicyDefinitionEffect *string + + // An array of policy definition group names. + PolicyDefinitionGroupNames []*string + + // The policy definition Id. + PolicyDefinitionID *string + + // The policy definition name. + PolicyDefinitionName *string + + // The policy definition instance Id inside a policy set. + PolicyDefinitionReferenceID *string + + // The policy definition version. + PolicyDefinitionVersion *string + + // An array of policy exemption Ids. + PolicyExemptionIDs []*string + + // The policy set definition category. + PolicySetDefinitionCategory *string + + // The policy set definition display name. + PolicySetDefinitionDisplayName *string + + // The policy set definition Id. + PolicySetDefinitionID *string + + // The policy set definition name. + PolicySetDefinitionName *string + + // The policy set definition version. + PolicySetDefinitionVersion *string + + // The resource location. + ResourceLocation *string +} + // NonComplianceMessage - A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' // error messages and on resource's non-compliant compliance results. type NonComplianceMessage struct { @@ -573,15 +489,6 @@ type ResourceSelector struct { Selectors []*Selector } -// ResourceTypeAliases - The resource type aliases definition. -type ResourceTypeAliases struct { - // The aliases for property names. - Aliases []*Alias - - // The resource type name. - ResourceType *string -} - // Selector - The selector expression. type Selector struct { // The list of values to filter in. @@ -726,91 +633,58 @@ type SystemData struct { LastModifiedByType *CreatedByType } -type UserAssignedIdentitiesValue struct { - // READ-ONLY; The client id of user assigned identity. - ClientID *string - - // READ-ONLY; The principal id of user assigned identity. - PrincipalID *string -} - -// Variable - The variable. -type Variable struct { - // REQUIRED; Properties for the variable. - Properties *VariableProperties +// TokenOperation - The resource operation to acquire a token for. +type TokenOperation struct { + // The payload of the resource operation. + Content any - // READ-ONLY; The ID of the variable. - ID *string - - // READ-ONLY; The name of the variable. - Name *string + // The http method of the resource operation. + HTTPMethod *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData - - // READ-ONLY; The type of the resource (Microsoft.Authorization/variables). - Type *string + // The request URI of the resource operation. + URI *string } -// VariableColumn - The variable column. -type VariableColumn struct { - // REQUIRED; The name of this policy variable column. - ColumnName *string -} +// TokenRequest - The policy token request properties. +type TokenRequest struct { + // The change reference. + ChangeReference *string -// VariableListResult - List of variables. -type VariableListResult struct { - // An array of variables. - Value []*Variable - - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string + // The resource operation to acquire a token for. + Operation *TokenOperation } -// VariableProperties - The variable properties. -type VariableProperties struct { - // REQUIRED; Variable column definitions. - Columns []*VariableColumn -} +// TokenResponse - The policy token response properties. +type TokenResponse struct { + // The change reference associated with the operation for which the token is acquired. + ChangeReference *string -// VariableValue - The variable value. -type VariableValue struct { - // REQUIRED; Properties for the variable value. - Properties *VariableValueProperties + // The expiration of the policy token. + Expiration *time.Time - // READ-ONLY; The ID of the variable. - ID *string + // Status message with additional details about the token acquisition operation result. + Message *string - // READ-ONLY; The name of the variable. - Name *string + // The result of the completed token acquisition operation. Possible values are Succeeded and Failed. + Result *PolicyTokenResult - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData + // An array of external evaluation endpoint invocation results. + Results []*ExternalEvaluationEndpointInvocationResult - // READ-ONLY; The type of the resource (Microsoft.Authorization/variables/values). - Type *string -} + // The date and time after which the client can try to acquire a token again in the case of retry-able failures. + RetryAfter *time.Time -// VariableValueColumnValue - The name value tuple for this variable value column. -type VariableValueColumnValue struct { - // REQUIRED; Column name for the variable value - ColumnName *string + // The issued policy token. + Token *string - // REQUIRED; Column value for the variable value; this can be an integer, double, boolean, null or a string. - ColumnValue any + // The unique Id assigned to the policy token. + TokenID *string } -// VariableValueListResult - List of variable values. -type VariableValueListResult struct { - // An array of variable values. - Value []*VariableValue - - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string -} +type UserAssignedIdentitiesValue struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string -// VariableValueProperties - The variable value properties. -type VariableValueProperties struct { - // REQUIRED; Variable value column value array. - Values []*VariableValueColumnValue + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string } diff --git a/sdk/resourcemanager/resources/armpolicy/models_serde.go b/sdk/resourcemanager/resources/armpolicy/models_serde.go index 9dbeeb0619db..32885f0c0eec 100644 --- a/sdk/resourcemanager/resources/armpolicy/models_serde.go +++ b/sdk/resourcemanager/resources/armpolicy/models_serde.go @@ -12,158 +12,6 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type Alias. -func (a Alias) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "defaultMetadata", a.DefaultMetadata) - populate(objectMap, "defaultPath", a.DefaultPath) - populate(objectMap, "defaultPattern", a.DefaultPattern) - populate(objectMap, "name", a.Name) - populate(objectMap, "paths", a.Paths) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Alias. -func (a *Alias) 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 "defaultMetadata": - err = unpopulate(val, "DefaultMetadata", &a.DefaultMetadata) - delete(rawMsg, key) - case "defaultPath": - err = unpopulate(val, "DefaultPath", &a.DefaultPath) - delete(rawMsg, key) - case "defaultPattern": - err = unpopulate(val, "DefaultPattern", &a.DefaultPattern) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) - case "paths": - err = unpopulate(val, "Paths", &a.Paths) - 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 AliasPath. -func (a AliasPath) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "apiVersions", a.APIVersions) - populate(objectMap, "metadata", a.Metadata) - populate(objectMap, "path", a.Path) - populate(objectMap, "pattern", a.Pattern) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPath. -func (a *AliasPath) 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 "apiVersions": - err = unpopulate(val, "APIVersions", &a.APIVersions) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &a.Metadata) - delete(rawMsg, key) - case "path": - err = unpopulate(val, "Path", &a.Path) - delete(rawMsg, key) - case "pattern": - err = unpopulate(val, "Pattern", &a.Pattern) - 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 AliasPathMetadata. -func (a AliasPathMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "attributes", a.Attributes) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPathMetadata. -func (a *AliasPathMetadata) 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 "attributes": - err = unpopulate(val, "Attributes", &a.Attributes) - 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 AliasPattern. -func (a AliasPattern) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "phrase", a.Phrase) - populate(objectMap, "type", a.Type) - populate(objectMap, "variable", a.Variable) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPattern. -func (a *AliasPattern) 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 "phrase": - err = unpopulate(val, "Phrase", &a.Phrase) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - case "variable": - err = unpopulate(val, "Variable", &a.Variable) - 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 Assignment. func (a Assignment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -249,11 +97,13 @@ func (a *AssignmentListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssignmentProperties. func (a AssignmentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "assignmentType", a.AssignmentType) populate(objectMap, "definitionVersion", a.DefinitionVersion) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) populate(objectMap, "effectiveDefinitionVersion", a.EffectiveDefinitionVersion) populate(objectMap, "enforcementMode", a.EnforcementMode) + populate(objectMap, "instanceId", a.InstanceID) populate(objectMap, "latestDefinitionVersion", a.LatestDefinitionVersion) populateAny(objectMap, "metadata", a.Metadata) populate(objectMap, "nonComplianceMessages", a.NonComplianceMessages) @@ -275,6 +125,9 @@ func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "assignmentType": + err = unpopulate(val, "AssignmentType", &a.AssignmentType) + delete(rawMsg, key) case "definitionVersion": err = unpopulate(val, "DefinitionVersion", &a.DefinitionVersion) delete(rawMsg, key) @@ -290,6 +143,9 @@ func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { case "enforcementMode": err = unpopulate(val, "EnforcementMode", &a.EnforcementMode) delete(rawMsg, key) + case "instanceId": + err = unpopulate(val, "InstanceID", &a.InstanceID) + delete(rawMsg, key) case "latestDefinitionVersion": err = unpopulate(val, "LatestDefinitionVersion", &a.LatestDefinitionVersion) delete(rawMsg, key) @@ -381,233 +237,11 @@ func (a *AssignmentUpdateProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Overrides", &a.Overrides) delete(rawMsg, key) case "resourceSelectors": - err = unpopulate(val, "ResourceSelectors", &a.ResourceSelectors) - 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 DataEffect. -func (d DataEffect) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateAny(objectMap, "detailsSchema", d.DetailsSchema) - populate(objectMap, "name", d.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataEffect. -func (d *DataEffect) 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 "detailsSchema": - err = unpopulate(val, "DetailsSchema", &d.DetailsSchema) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - 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 DataManifestCustomResourceFunctionDefinition. -func (d DataManifestCustomResourceFunctionDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "allowCustomProperties", d.AllowCustomProperties) - populate(objectMap, "defaultProperties", d.DefaultProperties) - populate(objectMap, "fullyQualifiedResourceType", d.FullyQualifiedResourceType) - populate(objectMap, "name", d.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestCustomResourceFunctionDefinition. -func (d *DataManifestCustomResourceFunctionDefinition) 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 "allowCustomProperties": - err = unpopulate(val, "AllowCustomProperties", &d.AllowCustomProperties) - delete(rawMsg, key) - case "defaultProperties": - err = unpopulate(val, "DefaultProperties", &d.DefaultProperties) - delete(rawMsg, key) - case "fullyQualifiedResourceType": - err = unpopulate(val, "FullyQualifiedResourceType", &d.FullyQualifiedResourceType) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - 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 DataManifestResourceFunctionsDefinition. -func (d DataManifestResourceFunctionsDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "custom", d.Custom) - populate(objectMap, "standard", d.Standard) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestResourceFunctionsDefinition. -func (d *DataManifestResourceFunctionsDefinition) 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 "custom": - err = unpopulate(val, "Custom", &d.Custom) - delete(rawMsg, key) - case "standard": - err = unpopulate(val, "Standard", &d.Standard) - 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 DataPolicyManifest. -func (d DataPolicyManifest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", d.ID) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifest. -func (d *DataPolicyManifest) 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 "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - 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 DataPolicyManifestListResult. -func (d DataPolicyManifestListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", d.NextLink) - populate(objectMap, "value", d.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifestListResult. -func (d *DataPolicyManifestListResult) 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 "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) - 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 DataPolicyManifestProperties. -func (d DataPolicyManifestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "effects", d.Effects) - populate(objectMap, "fieldValues", d.FieldValues) - populate(objectMap, "isBuiltInOnly", d.IsBuiltInOnly) - populate(objectMap, "namespaces", d.Namespaces) - populate(objectMap, "policyMode", d.PolicyMode) - populate(objectMap, "resourceFunctions", d.ResourceFunctions) - populate(objectMap, "resourceTypeAliases", d.ResourceTypeAliases) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifestProperties. -func (d *DataPolicyManifestProperties) 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 "effects": - err = unpopulate(val, "Effects", &d.Effects) - delete(rawMsg, key) - case "fieldValues": - err = unpopulate(val, "FieldValues", &d.FieldValues) - delete(rawMsg, key) - case "isBuiltInOnly": - err = unpopulate(val, "IsBuiltInOnly", &d.IsBuiltInOnly) - delete(rawMsg, key) - case "namespaces": - err = unpopulate(val, "Namespaces", &d.Namespaces) - delete(rawMsg, key) - case "policyMode": - err = unpopulate(val, "PolicyMode", &d.PolicyMode) - delete(rawMsg, key) - case "resourceFunctions": - err = unpopulate(val, "ResourceFunctions", &d.ResourceFunctions) - delete(rawMsg, key) - case "resourceTypeAliases": - err = unpopulate(val, "ResourceTypeAliases", &d.ResourceTypeAliases) + err = unpopulate(val, "ResourceSelectors", &a.ResourceSelectors) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil @@ -735,6 +369,7 @@ func (d DefinitionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", d.Description) populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "externalEvaluationEnforcementSettings", d.ExternalEvaluationEnforcementSettings) populateAny(objectMap, "metadata", d.Metadata) populate(objectMap, "mode", d.Mode) populate(objectMap, "parameters", d.Parameters) @@ -760,6 +395,9 @@ func (d *DefinitionProperties) UnmarshalJSON(data []byte) error { case "displayName": err = unpopulate(val, "DisplayName", &d.DisplayName) delete(rawMsg, key) + case "externalEvaluationEnforcementSettings": + err = unpopulate(val, "ExternalEvaluationEnforcementSettings", &d.ExternalEvaluationEnforcementSettings) + delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &d.Metadata) delete(rawMsg, key) @@ -919,6 +557,7 @@ func (d DefinitionVersionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", d.Description) populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "externalEvaluationEnforcementSettings", d.ExternalEvaluationEnforcementSettings) populateAny(objectMap, "metadata", d.Metadata) populate(objectMap, "mode", d.Mode) populate(objectMap, "parameters", d.Parameters) @@ -943,6 +582,9 @@ func (d *DefinitionVersionProperties) UnmarshalJSON(data []byte) error { case "displayName": err = unpopulate(val, "DisplayName", &d.DisplayName) delete(rawMsg, key) + case "externalEvaluationEnforcementSettings": + err = unpopulate(val, "ExternalEvaluationEnforcementSettings", &d.ExternalEvaluationEnforcementSettings) + delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &d.Metadata) delete(rawMsg, key) @@ -969,19 +611,20 @@ func (d *DefinitionVersionProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Exemption. -func (e Exemption) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEndpointInvocationResult. +func (e ExternalEvaluationEndpointInvocationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", e.ID) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "systemData", e.SystemData) - populate(objectMap, "type", e.Type) + populateAny(objectMap, "claims", e.Claims) + populateDateTimeRFC3339(objectMap, "expiration", e.Expiration) + populate(objectMap, "message", e.Message) + populate(objectMap, "policyInfo", e.PolicyInfo) + populate(objectMap, "result", e.Result) + populateDateTimeRFC3339(objectMap, "retryAfter", e.RetryAfter) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Exemption. -func (e *Exemption) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEndpointInvocationResult. +func (e *ExternalEvaluationEndpointInvocationResult) 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) @@ -989,20 +632,23 @@ func (e *Exemption) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &e.ID) + case "claims": + err = unpopulate(val, "Claims", &e.Claims) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &e.Name) + case "expiration": + err = unpopulateDateTimeRFC3339(val, "Expiration", &e.Expiration) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) + case "message": + err = unpopulate(val, "Message", &e.Message) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &e.SystemData) + case "policyInfo": + err = unpopulate(val, "PolicyInfo", &e.PolicyInfo) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &e.Type) + case "result": + err = unpopulate(val, "Result", &e.Result) + delete(rawMsg, key) + case "retryAfter": + err = unpopulateDateTimeRFC3339(val, "RetryAfter", &e.RetryAfter) delete(rawMsg, key) } if err != nil { @@ -1012,16 +658,16 @@ func (e *Exemption) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionListResult. -func (e ExemptionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEndpointSettings. +func (e ExternalEvaluationEndpointSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) + populateAny(objectMap, "details", e.Details) + populate(objectMap, "kind", e.Kind) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionListResult. -func (e *ExemptionListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEndpointSettings. +func (e *ExternalEvaluationEndpointSettings) 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) @@ -1029,11 +675,11 @@ func (e *ExemptionListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &e.NextLink) + case "details": + err = unpopulate(val, "Details", &e.Details) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &e.Value) + case "kind": + err = unpopulate(val, "Kind", &e.Kind) delete(rawMsg, key) } if err != nil { @@ -1043,23 +689,18 @@ func (e *ExemptionListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionProperties. -func (e ExemptionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExternalEvaluationEnforcementSettings. +func (e ExternalEvaluationEnforcementSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "assignmentScopeValidation", e.AssignmentScopeValidation) - populate(objectMap, "description", e.Description) - populate(objectMap, "displayName", e.DisplayName) - populate(objectMap, "exemptionCategory", e.ExemptionCategory) - populateDateTimeRFC3339(objectMap, "expiresOn", e.ExpiresOn) - populateAny(objectMap, "metadata", e.Metadata) - populate(objectMap, "policyAssignmentId", e.PolicyAssignmentID) - populate(objectMap, "policyDefinitionReferenceIds", e.PolicyDefinitionReferenceIDs) - populate(objectMap, "resourceSelectors", e.ResourceSelectors) + populate(objectMap, "endpointSettings", e.EndpointSettings) + populate(objectMap, "missingTokenAction", e.MissingTokenAction) + populate(objectMap, "resultLifespan", e.ResultLifespan) + populate(objectMap, "roleDefinitionIds", e.RoleDefinitionIDs) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionProperties. -func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalEvaluationEnforcementSettings. +func (e *ExternalEvaluationEnforcementSettings) 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) @@ -1067,32 +708,17 @@ func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "assignmentScopeValidation": - err = unpopulate(val, "AssignmentScopeValidation", &e.AssignmentScopeValidation) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &e.Description) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &e.DisplayName) - delete(rawMsg, key) - case "exemptionCategory": - err = unpopulate(val, "ExemptionCategory", &e.ExemptionCategory) + case "endpointSettings": + err = unpopulate(val, "EndpointSettings", &e.EndpointSettings) delete(rawMsg, key) - case "expiresOn": - err = unpopulateDateTimeRFC3339(val, "ExpiresOn", &e.ExpiresOn) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &e.Metadata) - delete(rawMsg, key) - case "policyAssignmentId": - err = unpopulate(val, "PolicyAssignmentID", &e.PolicyAssignmentID) + case "missingTokenAction": + err = unpopulate(val, "MissingTokenAction", &e.MissingTokenAction) delete(rawMsg, key) - case "policyDefinitionReferenceIds": - err = unpopulate(val, "PolicyDefinitionReferenceIDs", &e.PolicyDefinitionReferenceIDs) + case "resultLifespan": + err = unpopulate(val, "ResultLifespan", &e.ResultLifespan) delete(rawMsg, key) - case "resourceSelectors": - err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) + case "roleDefinitionIds": + err = unpopulate(val, "RoleDefinitionIDs", &e.RoleDefinitionIDs) delete(rawMsg, key) } if err != nil { @@ -1102,98 +728,147 @@ func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionUpdate. -func (e ExemptionUpdate) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", e.Properties) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdate. -func (e *ExemptionUpdate) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) 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) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &e.Properties) + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) 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 ExemptionUpdateProperties. -func (e ExemptionUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "assignmentScopeValidation", e.AssignmentScopeValidation) - populate(objectMap, "resourceSelectors", e.ResourceSelectors) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdateProperties. -func (e *ExemptionUpdateProperties) 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 "assignmentScopeValidation": - err = unpopulate(val, "AssignmentScopeValidation", &e.AssignmentScopeValidation) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) delete(rawMsg, key) - case "resourceSelectors": - err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Identity. -func (i Identity) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type LogInfo. +func (l LogInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "principalId", i.PrincipalID) - populate(objectMap, "tenantId", i.TenantID) - populate(objectMap, "type", i.Type) - populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + populate(objectMap, "ancestors", l.Ancestors) + populate(objectMap, "complianceReasonCode", l.ComplianceReasonCode) + populate(objectMap, "policyAssignmentDisplayName", l.PolicyAssignmentDisplayName) + populate(objectMap, "policyAssignmentId", l.PolicyAssignmentID) + populate(objectMap, "policyAssignmentName", l.PolicyAssignmentName) + populate(objectMap, "policyAssignmentScope", l.PolicyAssignmentScope) + populate(objectMap, "policyAssignmentVersion", l.PolicyAssignmentVersion) + populate(objectMap, "policyDefinitionDisplayName", l.PolicyDefinitionDisplayName) + populate(objectMap, "policyDefinitionEffect", l.PolicyDefinitionEffect) + populate(objectMap, "policyDefinitionGroupNames", l.PolicyDefinitionGroupNames) + populate(objectMap, "policyDefinitionId", l.PolicyDefinitionID) + populate(objectMap, "policyDefinitionName", l.PolicyDefinitionName) + populate(objectMap, "policyDefinitionReferenceId", l.PolicyDefinitionReferenceID) + populate(objectMap, "policyDefinitionVersion", l.PolicyDefinitionVersion) + populate(objectMap, "policyExemptionIds", l.PolicyExemptionIDs) + populate(objectMap, "policySetDefinitionCategory", l.PolicySetDefinitionCategory) + populate(objectMap, "policySetDefinitionDisplayName", l.PolicySetDefinitionDisplayName) + populate(objectMap, "policySetDefinitionId", l.PolicySetDefinitionID) + populate(objectMap, "policySetDefinitionName", l.PolicySetDefinitionName) + populate(objectMap, "policySetDefinitionVersion", l.PolicySetDefinitionVersion) + populate(objectMap, "resourceLocation", l.ResourceLocation) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. -func (i *Identity) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type LogInfo. +func (l *LogInfo) 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", i, err) + return fmt.Errorf("unmarshalling type %T: %v", l, err) } for key, val := range rawMsg { var err error switch key { - case "principalId": - err = unpopulate(val, "PrincipalID", &i.PrincipalID) + case "ancestors": + err = unpopulate(val, "Ancestors", &l.Ancestors) delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &i.TenantID) + case "complianceReasonCode": + err = unpopulate(val, "ComplianceReasonCode", &l.ComplianceReasonCode) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &i.Type) + case "policyAssignmentDisplayName": + err = unpopulate(val, "PolicyAssignmentDisplayName", &l.PolicyAssignmentDisplayName) delete(rawMsg, key) - case "userAssignedIdentities": - err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) + case "policyAssignmentId": + err = unpopulate(val, "PolicyAssignmentID", &l.PolicyAssignmentID) + delete(rawMsg, key) + case "policyAssignmentName": + err = unpopulate(val, "PolicyAssignmentName", &l.PolicyAssignmentName) + delete(rawMsg, key) + case "policyAssignmentScope": + err = unpopulate(val, "PolicyAssignmentScope", &l.PolicyAssignmentScope) + delete(rawMsg, key) + case "policyAssignmentVersion": + err = unpopulate(val, "PolicyAssignmentVersion", &l.PolicyAssignmentVersion) + delete(rawMsg, key) + case "policyDefinitionDisplayName": + err = unpopulate(val, "PolicyDefinitionDisplayName", &l.PolicyDefinitionDisplayName) + delete(rawMsg, key) + case "policyDefinitionEffect": + err = unpopulate(val, "PolicyDefinitionEffect", &l.PolicyDefinitionEffect) + delete(rawMsg, key) + case "policyDefinitionGroupNames": + err = unpopulate(val, "PolicyDefinitionGroupNames", &l.PolicyDefinitionGroupNames) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &l.PolicyDefinitionID) + delete(rawMsg, key) + case "policyDefinitionName": + err = unpopulate(val, "PolicyDefinitionName", &l.PolicyDefinitionName) + delete(rawMsg, key) + case "policyDefinitionReferenceId": + err = unpopulate(val, "PolicyDefinitionReferenceID", &l.PolicyDefinitionReferenceID) + delete(rawMsg, key) + case "policyDefinitionVersion": + err = unpopulate(val, "PolicyDefinitionVersion", &l.PolicyDefinitionVersion) + delete(rawMsg, key) + case "policyExemptionIds": + err = unpopulate(val, "PolicyExemptionIDs", &l.PolicyExemptionIDs) + delete(rawMsg, key) + case "policySetDefinitionCategory": + err = unpopulate(val, "PolicySetDefinitionCategory", &l.PolicySetDefinitionCategory) + delete(rawMsg, key) + case "policySetDefinitionDisplayName": + err = unpopulate(val, "PolicySetDefinitionDisplayName", &l.PolicySetDefinitionDisplayName) + delete(rawMsg, key) + case "policySetDefinitionId": + err = unpopulate(val, "PolicySetDefinitionID", &l.PolicySetDefinitionID) + delete(rawMsg, key) + case "policySetDefinitionName": + err = unpopulate(val, "PolicySetDefinitionName", &l.PolicySetDefinitionName) + delete(rawMsg, key) + case "policySetDefinitionVersion": + err = unpopulate(val, "PolicySetDefinitionVersion", &l.PolicySetDefinitionVersion) + delete(rawMsg, key) + case "resourceLocation": + err = unpopulate(val, "ResourceLocation", &l.ResourceLocation) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", l, err) } } return nil @@ -1420,37 +1095,6 @@ func (r *ResourceSelector) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceTypeAliases. -func (r ResourceTypeAliases) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "aliases", r.Aliases) - populate(objectMap, "resourceType", r.ResourceType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceTypeAliases. -func (r *ResourceTypeAliases) 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 "aliases": - err = unpopulate(val, "Aliases", &r.Aliases) - delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &r.ResourceType) - 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 Selector. func (s Selector) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1795,292 +1439,153 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue. -func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "clientId", u.ClientID) - populate(objectMap, "principalId", u.PrincipalID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue. -func (u *UserAssignedIdentitiesValue) 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 "clientId": - err = unpopulate(val, "ClientID", &u.ClientID) - delete(rawMsg, key) - case "principalId": - err = unpopulate(val, "PrincipalID", &u.PrincipalID) - 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 Variable. -func (v Variable) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TokenOperation. +func (t TokenOperation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", v.ID) - populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "type", v.Type) + populateAny(objectMap, "content", t.Content) + populate(objectMap, "httpMethod", t.HTTPMethod) + populate(objectMap, "uri", t.URI) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Variable. -func (v *Variable) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenOperation. +func (t *TokenOperation) 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", v, err) + 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", &v.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &v.Name) + case "content": + err = unpopulate(val, "Content", &t.Content) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &v.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &v.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &v.Type) + case "httpMethod": + err = unpopulate(val, "HTTPMethod", &t.HTTPMethod) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableColumn. -func (v VariableColumn) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "columnName", v.ColumnName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableColumn. -func (v *VariableColumn) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "columnName": - err = unpopulate(val, "ColumnName", &v.ColumnName) + case "uri": + err = unpopulate(val, "URI", &t.URI) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableListResult. -func (v VariableListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TokenRequest. +func (t TokenRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", v.NextLink) - populate(objectMap, "value", v.Value) + populate(objectMap, "changeReference", t.ChangeReference) + populate(objectMap, "operation", t.Operation) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableListResult. -func (v *VariableListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenRequest. +func (t *TokenRequest) 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", v, err) + 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", &v.NextLink) + case "changeReference": + err = unpopulate(val, "ChangeReference", &t.ChangeReference) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &v.Value) + case "operation": + err = unpopulate(val, "Operation", &t.Operation) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableProperties. -func (v VariableProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TokenResponse. +func (t TokenResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "columns", v.Columns) + populate(objectMap, "changeReference", t.ChangeReference) + populateDateTimeRFC3339(objectMap, "expiration", t.Expiration) + populate(objectMap, "message", t.Message) + populate(objectMap, "result", t.Result) + populate(objectMap, "results", t.Results) + populateDateTimeRFC3339(objectMap, "retryAfter", t.RetryAfter) + populate(objectMap, "token", t.Token) + populate(objectMap, "tokenId", t.TokenID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableProperties. -func (v *VariableProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenResponse. +func (t *TokenResponse) 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", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { - case "columns": - err = unpopulate(val, "Columns", &v.Columns) + case "changeReference": + err = unpopulate(val, "ChangeReference", &t.ChangeReference) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValue. -func (v VariableValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", v.ID) - populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "type", v.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValue. -func (v *VariableValue) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &v.ID) + case "expiration": + err = unpopulateDateTimeRFC3339(val, "Expiration", &t.Expiration) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &v.Name) + case "message": + err = unpopulate(val, "Message", &t.Message) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &v.Properties) + case "result": + err = unpopulate(val, "Result", &t.Result) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &v.SystemData) + case "results": + err = unpopulate(val, "Results", &t.Results) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &v.Type) + case "retryAfter": + err = unpopulateDateTimeRFC3339(val, "RetryAfter", &t.RetryAfter) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValueColumnValue. -func (v VariableValueColumnValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "columnName", v.ColumnName) - populateAny(objectMap, "columnValue", v.ColumnValue) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueColumnValue. -func (v *VariableValueColumnValue) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "columnName": - err = unpopulate(val, "ColumnName", &v.ColumnName) + case "token": + err = unpopulate(val, "Token", &t.Token) delete(rawMsg, key) - case "columnValue": - err = unpopulate(val, "ColumnValue", &v.ColumnValue) + case "tokenId": + err = unpopulate(val, "TokenID", &t.TokenID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableValueListResult. -func (v VariableValueListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue. +func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", v.NextLink) - populate(objectMap, "value", v.Value) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueListResult. -func (v *VariableValueListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue. +func (u *UserAssignedIdentitiesValue) 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", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &v.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &v.Value) + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValueProperties. -func (v VariableValueProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "values", v.Values) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueProperties. -func (v *VariableValueProperties) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "values": - err = unpopulate(val, "Values", &v.Values) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil diff --git a/sdk/resourcemanager/resources/armpolicy/options.go b/sdk/resourcemanager/resources/armpolicy/options.go index 9b81fe61d4ba..494c2aa45e04 100644 --- a/sdk/resourcemanager/resources/armpolicy/options.go +++ b/sdk/resourcemanager/resources/armpolicy/options.go @@ -27,9 +27,7 @@ type AssignmentsClientDeleteOptions struct { // AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method. type AssignmentsClientGetByIDOptions struct { - // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, - // EffectiveDefinitionVersion'. - Expand *string + // placeholder for future optional parameters } // AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method. @@ -128,20 +126,6 @@ type AssignmentsClientUpdateOptions struct { // placeholder for future optional parameters } -// DataPolicyManifestsClientGetByPolicyModeOptions contains the optional parameters for the DataPolicyManifestsClient.GetByPolicyMode -// method. -type DataPolicyManifestsClientGetByPolicyModeOptions struct { - // placeholder for future optional parameters -} - -// DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.NewListPager method. -type DataPolicyManifestsClientListOptions struct { - // The filter to apply on the operation. Valid values for $filter are: "namespace eq '{value}'". If $filter is not provided, - // no filtering is performed. If $filter=namespace eq '{value}' is provided, the - // returned list only includes all data policy manifests that have a namespace matching the provided value. - Filter *string -} - // DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup // method. type DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { @@ -303,93 +287,6 @@ type DefinitionsClientListOptions struct { Top *int32 } -// ExemptionsClientCreateOrUpdateOptions contains the optional parameters for the ExemptionsClient.CreateOrUpdate method. -type ExemptionsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ExemptionsClientDeleteOptions contains the optional parameters for the ExemptionsClient.Delete method. -type ExemptionsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ExemptionsClientGetOptions contains the optional parameters for the ExemptionsClient.Get method. -type ExemptionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.NewListForManagementGroupPager -// method. -type ExemptionsClientListForManagementGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.NewListForResourceGroupPager -// method. -type ExemptionsClientListForResourceGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientListForResourceOptions contains the optional parameters for the ExemptionsClient.NewListForResourcePager -// method. -type ExemptionsClientListForResourceOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.NewListPager method. -type ExemptionsClientListOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string -} - -// ExemptionsClientUpdateOptions contains the optional parameters for the ExemptionsClient.Update method. -type ExemptionsClientUpdateOptions struct { - // placeholder for future optional parameters -} - // SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup // method. type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { @@ -591,91 +488,8 @@ type SetDefinitionsClientListOptions struct { Top *int32 } -// VariableValuesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdateAtManagementGroup -// method. -type VariableValuesClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientCreateOrUpdateOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdate -// method. -type VariableValuesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.DeleteAtManagementGroup -// method. -type VariableValuesClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientDeleteOptions contains the optional parameters for the VariableValuesClient.Delete method. -type VariableValuesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientGetAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.GetAtManagementGroup -// method. -type VariableValuesClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientGetOptions contains the optional parameters for the VariableValuesClient.Get method. -type VariableValuesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientListForManagementGroupOptions contains the optional parameters for the VariableValuesClient.NewListForManagementGroupPager -// method. -type VariableValuesClientListForManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientListOptions contains the optional parameters for the VariableValuesClient.NewListPager method. -type VariableValuesClientListOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariablesClient.CreateOrUpdateAtManagementGroup -// method. -type VariablesClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientCreateOrUpdateOptions contains the optional parameters for the VariablesClient.CreateOrUpdate method. -type VariablesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariablesClient.DeleteAtManagementGroup -// method. -type VariablesClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientDeleteOptions contains the optional parameters for the VariablesClient.Delete method. -type VariablesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientGetAtManagementGroupOptions contains the optional parameters for the VariablesClient.GetAtManagementGroup -// method. -type VariablesClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientGetOptions contains the optional parameters for the VariablesClient.Get method. -type VariablesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientListForManagementGroupOptions contains the optional parameters for the VariablesClient.NewListForManagementGroupPager -// method. -type VariablesClientListForManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientListOptions contains the optional parameters for the VariablesClient.NewListPager method. -type VariablesClientListOptions struct { - // placeholder for future optional parameters +// TokensClientBeginAcquireOptions contains the optional parameters for the TokensClient.BeginAcquire method. +type TokensClientBeginAcquireOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string } diff --git a/sdk/resourcemanager/resources/armpolicy/responses.go b/sdk/resourcemanager/resources/armpolicy/responses.go index ec47e2fb4c16..ba99ccd6adf2 100644 --- a/sdk/resourcemanager/resources/armpolicy/responses.go +++ b/sdk/resourcemanager/resources/armpolicy/responses.go @@ -77,18 +77,6 @@ type AssignmentsClientUpdateResponse struct { Assignment } -// DataPolicyManifestsClientGetByPolicyModeResponse contains the response from method DataPolicyManifestsClient.GetByPolicyMode. -type DataPolicyManifestsClientGetByPolicyModeResponse struct { - // The data policy manifest. - DataPolicyManifest -} - -// DataPolicyManifestsClientListResponse contains the response from method DataPolicyManifestsClient.NewListPager. -type DataPolicyManifestsClientListResponse struct { - // List of data policy manifests. - DataPolicyManifestListResult -} - // DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionVersionsClient.CreateOrUpdateAtManagementGroup. type DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct { // The ID of the policy definition version. @@ -223,53 +211,6 @@ type DefinitionsClientListResponse struct { DefinitionListResult } -// ExemptionsClientCreateOrUpdateResponse contains the response from method ExemptionsClient.CreateOrUpdate. -type ExemptionsClientCreateOrUpdateResponse struct { - // The policy exemption. - Exemption -} - -// ExemptionsClientDeleteResponse contains the response from method ExemptionsClient.Delete. -type ExemptionsClientDeleteResponse struct { - // placeholder for future response values -} - -// ExemptionsClientGetResponse contains the response from method ExemptionsClient.Get. -type ExemptionsClientGetResponse struct { - // The policy exemption. - Exemption -} - -// ExemptionsClientListForManagementGroupResponse contains the response from method ExemptionsClient.NewListForManagementGroupPager. -type ExemptionsClientListForManagementGroupResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientListForResourceGroupResponse contains the response from method ExemptionsClient.NewListForResourceGroupPager. -type ExemptionsClientListForResourceGroupResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientListForResourceResponse contains the response from method ExemptionsClient.NewListForResourcePager. -type ExemptionsClientListForResourceResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientListResponse contains the response from method ExemptionsClient.NewListPager. -type ExemptionsClientListResponse struct { - // List of policy exemptions. - ExemptionListResult -} - -// ExemptionsClientUpdateResponse contains the response from method ExemptionsClient.Update. -type ExemptionsClientUpdateResponse struct { - // The policy exemption. - Exemption -} - // SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup. type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct { // The policy set definition version. @@ -404,94 +345,8 @@ type SetDefinitionsClientListResponse struct { SetDefinitionListResult } -// VariableValuesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariableValuesClient.CreateOrUpdateAtManagementGroup. -type VariableValuesClientCreateOrUpdateAtManagementGroupResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientCreateOrUpdateResponse contains the response from method VariableValuesClient.CreateOrUpdate. -type VariableValuesClientCreateOrUpdateResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientDeleteAtManagementGroupResponse contains the response from method VariableValuesClient.DeleteAtManagementGroup. -type VariableValuesClientDeleteAtManagementGroupResponse struct { - // placeholder for future response values -} - -// VariableValuesClientDeleteResponse contains the response from method VariableValuesClient.Delete. -type VariableValuesClientDeleteResponse struct { - // placeholder for future response values -} - -// VariableValuesClientGetAtManagementGroupResponse contains the response from method VariableValuesClient.GetAtManagementGroup. -type VariableValuesClientGetAtManagementGroupResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientGetResponse contains the response from method VariableValuesClient.Get. -type VariableValuesClientGetResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientListForManagementGroupResponse contains the response from method VariableValuesClient.NewListForManagementGroupPager. -type VariableValuesClientListForManagementGroupResponse struct { - // List of variable values. - VariableValueListResult -} - -// VariableValuesClientListResponse contains the response from method VariableValuesClient.NewListPager. -type VariableValuesClientListResponse struct { - // List of variable values. - VariableValueListResult -} - -// VariablesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariablesClient.CreateOrUpdateAtManagementGroup. -type VariablesClientCreateOrUpdateAtManagementGroupResponse struct { - // The variable. - Variable -} - -// VariablesClientCreateOrUpdateResponse contains the response from method VariablesClient.CreateOrUpdate. -type VariablesClientCreateOrUpdateResponse struct { - // The variable. - Variable -} - -// VariablesClientDeleteAtManagementGroupResponse contains the response from method VariablesClient.DeleteAtManagementGroup. -type VariablesClientDeleteAtManagementGroupResponse struct { - // placeholder for future response values -} - -// VariablesClientDeleteResponse contains the response from method VariablesClient.Delete. -type VariablesClientDeleteResponse struct { - // placeholder for future response values -} - -// VariablesClientGetAtManagementGroupResponse contains the response from method VariablesClient.GetAtManagementGroup. -type VariablesClientGetAtManagementGroupResponse struct { - // The variable. - Variable -} - -// VariablesClientGetResponse contains the response from method VariablesClient.Get. -type VariablesClientGetResponse struct { - // The variable. - Variable -} - -// VariablesClientListForManagementGroupResponse contains the response from method VariablesClient.NewListForManagementGroupPager. -type VariablesClientListForManagementGroupResponse struct { - // List of variables. - VariableListResult -} - -// VariablesClientListResponse contains the response from method VariablesClient.NewListPager. -type VariablesClientListResponse struct { - // List of variables. - VariableListResult +// TokensClientAcquireResponse contains the response from method TokensClient.BeginAcquire. +type TokensClientAcquireResponse struct { + // The policy token response properties. + TokenResponse } diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go index 93b87e2da6d0..916d7a5ebf6d 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go @@ -44,7 +44,7 @@ func NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCrede // CreateOrUpdate - This operation creates or updates a policy set definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition to create. // - parameters - The policy set definition properties. // - options - SetDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdate @@ -87,7 +87,7 @@ func (client *SetDefinitionsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -109,7 +109,7 @@ func (client *SetDefinitionsClient) createOrUpdateHandleResponse(resp *http.Resp // with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - policySetDefinitionName - The name of the policy set definition to create. // - parameters - The policy set definition properties. @@ -153,7 +153,7 @@ func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -174,7 +174,7 @@ func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupHandleRespons // Delete - This operation deletes the policy set definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition to delete. // - options - SetDefinitionsClientDeleteOptions contains the optional parameters for the SetDefinitionsClient.Delete method. func (client *SetDefinitionsClient) Delete(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientDeleteOptions) (SetDefinitionsClientDeleteResponse, error) { @@ -214,7 +214,7 @@ func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, pol return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -224,7 +224,7 @@ func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, pol // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - policySetDefinitionName - The name of the policy set definition to delete. // - options - SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup @@ -266,7 +266,7 @@ func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -275,7 +275,7 @@ func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx con // Get - This operation retrieves the policy set definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetOptions contains the optional parameters for the SetDefinitionsClient.Get method. func (client *SetDefinitionsClient) Get(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientGetOptions) (SetDefinitionsClientGetResponse, error) { @@ -319,7 +319,7 @@ func (client *SetDefinitionsClient) getCreateRequest(ctx context.Context, policy if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,7 +338,7 @@ func (client *SetDefinitionsClient) getHandleResponse(resp *http.Response) (SetD // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup @@ -384,7 +384,7 @@ func (client *SetDefinitionsClient) getAtManagementGroupCreateRequest(ctx contex if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -402,7 +402,7 @@ func (client *SetDefinitionsClient) getAtManagementGroupHandleResponse(resp *htt // GetBuiltIn - This operation retrieves the built-in policy set definition with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn // method. @@ -443,7 +443,7 @@ func (client *SetDefinitionsClient) getBuiltInCreateRequest(ctx context.Context, if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -469,7 +469,7 @@ func (client *SetDefinitionsClient) getBuiltInHandleResponse(resp *http.Response // If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category // match the {value}. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method. func (client *SetDefinitionsClient) NewListPager(options *SetDefinitionsClientListOptions) *runtime.Pager[SetDefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SetDefinitionsClientListResponse]{ @@ -512,7 +512,7 @@ func (client *SetDefinitionsClient) listCreateRequest(ctx context.Context, optio if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -536,7 +536,7 @@ func (client *SetDefinitionsClient) listHandleResponse(resp *http.Response) (Set // given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all // built-in policy set definitions whose category match the {value}. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager // method. func (client *SetDefinitionsClient) NewListBuiltInPager(options *SetDefinitionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionsClientListBuiltInResponse] { @@ -576,7 +576,7 @@ func (client *SetDefinitionsClient) listBuiltInCreateRequest(ctx context.Context if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -607,7 +607,7 @@ func (client *SetDefinitionsClient) listBuiltInHandleResponse(resp *http.Respons // If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category // match the {value}. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupID - The ID of the management group. // - options - SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager // method. @@ -652,7 +652,7 @@ func (client *SetDefinitionsClient) listByManagementGroupCreateRequest(ctx conte if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go deleted file mode 100644 index 3db2ad62ff4e..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go +++ /dev/null @@ -1,1125 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinition.json -func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefinition() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "namePrefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - DefaultValue: "myPrefix", - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - DisplayName: to.Ptr("Prefix to enforce on resource names"), - }, - }, - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "[parameters('namePrefix')]", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "namePrefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // DefaultValue: "myPrefix", - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Prefix to enforce on resource names"), - // }, - // }, - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "[parameters('namePrefix')]", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json -func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefinitionWithGroups() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - { - Name: to.Ptr("CostSaving"), - Description: to.Ptr("Policies designed to control spend within a subscription."), - DisplayName: to.Ptr("Cost Management Policies"), - }, - { - Name: to.Ptr("Organizational"), - Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - DisplayName: to.Ptr("Organizational Policies"), - }}, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - DefinitionVersion: to.Ptr("1.*.*"), - GroupNames: []*string{ - to.Ptr("CostSaving")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - DefinitionVersion: to.Ptr("1.*.*"), - GroupNames: []*string{ - to.Ptr("Organizational")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("CostSaving")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinition.json -func ExampleSetDefinitionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionsClient().Delete(ctx, "CostManagement", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinition.json -func ExampleSetDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().Get(ctx, "CostManagement", &armpolicy.SetDefinitionsClientGetOptions{Expand: 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("CostSaving")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltInPolicySetDefinition.json -func ExampleSetDefinitionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().GetBuiltIn(ctx, "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", &armpolicy.SetDefinitionsClientGetBuiltInOptions{Expand: 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitions.json -func ExampleSetDefinitionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListPager(&armpolicy.SetDefinitionsClientListOptions{Filter: nil, - Expand: nil, - Top: 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.SetDefinitionListResult = armpolicy.SetDefinitionListResult{ - // Value: []*armpolicy.SetDefinition{ - // { - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }, - // { - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicySetDefinitions.json -func ExampleSetDefinitionsClient_NewListBuiltInPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListBuiltInPager(&armpolicy.SetDefinitionsClientListBuiltInOptions{Filter: nil, - Expand: nil, - Top: 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.SetDefinitionListResult = armpolicy.SetDefinitionListResult{ - // Value: []*armpolicy.SetDefinition{ - // { - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json -func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - { - Name: to.Ptr("CostSaving"), - Description: to.Ptr("Policies designed to control spend within a subscription."), - DisplayName: to.Ptr("Cost Management Policies"), - }, - { - Name: to.Ptr("Organizational"), - Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - DisplayName: to.Ptr("Organizational Policies"), - }}, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - GroupNames: []*string{ - to.Ptr("CostSaving")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - GroupNames: []*string{ - to.Ptr("Organizational")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("CostSaving")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", &armpolicy.SetDefinitionsClientGetAtManagementGroupOptions{Expand: 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitionsByManagementGroup.json -func ExampleSetDefinitionsClient_NewListByManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", &armpolicy.SetDefinitionsClientListByManagementGroupOptions{Filter: nil, - Expand: nil, - Top: 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.SetDefinitionListResult = armpolicy.SetDefinitionListResult{ - // Value: []*armpolicy.SetDefinition{ - // { - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }, - // { - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // Versions: []*string{ - // to.Ptr("1.2.1"), - // to.Ptr("1.0.0")}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go index 9d44a9dac965..7f5ee0e4d992 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go @@ -45,7 +45,7 @@ func NewSetDefinitionVersionsClient(subscriptionID string, credential azcore.Tok // name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition. // - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y // is the minor version number, and z is the patch number @@ -94,7 +94,7 @@ func (client *SetDefinitionVersionsClient) createOrUpdateCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -116,7 +116,7 @@ func (client *SetDefinitionVersionsClient) createOrUpdateHandleResponse(resp *ht // group with the given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policySetDefinitionName - The name of the policy set definition. // - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y @@ -166,7 +166,7 @@ func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupCreate return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -187,7 +187,7 @@ func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupHandle // Delete - This operation deletes the policy set definition version in the given subscription with the given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition. // - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y // is the minor version number, and z is the patch number @@ -234,7 +234,7 @@ func (client *SetDefinitionVersionsClient) deleteCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -244,7 +244,7 @@ func (client *SetDefinitionVersionsClient) deleteCreateRequest(ctx context.Conte // given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policySetDefinitionName - The name of the policy set definition. // - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y @@ -292,7 +292,7 @@ func (client *SetDefinitionVersionsClient) deleteAtManagementGroupCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -301,7 +301,7 @@ func (client *SetDefinitionVersionsClient) deleteAtManagementGroupCreateRequest( // Get - This operation retrieves the policy set definition version in the given subscription with the given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition. // - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y // is the minor version number, and z is the patch number @@ -352,7 +352,7 @@ func (client *SetDefinitionVersionsClient) getCreateRequest(ctx context.Context, if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,7 +371,7 @@ func (client *SetDefinitionVersionsClient) getHandleResponse(resp *http.Response // given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policySetDefinitionName - The name of the policy set definition. // - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y @@ -423,7 +423,7 @@ func (client *SetDefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -441,7 +441,7 @@ func (client *SetDefinitionVersionsClient) getAtManagementGroupHandleResponse(re // GetBuiltIn - This operation retrieves the built-in policy set definition version with the given name and version. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition. // - policyDefinitionVersion - The policy set definition version. The format is x.y.z where x is the major version number, y // is the minor version number, and z is the patch number @@ -488,7 +488,7 @@ func (client *SetDefinitionVersionsClient) getBuiltInCreateRequest(ctx context.C if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -505,7 +505,7 @@ func (client *SetDefinitionVersionsClient) getBuiltInHandleResponse(resp *http.R // NewListPager - This operation retrieves a list of all the policy set definition versions for the given policy set definition. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition. // - options - SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager // method. @@ -554,7 +554,7 @@ func (client *SetDefinitionVersionsClient) listCreateRequest(ctx context.Context if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -572,7 +572,7 @@ func (client *SetDefinitionVersionsClient) listHandleResponse(resp *http.Respons // ListAll - This operation lists all the policy set definition versions for all policy set definitions within a subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll // method. func (client *SetDefinitionVersionsClient) ListAll(ctx context.Context, options *SetDefinitionVersionsClientListAllOptions) (SetDefinitionVersionsClientListAllResponse, error) { @@ -609,7 +609,7 @@ func (client *SetDefinitionVersionsClient) listAllCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -628,7 +628,7 @@ func (client *SetDefinitionVersionsClient) listAllHandleResponse(resp *http.Resp // the management group scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - options - SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup // method. @@ -666,7 +666,7 @@ func (client *SetDefinitionVersionsClient) listAllAtManagementGroupCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -684,7 +684,7 @@ func (client *SetDefinitionVersionsClient) listAllAtManagementGroupHandleRespons // ListAllBuiltins - This operation lists all the built-in policy set definition versions for all built-in policy set definitions. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - options - SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins // method. func (client *SetDefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *SetDefinitionVersionsClientListAllBuiltinsOptions) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) { @@ -717,7 +717,7 @@ func (client *SetDefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -735,7 +735,7 @@ func (client *SetDefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *h // NewListBuiltInPager - This operation retrieves a list of all the built-in policy set definition versions for the given // built-in policy set definition. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - policySetDefinitionName - The name of the policy set definition. // - options - SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager // method. @@ -780,7 +780,7 @@ func (client *SetDefinitionVersionsClient) listBuiltInCreateRequest(ctx context. if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -798,7 +798,7 @@ func (client *SetDefinitionVersionsClient) listBuiltInHandleResponse(resp *http. // NewListByManagementGroupPager - This operation retrieves a list of all the policy set definition versions for the given // policy set definition in a given management group. // -// Generated from API version 2023-04-01 +// Generated from API version 2025-03-01 // - managementGroupName - The name of the management group. The name is case insensitive. // - policySetDefinitionName - The name of the policy set definition. // - options - SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager @@ -848,7 +848,7 @@ func (client *SetDefinitionVersionsClient) listByManagementGroupCreateRequest(ct if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2023-04-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client_example_test.go deleted file mode 100644 index dd5b96c9cf39..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client_example_test.go +++ /dev/null @@ -1,1000 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllBuiltInPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_ListAllBuiltins() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().ListAllBuiltins(ctx, 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.SetDefinitionVersionListResult = armpolicy.SetDefinitionVersionListResult{ - // Value: []*armpolicy.SetDefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json -func ExampleSetDefinitionVersionsClient_ListAllAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().ListAllAtManagementGroup(ctx, "MyManagementGroup", 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.SetDefinitionVersionListResult = armpolicy.SetDefinitionVersionListResult{ - // Value: []*armpolicy.SetDefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versoins/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // }, - // }, - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listAllPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_ListAll() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().ListAll(ctx, 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.SetDefinitionVersionListResult = armpolicy.SetDefinitionVersionListResult{ - // Value: []*armpolicy.SetDefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionVersion.json -func ExampleSetDefinitionVersionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().CreateOrUpdate(ctx, "CostManagement", "1.2.1", armpolicy.SetDefinitionVersion{ - Properties: &armpolicy.SetDefinitionVersionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "namePrefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - DefaultValue: "myPrefix", - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - DisplayName: to.Ptr("Prefix to enforce on resource names"), - }, - }, - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "[parameters('namePrefix')]", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - Version: to.Ptr("1.2.1"), - }, - }, 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.SetDefinitionVersion = armpolicy.SetDefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "namePrefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // DefaultValue: "myPrefix", - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Prefix to enforce on resource names"), - // }, - // }, - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "[parameters('namePrefix')]", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinitionVersion.json -func ExampleSetDefinitionVersionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionVersionsClient().Delete(ctx, "CostManagement", "1.2.1", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinitionVersion.json -func ExampleSetDefinitionVersionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().Get(ctx, "CostManagement", "1.2.1", &armpolicy.SetDefinitionVersionsClientGetOptions{Expand: 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.SetDefinitionVersion = armpolicy.SetDefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("CostSaving")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getBuiltInPolicySetDefinitionVersion.json -func ExampleSetDefinitionVersionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().GetBuiltIn(ctx, "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", "1.2.1", &armpolicy.SetDefinitionVersionsClientGetBuiltInOptions{Expand: 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.SetDefinitionVersion = armpolicy.SetDefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionVersionsClient().NewListPager("CostManagement", &armpolicy.SetDefinitionVersionsClientListOptions{Expand: nil, - Top: 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.SetDefinitionVersionListResult = armpolicy.SetDefinitionVersionListResult{ - // Value: []*armpolicy.SetDefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listBuiltInPolicySetDefinitionVersions.json -func ExampleSetDefinitionVersionsClient_NewListBuiltInPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionVersionsClient().NewListBuiltInPager("1f3afdf9-d0c9-4c3d-847f-89da613e70a8", &armpolicy.SetDefinitionVersionsClientListBuiltInOptions{Expand: nil, - Top: 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.SetDefinitionVersionListResult = armpolicy.SetDefinitionVersionListResult{ - // Value: []*armpolicy.SetDefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json -func ExampleSetDefinitionVersionsClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().CreateOrUpdateAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", armpolicy.SetDefinitionVersion{ - Properties: &armpolicy.SetDefinitionVersionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - Version: to.Ptr("1.2.1"), - }, - }, 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.SetDefinitionVersion = armpolicy.SetDefinitionVersion{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json -func ExampleSetDefinitionVersionsClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionVersionsClient().DeleteAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json -func ExampleSetDefinitionVersionsClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionVersionsClient().GetAtManagementGroup(ctx, "MyManagementGroup", "CostManagement", "1.2.1", &armpolicy.SetDefinitionVersionsClientGetAtManagementGroupOptions{Expand: 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.SetDefinitionVersion = armpolicy.SetDefinitionVersion{ - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json -func ExampleSetDefinitionVersionsClient_NewListByManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionVersionsClient().NewListByManagementGroupPager("MyManagementGroup", "CostManagement", &armpolicy.SetDefinitionVersionsClientListByManagementGroupOptions{Expand: nil, - Top: 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.SetDefinitionVersionListResult = armpolicy.SetDefinitionVersionListResult{ - // Value: []*armpolicy.SetDefinitionVersion{ - // { - // Name: to.Ptr("1.2.1"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions/versions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement/versions/1.2.1"), - // Properties: &armpolicy.SetDefinitionVersionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // DefinitionVersion: to.Ptr("1.*.*"), - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // Version: to.Ptr("1.2.1"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/tokens_client.go b/sdk/resourcemanager/resources/armpolicy/tokens_client.go new file mode 100644 index 000000000000..d930255ef760 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/tokens_client.go @@ -0,0 +1,111 @@ +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpolicy + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// TokensClient contains the methods for the PolicyTokens group. +// Don't use this type directly, use NewTokensClient() instead. +type TokensClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTokensClient creates a new instance of TokensClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewTokensClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TokensClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TokensClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginAcquire - This operation acquires a policy token in the given subscription for the given request body. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01 +// - parameters - The policy token properties. +// - options - TokensClientBeginAcquireOptions contains the optional parameters for the TokensClient.BeginAcquire method. +func (client *TokensClient) BeginAcquire(ctx context.Context, parameters TokenRequest, options *TokensClientBeginAcquireOptions) (*runtime.Poller[TokensClientAcquireResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.acquire(ctx, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TokensClientAcquireResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TokensClientAcquireResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Acquire - This operation acquires a policy token in the given subscription for the given request body. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01 +func (client *TokensClient) acquire(ctx context.Context, parameters TokenRequest, options *TokensClientBeginAcquireOptions) (*http.Response, error) { + var err error + const operationName = "TokensClient.BeginAcquire" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.acquireCreateRequest(ctx, parameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// acquireCreateRequest creates the Acquire request. +func (client *TokensClient) acquireCreateRequest(ctx context.Context, parameters TokenRequest, _ *TokensClientBeginAcquireOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/acquirePolicyToken" + if client.subscriptionID == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/variables_client.go b/sdk/resourcemanager/resources/armpolicy/variables_client.go deleted file mode 100644 index 30ac3a1dd3af..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variables_client.go +++ /dev/null @@ -1,507 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// VariablesClient contains the methods for the Variables group. -// Don't use this type directly, use NewVariablesClient() instead. -type VariablesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewVariablesClient creates a new instance of VariablesClient with the specified values. -// - subscriptionID - The ID of the target subscription. The value must be an UUID. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewVariablesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VariablesClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &VariablesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a variable with the given subscription and name. Policy variables can -// only be used by a policy definition at the scope they are created or below. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - parameters - Parameters for the variable. -// - options - VariablesClientCreateOrUpdateOptions contains the optional parameters for the VariablesClient.CreateOrUpdate -// method. -func (client *VariablesClient) CreateOrUpdate(ctx context.Context, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateOptions) (VariablesClientCreateOrUpdateResponse, error) { - var err error - const operationName = "VariablesClient.CreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, variableName, parameters, options) - if err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariablesClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VariablesClient) createOrUpdateCreateRequest(ctx context.Context, variableName string, parameters Variable, _ *VariablesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *VariablesClient) createOrUpdateHandleResponse(resp *http.Response) (VariablesClientCreateOrUpdateResponse, error) { - result := VariablesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// CreateOrUpdateAtManagementGroup - This operation creates or updates a variable with the given management group and name. -// Policy variables can only be used by a policy definition at the scope they are created or below. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - parameters - Parameters for the variable. -// - options - VariablesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariablesClient.CreateOrUpdateAtManagementGroup -// method. -func (client *VariablesClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateAtManagementGroupOptions) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.CreateOrUpdateAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, parameters, options) - if err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *VariablesClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, parameters Variable, _ *VariablesClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. -func (client *VariablesClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error) { - result := VariablesClientCreateOrUpdateAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a variable, given its name and the subscription it was created in. The scope of a variable -// is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariablesClientDeleteOptions contains the optional parameters for the VariablesClient.Delete method. -func (client *VariablesClient) Delete(ctx context.Context, variableName string, options *VariablesClientDeleteOptions) (VariablesClientDeleteResponse, error) { - var err error - const operationName = "VariablesClient.Delete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, variableName, options) - if err != nil { - return VariablesClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariablesClientDeleteResponse{}, err - } - return VariablesClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *VariablesClient) deleteCreateRequest(ctx context.Context, variableName string, _ *VariablesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// DeleteAtManagementGroup - This operation deletes a variable, given its name and the management group it was created in. -// The scope of a variable is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariablesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariablesClient.DeleteAtManagementGroup -// method. -func (client *VariablesClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientDeleteAtManagementGroupOptions) (VariablesClientDeleteAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.DeleteAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) - if err != nil { - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - return VariablesClientDeleteAtManagementGroupResponse{}, nil -} - -// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *VariablesClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, _ *VariablesClientDeleteAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single variable, given its name and the subscription it was created at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariablesClientGetOptions contains the optional parameters for the VariablesClient.Get method. -func (client *VariablesClient) Get(ctx context.Context, variableName string, options *VariablesClientGetOptions) (VariablesClientGetResponse, error) { - var err error - const operationName = "VariablesClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, variableName, options) - if err != nil { - return VariablesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariablesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *VariablesClient) getCreateRequest(ctx context.Context, variableName string, _ *VariablesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *VariablesClient) getHandleResponse(resp *http.Response) (VariablesClientGetResponse, error) { - result := VariablesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientGetResponse{}, err - } - return result, nil -} - -// GetAtManagementGroup - This operation retrieves a single variable, given its name and the management group it was created -// at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariablesClientGetAtManagementGroupOptions contains the optional parameters for the VariablesClient.GetAtManagementGroup -// method. -func (client *VariablesClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientGetAtManagementGroupOptions) (VariablesClientGetAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.GetAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) - if err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariablesClientGetAtManagementGroupResponse{}, err - } - resp, err := client.getAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *VariablesClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, _ *VariablesClientGetAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. -func (client *VariablesClient) getAtManagementGroupHandleResponse(resp *http.Response) (VariablesClientGetAtManagementGroupResponse, error) { - result := VariablesClientGetAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all variables associated with the given subscription. -// -// Generated from API version 2022-08-01-preview -// - options - VariablesClientListOptions contains the optional parameters for the VariablesClient.NewListPager method. -func (client *VariablesClient) NewListPager(options *VariablesClientListOptions) *runtime.Pager[VariablesClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[VariablesClientListResponse]{ - More: func(page VariablesClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariablesClientListResponse) (VariablesClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariablesClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return VariablesClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *VariablesClient) listCreateRequest(ctx context.Context, _ *VariablesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables" - if client.subscriptionID == "" { - 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.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *VariablesClient) listHandleResponse(resp *http.Response) (VariablesClientListResponse, error) { - result := VariablesClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableListResult); err != nil { - return VariablesClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all variables applicable to the management group. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - options - VariablesClientListForManagementGroupOptions contains the optional parameters for the VariablesClient.NewListForManagementGroupPager -// method. -func (client *VariablesClient) NewListForManagementGroupPager(managementGroupID string, options *VariablesClientListForManagementGroupOptions) *runtime.Pager[VariablesClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VariablesClientListForManagementGroupResponse]{ - More: func(page VariablesClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariablesClientListForManagementGroupResponse) (VariablesClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariablesClient.NewListForManagementGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, options) - }, nil) - if err != nil { - return VariablesClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *VariablesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, _ *VariablesClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *VariablesClient) listForManagementGroupHandleResponse(resp *http.Response) (VariablesClientListForManagementGroupResponse, error) { - result := VariablesClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableListResult); err != nil { - return VariablesClientListForManagementGroupResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go deleted file mode 100644 index 816584e2d9eb..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go +++ /dev/null @@ -1,355 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariable.json -func ExampleVariablesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariablesClient().Delete(ctx, "DemoTestVariable", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariable.json -func ExampleVariablesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().CreateOrUpdate(ctx, "DemoTestVariable", armpolicy.Variable{ - Properties: &armpolicy.VariableProperties{ - Columns: []*armpolicy.VariableColumn{ - { - ColumnName: to.Ptr("TestColumn"), - }}, - }, - }, 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariable.json -func ExampleVariablesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().Get(ctx, "DemoTestVariable", 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableAtManagementGroup.json -func ExampleVariablesClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariablesClient().DeleteAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableAtManagementGroup.json -func ExampleVariablesClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().CreateOrUpdateAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", armpolicy.Variable{ - Properties: &armpolicy.VariableProperties{ - Columns: []*armpolicy.VariableColumn{ - { - ColumnName: to.Ptr("TestColumn"), - }}, - }, - }, 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableAtManagementGroup.json -func ExampleVariablesClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().GetAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariablesForSubscription.json -func ExampleVariablesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariablesClient().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.VariableListResult = armpolicy.VariableListResult{ - // Value: []*armpolicy.Variable{ - // { - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NetworkingVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/NetworkingVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("NetworkResourceName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariablesForManagementGroup.json -func ExampleVariablesClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariablesClient().NewListForManagementGroupPager("DevOrg", 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.VariableListResult = armpolicy.VariableListResult{ - // Value: []*armpolicy.Variable{ - // { - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NetworkingVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/NetworkingVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("NetworkResourceName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go b/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go deleted file mode 100644 index 9fd3cf0f9a50..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go +++ /dev/null @@ -1,550 +0,0 @@ -// 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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpolicy - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// VariableValuesClient contains the methods for the VariableValues group. -// Don't use this type directly, use NewVariableValuesClient() instead. -type VariableValuesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewVariableValuesClient creates a new instance of VariableValuesClient with the specified values. -// - subscriptionID - The ID of the target subscription. The value must be an UUID. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewVariableValuesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VariableValuesClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &VariableValuesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a variable value with the given subscription and name for a given variable. -// Variable values are scoped to the variable for which they are created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - parameters - Parameters for the variable value. -// - options - VariableValuesClientCreateOrUpdateOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdate -// method. -func (client *VariableValuesClient) CreateOrUpdate(ctx context.Context, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateOptions) (VariableValuesClientCreateOrUpdateResponse, error) { - var err error - const operationName = "VariableValuesClient.CreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, variableName, variableValueName, parameters, options) - if err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VariableValuesClient) createOrUpdateCreateRequest(ctx context.Context, variableName string, variableValueName string, parameters VariableValue, _ *VariableValuesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *VariableValuesClient) createOrUpdateHandleResponse(resp *http.Response) (VariableValuesClientCreateOrUpdateResponse, error) { - result := VariableValuesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// CreateOrUpdateAtManagementGroup - This operation creates or updates a variable value with the given management group and -// name for a given variable. Variable values are scoped to the variable for which they are created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - parameters - Parameters for the variable value. -// - options - VariableValuesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdateAtManagementGroup -// method. -func (client *VariableValuesClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.CreateOrUpdateAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, parameters, options) - if err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *VariableValuesClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters VariableValue, _ *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. -func (client *VariableValuesClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error) { - result := VariableValuesClientCreateOrUpdateAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a variable value, given its name, the subscription it was created in, and the variable -// it belongs to. The scope of a variable value is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientDeleteOptions contains the optional parameters for the VariableValuesClient.Delete method. -func (client *VariableValuesClient) Delete(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientDeleteOptions) (VariableValuesClientDeleteResponse, error) { - var err error - const operationName = "VariableValuesClient.Delete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientDeleteResponse{}, err - } - return VariableValuesClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *VariableValuesClient) deleteCreateRequest(ctx context.Context, variableName string, variableValueName string, _ *VariableValuesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// DeleteAtManagementGroup - This operation deletes a variable value, given its name, the management group it was created -// in, and the variable it belongs to. The scope of a variable value is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.DeleteAtManagementGroup -// method. -func (client *VariableValuesClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientDeleteAtManagementGroupOptions) (VariableValuesClientDeleteAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.DeleteAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - return VariableValuesClientDeleteAtManagementGroupResponse{}, nil -} - -// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *VariableValuesClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, _ *VariableValuesClientDeleteAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single variable value; given its name, subscription it was created at and the variable -// it's created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientGetOptions contains the optional parameters for the VariableValuesClient.Get method. -func (client *VariableValuesClient) Get(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientGetOptions) (VariableValuesClientGetResponse, error) { - var err error - const operationName = "VariableValuesClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *VariableValuesClient) getCreateRequest(ctx context.Context, variableName string, variableValueName string, _ *VariableValuesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *VariableValuesClient) getHandleResponse(resp *http.Response) (VariableValuesClientGetResponse, error) { - result := VariableValuesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientGetResponse{}, err - } - return result, nil -} - -// GetAtManagementGroup - This operation retrieves a single variable value; given its name, management group it was created -// at and the variable it's created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientGetAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.GetAtManagementGroup -// method. -func (client *VariableValuesClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientGetAtManagementGroupOptions) (VariableValuesClientGetAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.GetAtManagementGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - resp, err := client.getAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *VariableValuesClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, _ *VariableValuesClientGetAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. -func (client *VariableValuesClient) getAtManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientGetAtManagementGroupResponse, error) { - result := VariableValuesClientGetAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all variable values associated with the given variable that is at a -// subscription level. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariableValuesClientListOptions contains the optional parameters for the VariableValuesClient.NewListPager method. -func (client *VariableValuesClient) NewListPager(variableName string, options *VariableValuesClientListOptions) *runtime.Pager[VariableValuesClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[VariableValuesClientListResponse]{ - More: func(page VariableValuesClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariableValuesClientListResponse) (VariableValuesClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariableValuesClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, variableName, options) - }, nil) - if err != nil { - return VariableValuesClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *VariableValuesClient) listCreateRequest(ctx context.Context, variableName string, _ *VariableValuesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *VariableValuesClient) listHandleResponse(resp *http.Response) (VariableValuesClientListResponse, error) { - result := VariableValuesClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValueListResult); err != nil { - return VariableValuesClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all variable values applicable the variable indicated -// at the management group scope. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariableValuesClientListForManagementGroupOptions contains the optional parameters for the VariableValuesClient.NewListForManagementGroupPager -// method. -func (client *VariableValuesClient) NewListForManagementGroupPager(managementGroupID string, variableName string, options *VariableValuesClientListForManagementGroupOptions) *runtime.Pager[VariableValuesClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VariableValuesClientListForManagementGroupResponse]{ - More: func(page VariableValuesClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariableValuesClientListForManagementGroupResponse) (VariableValuesClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariableValuesClient.NewListForManagementGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listForManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) - }, nil) - if err != nil { - return VariableValuesClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *VariableValuesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, _ *VariableValuesClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *VariableValuesClient) listForManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientListForManagementGroupResponse, error) { - result := VariableValuesClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValueListResult); err != nil { - return VariableValuesClientListForManagementGroupResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go deleted file mode 100644 index d59b2a39be6c..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go +++ /dev/null @@ -1,395 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armpolicy_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/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableValue.json -func ExampleVariableValuesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariableValuesClient().Delete(ctx, "DemoTestVariable", "TestValue", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableValue.json -func ExampleVariableValuesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().CreateOrUpdate(ctx, "DemoTestVariable", "TestValue", armpolicy.VariableValue{ - Properties: &armpolicy.VariableValueProperties{ - Values: []*armpolicy.VariableValueColumnValue{ - { - ColumnName: to.Ptr("StringColumn"), - ColumnValue: "SampleValue", - }, - { - ColumnName: to.Ptr("IntegerColumn"), - ColumnValue: float64(10), - }}, - }, - }, 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableValue.json -func ExampleVariableValuesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().Get(ctx, "DemoTestVariable", "TestValue", 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariableValuesForSubscription.json -func ExampleVariableValuesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariableValuesClient().NewListPager("DemoTestVariable", 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.VariableValueListResult = armpolicy.VariableValueListResult{ - // Value: []*armpolicy.VariableValue{ - // { - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NullableTestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/NullableTestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("NullColumnName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariableValuesForManagementGroup.json -func ExampleVariableValuesClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariableValuesClient().NewListForManagementGroupPager("DevOrg", "DemoTestVariable", 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.VariableValueListResult = armpolicy.VariableValueListResult{ - // Value: []*armpolicy.VariableValue{ - // { - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NullableTestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/NullableTestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("NullColumnName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariableValuesClient().DeleteAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", 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/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().CreateOrUpdateAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", armpolicy.VariableValue{ - Properties: &armpolicy.VariableValueProperties{ - Values: []*armpolicy.VariableValueColumnValue{ - { - ColumnName: to.Ptr("StringColumn"), - ColumnValue: "SampleValue", - }, - { - ColumnName: to.Ptr("IntegerColumn"), - ColumnValue: float64(10), - }}, - }, - }, 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/219b2e3ef270f18149774eb2793b48baacde982f/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().GetAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/CHANGELOG.md b/sdk/resourcemanager/resources/armresources/CHANGELOG.md index 9a48d952b865..bb9e0007268d 100644 --- a/sdk/resourcemanager/resources/armresources/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armresources/CHANGELOG.md @@ -1,5 +1,116 @@ # Release History +## 3.0.0 (2025-04-28) +### Breaking Changes + +- Enum `ChangeType` has been removed +- Enum `DeploymentMode` has been removed +- Enum `ExpressionEvaluationOptionsScopeType` has been removed +- Enum `Level` has been removed +- Enum `OnErrorDeploymentType` has been removed +- Enum `PropertyChangeType` has been removed +- Enum `ProvisioningOperation` has been removed +- Enum `ProvisioningState` has been removed +- Enum `ValidationLevel` has been removed +- Enum `WhatIfResultFormat` has been removed +- Function `*ClientFactory.NewDeploymentOperationsClient` has been removed +- Function `*ClientFactory.NewDeploymentsClient` has been removed +- Function `NewDeploymentOperationsClient` has been removed +- Function `*DeploymentOperationsClient.Get` has been removed +- Function `*DeploymentOperationsClient.GetAtManagementGroupScope` has been removed +- Function `*DeploymentOperationsClient.GetAtScope` has been removed +- Function `*DeploymentOperationsClient.GetAtSubscriptionScope` has been removed +- Function `*DeploymentOperationsClient.GetAtTenantScope` has been removed +- Function `*DeploymentOperationsClient.NewListAtManagementGroupScopePager` has been removed +- Function `*DeploymentOperationsClient.NewListAtScopePager` has been removed +- Function `*DeploymentOperationsClient.NewListAtSubscriptionScopePager` has been removed +- Function `*DeploymentOperationsClient.NewListAtTenantScopePager` has been removed +- Function `*DeploymentOperationsClient.NewListPager` has been removed +- Function `NewDeploymentsClient` has been removed +- Function `*DeploymentsClient.CalculateTemplateHash` has been removed +- Function `*DeploymentsClient.Cancel` has been removed +- Function `*DeploymentsClient.CancelAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.CancelAtScope` has been removed +- Function `*DeploymentsClient.CancelAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.CancelAtTenantScope` has been removed +- Function `*DeploymentsClient.CheckExistence` has been removed +- Function `*DeploymentsClient.CheckExistenceAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.CheckExistenceAtScope` has been removed +- Function `*DeploymentsClient.CheckExistenceAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.CheckExistenceAtTenantScope` has been removed +- Function `*DeploymentsClient.BeginCreateOrUpdate` has been removed +- Function `*DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.BeginCreateOrUpdateAtScope` has been removed +- Function `*DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.BeginCreateOrUpdateAtTenantScope` has been removed +- Function `*DeploymentsClient.BeginDelete` has been removed +- Function `*DeploymentsClient.BeginDeleteAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.BeginDeleteAtScope` has been removed +- Function `*DeploymentsClient.BeginDeleteAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.BeginDeleteAtTenantScope` has been removed +- Function `*DeploymentsClient.ExportTemplate` has been removed +- Function `*DeploymentsClient.ExportTemplateAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.ExportTemplateAtScope` has been removed +- Function `*DeploymentsClient.ExportTemplateAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.ExportTemplateAtTenantScope` has been removed +- Function `*DeploymentsClient.Get` has been removed +- Function `*DeploymentsClient.GetAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.GetAtScope` has been removed +- Function `*DeploymentsClient.GetAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.GetAtTenantScope` has been removed +- Function `*DeploymentsClient.NewListAtManagementGroupScopePager` has been removed +- Function `*DeploymentsClient.NewListAtScopePager` has been removed +- Function `*DeploymentsClient.NewListAtSubscriptionScopePager` has been removed +- Function `*DeploymentsClient.NewListAtTenantScopePager` has been removed +- Function `*DeploymentsClient.NewListByResourceGroupPager` has been removed +- Function `*DeploymentsClient.BeginValidate` has been removed +- Function `*DeploymentsClient.BeginValidateAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.BeginValidateAtScope` has been removed +- Function `*DeploymentsClient.BeginValidateAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.BeginValidateAtTenantScope` has been removed +- Function `*DeploymentsClient.BeginWhatIf` has been removed +- Function `*DeploymentsClient.BeginWhatIfAtManagementGroupScope` has been removed +- Function `*DeploymentsClient.BeginWhatIfAtSubscriptionScope` has been removed +- Function `*DeploymentsClient.BeginWhatIfAtTenantScope` has been removed +- Struct `BasicDependency` has been removed +- Struct `DebugSetting` has been removed +- Struct `Dependency` has been removed +- Struct `Deployment` has been removed +- Struct `DeploymentDiagnosticsDefinition` has been removed +- Struct `DeploymentExportResult` has been removed +- Struct `DeploymentExtended` has been removed +- Struct `DeploymentExtendedFilter` has been removed +- Struct `DeploymentListResult` has been removed +- Struct `DeploymentOperation` has been removed +- Struct `DeploymentOperationProperties` has been removed +- Struct `DeploymentOperationsListResult` has been removed +- Struct `DeploymentParameter` has been removed +- Struct `DeploymentProperties` has been removed +- Struct `DeploymentPropertiesExtended` has been removed +- Struct `DeploymentValidateResult` has been removed +- Struct `DeploymentWhatIf` has been removed +- Struct `DeploymentWhatIfProperties` has been removed +- Struct `DeploymentWhatIfSettings` has been removed +- Struct `ExpressionEvaluationOptions` has been removed +- Struct `HTTPMessage` has been removed +- Struct `KeyVaultParameterReference` has been removed +- Struct `KeyVaultReference` has been removed +- Struct `OnErrorDeployment` has been removed +- Struct `OnErrorDeploymentExtended` has been removed +- Struct `ParametersLink` has been removed +- Struct `ResourceReference` has been removed +- Struct `ScopedDeployment` has been removed +- Struct `ScopedDeploymentWhatIf` has been removed +- Struct `StatusMessage` has been removed +- Struct `TargetResource` has been removed +- Struct `TemplateHashResult` has been removed +- Struct `TemplateLink` has been removed +- Struct `WhatIfChange` has been removed +- Struct `WhatIfOperationProperties` has been removed +- Struct `WhatIfOperationResult` has been removed +- Struct `WhatIfPropertyChange` has been removed + + ## 2.0.0 (2025-02-13) ### Breaking Changes diff --git a/sdk/resourcemanager/resources/armresources/README.md b/sdk/resourcemanager/resources/armresources/README.md index 857630b0c1fb..ab23bbbea566 100644 --- a/sdk/resourcemanager/resources/armresources/README.md +++ b/sdk/resourcemanager/resources/armresources/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Resources module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2 +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3 ``` ## Authorization diff --git a/sdk/resourcemanager/resources/armresources/autorest.md b/sdk/resourcemanager/resources/armresources/autorest.md index 439e090d40ff..462798f88701 100644 --- a/sdk/resourcemanager/resources/armresources/autorest.md +++ b/sdk/resourcemanager/resources/armresources/autorest.md @@ -5,10 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/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: 2.0.0 +module-version: 3.0.0 package-resources: true -tag: package-resources-2024-11 ``` diff --git a/sdk/resourcemanager/resources/armresources/client.go b/sdk/resourcemanager/resources/armresources/client.go index 3796575c3cb4..f610c9df36bb 100644 --- a/sdk/resourcemanager/resources/armresources/client.go +++ b/sdk/resourcemanager/resources/armresources/client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -46,7 +43,7 @@ func NewClient(subscriptionID string, credential azcore.TokenCredential, options // CheckExistence - Checks whether a resource exists. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group containing the resource to check. The name is case insensitive. // - resourceProviderNamespace - The resource provider of the resource to check. // - parentResourcePath - The parent resource identity. @@ -76,7 +73,7 @@ func (client *Client) CheckExistence(ctx context.Context, resourceGroupName stri } // checkExistenceCreateRequest creates the CheckExistence request. -func (client *Client) checkExistenceCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, options *ClientCheckExistenceOptions) (*policy.Request, error) { +func (client *Client) checkExistenceCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, _ *ClientCheckExistenceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -111,7 +108,7 @@ func (client *Client) checkExistenceCreateRequest(ctx context.Context, resourceG // providers. In the event that a Resource provider does not implement this API, ARM will respond with // a 405. The alternative then is to use the GET API to check for the existence of the resource. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -138,7 +135,7 @@ func (client *Client) CheckExistenceByID(ctx context.Context, resourceID string, } // checkExistenceByIDCreateRequest creates the CheckExistenceByID request. -func (client *Client) checkExistenceByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, options *ClientCheckExistenceByIDOptions) (*policy.Request, error) { +func (client *Client) checkExistenceByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, _ *ClientCheckExistenceByIDOptions) (*policy.Request, error) { urlPath := "/{resourceId}" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -155,7 +152,7 @@ func (client *Client) checkExistenceByIDCreateRequest(ctx context.Context, resou // BeginCreateOrUpdate - Creates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group for the resource. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -184,7 +181,7 @@ func (client *Client) BeginCreateOrUpdate(ctx context.Context, resourceGroupName // CreateOrUpdate - Creates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) createOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, options *ClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "Client.BeginCreateOrUpdate" @@ -207,7 +204,7 @@ func (client *Client) createOrUpdate(ctx context.Context, resourceGroupName stri } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, options *ClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, _ *ClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -244,7 +241,7 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG // BeginCreateOrUpdateByID - Create a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -271,7 +268,7 @@ func (client *Client) BeginCreateOrUpdateByID(ctx context.Context, resourceID st // CreateOrUpdateByID - Create a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) createOrUpdateByID(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, options *ClientBeginCreateOrUpdateByIDOptions) (*http.Response, error) { var err error const operationName = "Client.BeginCreateOrUpdateByID" @@ -294,7 +291,7 @@ func (client *Client) createOrUpdateByID(ctx context.Context, resourceID string, } // createOrUpdateByIDCreateRequest creates the CreateOrUpdateByID request. -func (client *Client) createOrUpdateByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, options *ClientBeginCreateOrUpdateByIDOptions) (*policy.Request, error) { +func (client *Client) createOrUpdateByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, _ *ClientBeginCreateOrUpdateByIDOptions) (*policy.Request, error) { urlPath := "/{resourceId}" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -314,7 +311,7 @@ func (client *Client) createOrUpdateByIDCreateRequest(ctx context.Context, resou // BeginDelete - Deletes a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group that contains the resource to delete. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -342,7 +339,7 @@ func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, // Delete - Deletes a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, options *ClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "Client.BeginDelete" @@ -365,7 +362,7 @@ func (client *Client) deleteOperation(ctx context.Context, resourceGroupName str } // deleteCreateRequest creates the Delete request. -func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, options *ClientBeginDeleteOptions) (*policy.Request, error) { +func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, _ *ClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -399,7 +396,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName // BeginDeleteByID - Deletes a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -424,7 +421,7 @@ func (client *Client) BeginDeleteByID(ctx context.Context, resourceID string, ap // DeleteByID - Deletes a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) deleteByID(ctx context.Context, resourceID string, apiVersion string, options *ClientBeginDeleteByIDOptions) (*http.Response, error) { var err error const operationName = "Client.BeginDeleteByID" @@ -447,7 +444,7 @@ func (client *Client) deleteByID(ctx context.Context, resourceID string, apiVers } // deleteByIDCreateRequest creates the DeleteByID request. -func (client *Client) deleteByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, options *ClientBeginDeleteByIDOptions) (*policy.Request, error) { +func (client *Client) deleteByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, _ *ClientBeginDeleteByIDOptions) (*policy.Request, error) { urlPath := "/{resourceId}" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -464,7 +461,7 @@ func (client *Client) deleteByIDCreateRequest(ctx context.Context, resourceID st // Get - Gets a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group containing the resource to get. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -495,7 +492,7 @@ func (client *Client) Get(ctx context.Context, resourceGroupName string, resourc } // getCreateRequest creates the Get request. -func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, options *ClientGetOptions) (*policy.Request, error) { +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, _ *ClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -538,7 +535,7 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, // GetByID - Gets a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -566,7 +563,7 @@ func (client *Client) GetByID(ctx context.Context, resourceID string, apiVersion } // getByIDCreateRequest creates the GetByID request. -func (client *Client) getByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, options *ClientGetByIDOptions) (*policy.Request, error) { +func (client *Client) getByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, _ *ClientGetByIDOptions) (*policy.Request, error) { urlPath := "/{resourceId}" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -591,7 +588,7 @@ func (client *Client) getByIDHandleResponse(resp *http.Response) (ClientGetByIDR // NewListPager - Get all the resources in a subscription. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. func (client *Client) NewListPager(options *ClientListOptions) *runtime.Pager[ClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ @@ -637,7 +634,7 @@ func (client *Client) listCreateRequest(ctx context.Context, options *ClientList if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -654,7 +651,7 @@ func (client *Client) listHandleResponse(resp *http.Response) (ClientListRespons // NewListByResourceGroupPager - Get all the resources for a resource group. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The resource group with the resources to get. // - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager // method. @@ -706,7 +703,7 @@ func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, reso if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -727,7 +724,7 @@ func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (Cl // on the groups until the move completes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - sourceResourceGroupName - The name of the resource group from the source subscription containing the resources to be moved. // - parameters - Parameters for moving resources. // - options - ClientBeginMoveResourcesOptions contains the optional parameters for the Client.BeginMoveResources method. @@ -754,7 +751,7 @@ func (client *Client) BeginMoveResources(ctx context.Context, sourceResourceGrou // on the groups until the move completes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) moveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, options *ClientBeginMoveResourcesOptions) (*http.Response, error) { var err error const operationName = "Client.BeginMoveResources" @@ -777,7 +774,7 @@ func (client *Client) moveResources(ctx context.Context, sourceResourceGroupName } // moveResourcesCreateRequest creates the MoveResources request. -func (client *Client) moveResourcesCreateRequest(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, options *ClientBeginMoveResourcesOptions) (*policy.Request, error) { +func (client *Client) moveResourcesCreateRequest(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, _ *ClientBeginMoveResourcesOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources" if sourceResourceGroupName == "" { return nil, errors.New("parameter sourceResourceGroupName cannot be empty") @@ -792,7 +789,7 @@ func (client *Client) moveResourcesCreateRequest(ctx context.Context, sourceReso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -804,7 +801,7 @@ func (client *Client) moveResourcesCreateRequest(ctx context.Context, sourceReso // BeginUpdate - Updates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group for the resource. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -833,7 +830,7 @@ func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, // Update - Updates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, options *ClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "Client.BeginUpdate" @@ -856,7 +853,7 @@ func (client *Client) update(ctx context.Context, resourceGroupName string, reso } // updateCreateRequest creates the Update request. -func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, options *ClientBeginUpdateOptions) (*policy.Request, error) { +func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, _ *ClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -893,7 +890,7 @@ func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName // BeginUpdateByID - Updates a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -919,7 +916,7 @@ func (client *Client) BeginUpdateByID(ctx context.Context, resourceID string, ap // UpdateByID - Updates a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) updateByID(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, options *ClientBeginUpdateByIDOptions) (*http.Response, error) { var err error const operationName = "Client.BeginUpdateByID" @@ -942,7 +939,7 @@ func (client *Client) updateByID(ctx context.Context, resourceID string, apiVers } // updateByIDCreateRequest creates the UpdateByID request. -func (client *Client) updateByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, options *ClientBeginUpdateByIDOptions) (*policy.Request, error) { +func (client *Client) updateByIDCreateRequest(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, _ *ClientBeginUpdateByIDOptions) (*policy.Request, error) { urlPath := "/{resourceId}" urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -966,7 +963,7 @@ func (client *Client) updateByIDCreateRequest(ctx context.Context, resourceID st // error message. Retrieve the URL in the Location header value to check the result of the long-running operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - sourceResourceGroupName - The name of the resource group from the source subscription containing the resources to be validated // for move. // - parameters - Parameters for moving resources. @@ -996,7 +993,7 @@ func (client *Client) BeginValidateMoveResources(ctx context.Context, sourceReso // error message. Retrieve the URL in the Location header value to check the result of the long-running operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *Client) validateMoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, options *ClientBeginValidateMoveResourcesOptions) (*http.Response, error) { var err error const operationName = "Client.BeginValidateMoveResources" @@ -1019,7 +1016,7 @@ func (client *Client) validateMoveResources(ctx context.Context, sourceResourceG } // validateMoveResourcesCreateRequest creates the ValidateMoveResources request. -func (client *Client) validateMoveResourcesCreateRequest(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, options *ClientBeginValidateMoveResourcesOptions) (*policy.Request, error) { +func (client *Client) validateMoveResourcesCreateRequest(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, _ *ClientBeginValidateMoveResourcesOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources" if sourceResourceGroupName == "" { return nil, errors.New("parameter sourceResourceGroupName cannot be empty") @@ -1034,7 +1031,7 @@ func (client *Client) validateMoveResourcesCreateRequest(ctx context.Context, so return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armresources/client_factory.go b/sdk/resourcemanager/resources/armresources/client_factory.go index 8470b7bf6702..d545d8b68459 100644 --- a/sdk/resourcemanager/resources/armresources/client_factory.go +++ b/sdk/resourcemanager/resources/armresources/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -44,22 +41,6 @@ func (c *ClientFactory) NewClient() *Client { } } -// NewDeploymentOperationsClient creates a new instance of DeploymentOperationsClient. -func (c *ClientFactory) NewDeploymentOperationsClient() *DeploymentOperationsClient { - return &DeploymentOperationsClient{ - subscriptionID: c.subscriptionID, - internal: c.internal, - } -} - -// NewDeploymentsClient creates a new instance of DeploymentsClient. -func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { - return &DeploymentsClient{ - subscriptionID: c.subscriptionID, - internal: c.internal, - } -} - // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { return &OperationsClient{ diff --git a/sdk/resourcemanager/resources/armresources/constants.go b/sdk/resourcemanager/resources/armresources/constants.go index bee94d1b538e..b7198338a91c 100644 --- a/sdk/resourcemanager/resources/armresources/constants.go +++ b/sdk/resourcemanager/resources/armresources/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,7 +7,7 @@ package armresources const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - moduleVersion = "v2.0.0" + moduleVersion = "v3.0.0" ) // AliasPathAttributes - The attributes of the token that the alias path is referring to. @@ -106,65 +103,6 @@ func PossibleAliasTypeValues() []AliasType { } } -// ChangeType - Type of change that will be made to the resource when the deployment is executed. -type ChangeType string - -const ( - // ChangeTypeCreate - The resource does not exist in the current state but is present in the desired state. The resource will - // be created when the deployment is executed. - ChangeTypeCreate ChangeType = "Create" - // ChangeTypeDelete - The resource exists in the current state and is missing from the desired state. The resource will be - // deleted when the deployment is executed. - ChangeTypeDelete ChangeType = "Delete" - // ChangeTypeDeploy - The resource exists in the current state and the desired state and will be redeployed when the deployment - // is executed. The properties of the resource may or may not change. - ChangeTypeDeploy ChangeType = "Deploy" - // ChangeTypeIgnore - The resource exists in the current state and is missing from the desired state. The resource will not - // be deployed or modified when the deployment is executed. - ChangeTypeIgnore ChangeType = "Ignore" - // ChangeTypeModify - The resource exists in the current state and the desired state and will be redeployed when the deployment - // is executed. The properties of the resource will change. - ChangeTypeModify ChangeType = "Modify" - // ChangeTypeNoChange - The resource exists in the current state and the desired state and will be redeployed when the deployment - // is executed. The properties of the resource will not change. - ChangeTypeNoChange ChangeType = "NoChange" - // ChangeTypeUnsupported - The resource is not supported by What-If. - ChangeTypeUnsupported ChangeType = "Unsupported" -) - -// PossibleChangeTypeValues returns the possible values for the ChangeType const type. -func PossibleChangeTypeValues() []ChangeType { - return []ChangeType{ - ChangeTypeCreate, - ChangeTypeDelete, - ChangeTypeDeploy, - ChangeTypeIgnore, - ChangeTypeModify, - ChangeTypeNoChange, - ChangeTypeUnsupported, - } -} - -// DeploymentMode - The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental -// mode, resources are deployed without deleting existing resources that are not included in -// the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included -// in the template are deleted. Be careful when using Complete mode as you may -// unintentionally delete resources. -type DeploymentMode string - -const ( - DeploymentModeComplete DeploymentMode = "Complete" - DeploymentModeIncremental DeploymentMode = "Incremental" -) - -// PossibleDeploymentModeValues returns the possible values for the DeploymentMode const type. -func PossibleDeploymentModeValues() []DeploymentMode { - return []DeploymentMode{ - DeploymentModeComplete, - DeploymentModeIncremental, - } -} - // ExportTemplateOutputFormat - The output format for the exported resources. type ExportTemplateOutputFormat string @@ -181,25 +119,6 @@ func PossibleExportTemplateOutputFormatValues() []ExportTemplateOutputFormat { } } -// ExpressionEvaluationOptionsScopeType - The scope to be used for evaluation of parameters, variables and functions in a -// nested template. -type ExpressionEvaluationOptionsScopeType string - -const ( - ExpressionEvaluationOptionsScopeTypeInner ExpressionEvaluationOptionsScopeType = "Inner" - ExpressionEvaluationOptionsScopeTypeNotSpecified ExpressionEvaluationOptionsScopeType = "NotSpecified" - ExpressionEvaluationOptionsScopeTypeOuter ExpressionEvaluationOptionsScopeType = "Outer" -) - -// PossibleExpressionEvaluationOptionsScopeTypeValues returns the possible values for the ExpressionEvaluationOptionsScopeType const type. -func PossibleExpressionEvaluationOptionsScopeTypeValues() []ExpressionEvaluationOptionsScopeType { - return []ExpressionEvaluationOptionsScopeType{ - ExpressionEvaluationOptionsScopeTypeInner, - ExpressionEvaluationOptionsScopeTypeNotSpecified, - ExpressionEvaluationOptionsScopeTypeOuter, - } -} - // ExtendedLocationType - The extended location type. type ExtendedLocationType string @@ -214,70 +133,6 @@ func PossibleExtendedLocationTypeValues() []ExtendedLocationType { } } -// Level - Denotes the additional response level. -type Level string - -const ( - LevelError Level = "Error" - LevelInfo Level = "Info" - LevelWarning Level = "Warning" -) - -// PossibleLevelValues returns the possible values for the Level const type. -func PossibleLevelValues() []Level { - return []Level{ - LevelError, - LevelInfo, - LevelWarning, - } -} - -// OnErrorDeploymentType - The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. -type OnErrorDeploymentType string - -const ( - OnErrorDeploymentTypeLastSuccessful OnErrorDeploymentType = "LastSuccessful" - OnErrorDeploymentTypeSpecificDeployment OnErrorDeploymentType = "SpecificDeployment" -) - -// PossibleOnErrorDeploymentTypeValues returns the possible values for the OnErrorDeploymentType const type. -func PossibleOnErrorDeploymentTypeValues() []OnErrorDeploymentType { - return []OnErrorDeploymentType{ - OnErrorDeploymentTypeLastSuccessful, - OnErrorDeploymentTypeSpecificDeployment, - } -} - -// PropertyChangeType - The type of property change. -type PropertyChangeType string - -const ( - // PropertyChangeTypeArray - The property is an array and contains nested changes. - PropertyChangeTypeArray PropertyChangeType = "Array" - // PropertyChangeTypeCreate - The property does not exist in the current state but is present in the desired state. The property - // will be created when the deployment is executed. - PropertyChangeTypeCreate PropertyChangeType = "Create" - // PropertyChangeTypeDelete - The property exists in the current state and is missing from the desired state. It will be deleted - // when the deployment is executed. - PropertyChangeTypeDelete PropertyChangeType = "Delete" - // PropertyChangeTypeModify - The property exists in both current and desired state and is different. The value of the property - // will change when the deployment is executed. - PropertyChangeTypeModify PropertyChangeType = "Modify" - // PropertyChangeTypeNoEffect - The property will not be set or updated. - PropertyChangeTypeNoEffect PropertyChangeType = "NoEffect" -) - -// PossiblePropertyChangeTypeValues returns the possible values for the PropertyChangeType const type. -func PossiblePropertyChangeTypeValues() []PropertyChangeType { - return []PropertyChangeType{ - PropertyChangeTypeArray, - PropertyChangeTypeCreate, - PropertyChangeTypeDelete, - PropertyChangeTypeModify, - PropertyChangeTypeNoEffect, - } -} - // ProviderAuthorizationConsentState - The provider authorization consent state. type ProviderAuthorizationConsentState string @@ -298,85 +153,6 @@ func PossibleProviderAuthorizationConsentStateValues() []ProviderAuthorizationCo } } -// ProvisioningOperation - The name of the current provisioning operation. -type ProvisioningOperation string - -const ( - // ProvisioningOperationAction - The provisioning operation is action. - ProvisioningOperationAction ProvisioningOperation = "Action" - // ProvisioningOperationAzureAsyncOperationWaiting - The provisioning operation is waiting Azure async operation. - ProvisioningOperationAzureAsyncOperationWaiting ProvisioningOperation = "AzureAsyncOperationWaiting" - // ProvisioningOperationCreate - The provisioning operation is create. - ProvisioningOperationCreate ProvisioningOperation = "Create" - // ProvisioningOperationDelete - The provisioning operation is delete. - ProvisioningOperationDelete ProvisioningOperation = "Delete" - // ProvisioningOperationDeploymentCleanup - The provisioning operation is cleanup. This operation is part of the 'complete' - // mode deployment. - ProvisioningOperationDeploymentCleanup ProvisioningOperation = "DeploymentCleanup" - // ProvisioningOperationEvaluateDeploymentOutput - The provisioning operation is evaluate output. - ProvisioningOperationEvaluateDeploymentOutput ProvisioningOperation = "EvaluateDeploymentOutput" - // ProvisioningOperationNotSpecified - The provisioning operation is not specified. - ProvisioningOperationNotSpecified ProvisioningOperation = "NotSpecified" - // ProvisioningOperationRead - The provisioning operation is read. - ProvisioningOperationRead ProvisioningOperation = "Read" - // ProvisioningOperationResourceCacheWaiting - The provisioning operation is waiting for resource cache. - ProvisioningOperationResourceCacheWaiting ProvisioningOperation = "ResourceCacheWaiting" - // ProvisioningOperationWaiting - The provisioning operation is waiting. - ProvisioningOperationWaiting ProvisioningOperation = "Waiting" -) - -// PossibleProvisioningOperationValues returns the possible values for the ProvisioningOperation const type. -func PossibleProvisioningOperationValues() []ProvisioningOperation { - return []ProvisioningOperation{ - ProvisioningOperationAction, - ProvisioningOperationAzureAsyncOperationWaiting, - ProvisioningOperationCreate, - ProvisioningOperationDelete, - ProvisioningOperationDeploymentCleanup, - ProvisioningOperationEvaluateDeploymentOutput, - ProvisioningOperationNotSpecified, - ProvisioningOperationRead, - ProvisioningOperationResourceCacheWaiting, - ProvisioningOperationWaiting, - } -} - -// ProvisioningState - Denotes the state of provisioning. -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreated ProvisioningState = "Created" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleted ProvisioningState = "Deleted" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" - ProvisioningStateReady ProvisioningState = "Ready" - ProvisioningStateRunning ProvisioningState = "Running" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. -func PossibleProvisioningStateValues() []ProvisioningState { - return []ProvisioningState{ - ProvisioningStateAccepted, - ProvisioningStateCanceled, - ProvisioningStateCreated, - ProvisioningStateCreating, - ProvisioningStateDeleted, - ProvisioningStateDeleting, - ProvisioningStateFailed, - ProvisioningStateNotSpecified, - ProvisioningStateReady, - ProvisioningStateRunning, - ProvisioningStateSucceeded, - ProvisioningStateUpdating, - } -} - // ResourceIdentityType - The identity type. type ResourceIdentityType string @@ -418,42 +194,3 @@ func PossibleTagsPatchOperationValues() []TagsPatchOperation { TagsPatchOperationReplace, } } - -// ValidationLevel - The level of validation performed on the deployment. -type ValidationLevel string - -const ( - // ValidationLevelProvider - Static analysis of the template is performed and resource declarations are sent to resource providers - // for semantic validation. Validates that the caller has RBAC write permissions on each resource. - ValidationLevelProvider ValidationLevel = "Provider" - // ValidationLevelProviderNoRbac - Static analysis of the template is performed and resource declarations are sent to resource - // providers for semantic validation. Skips validating that the caller has RBAC write permissions on each resource. - ValidationLevelProviderNoRbac ValidationLevel = "ProviderNoRbac" - // ValidationLevelTemplate - Static analysis of the template is performed. - ValidationLevelTemplate ValidationLevel = "Template" -) - -// PossibleValidationLevelValues returns the possible values for the ValidationLevel const type. -func PossibleValidationLevelValues() []ValidationLevel { - return []ValidationLevel{ - ValidationLevelProvider, - ValidationLevelProviderNoRbac, - ValidationLevelTemplate, - } -} - -// WhatIfResultFormat - The format of the What-If results -type WhatIfResultFormat string - -const ( - WhatIfResultFormatFullResourcePayloads WhatIfResultFormat = "FullResourcePayloads" - WhatIfResultFormatResourceIDOnly WhatIfResultFormat = "ResourceIdOnly" -) - -// PossibleWhatIfResultFormatValues returns the possible values for the WhatIfResultFormat const type. -func PossibleWhatIfResultFormatValues() []WhatIfResultFormat { - return []WhatIfResultFormat{ - WhatIfResultFormatFullResourcePayloads, - WhatIfResultFormatResourceIDOnly, - } -} diff --git a/sdk/resourcemanager/resources/armresources/deployments_client_example_test.go b/sdk/resourcemanager/resources/armresources/deployments_client_example_test.go deleted file mode 100644 index d38169cb4282..000000000000 --- a/sdk/resourcemanager/resources/armresources/deployments_client_example_test.go +++ /dev/null @@ -1,1472 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armresources_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/armresources/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentAtScope.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtScope(ctx, "providers/Microsoft.Management/managementGroups/my-management-group-id", "my-deployment", armresources.Deployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Resources/deployments/my-deployment"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyDefinitions/policy-definition-name"), - // ResourceName: to.Ptr("policy-definition-name"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // }}, - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyAssignments/location-lock"), - // ResourceName: to.Ptr("location-lock"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyAssignments"), - // }}, - // Duration: to.Ptr("PT1.2970875S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyDefinitions"), - // }, - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyAssignments"), - // }}, - // }, - // { - // Namespace: to.Ptr("Microsoft.Resources"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("deployments"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-24T22:52:38.789Z"); return t}()), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentValidateOnScope.json -func ExampleDeploymentsClient_BeginValidateAtScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginValidateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - QueryString: to.Ptr("sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d"), - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentValidateResult = armresources.DeploymentValidateResult{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Diagnostics: []*armresources.DeploymentDiagnosticsDefinition{ - // { - // Code: to.Ptr("NestedDeploymentShortCircuited"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("A nested deployment got short-circuited and all its resources got skipped from validation. This is due to a nested template having a parameter that was not fully evaluated (e.g. contains a reference() function)."), - // }, - // { - // Code: to.Ptr("NestedDeploymentSkippedFromInternalExpansion"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("When nested deployments are expanded, all its inner resources are retrieved for further validation. This process is performed in batch of: '10' at a time. Nested deployments exceeding this batch count are skipped from expansion."), - // }, - // { - // Code: to.Ptr("NestedDeploymentExpansionLimitReached"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("Nested deployments are expanded up to: '50' in total. Nested deployments exceeding this count are skipped from expansion."), - // }}, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // ValidatedResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/my-storage-account"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentAtTenant.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtTenantScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtTenantScope(ctx, "tenant-dep01", armresources.ScopedDeployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("tenant-dep01"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Resources/deployments/tenant-dep01"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/policy-definition-name"), - // ResourceName: to.Ptr("policy-definition-name"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // }}, - // ID: to.Ptr("/providers/Microsoft.Authorization/policyAssignments/location-lock"), - // ResourceName: to.Ptr("location-lock"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyAssignments"), - // }}, - // Duration: to.Ptr("PT1.2970875S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyDefinitions"), - // }, - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyAssignments"), - // }}, - // }, - // { - // Namespace: to.Ptr("Microsoft.Resources"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("deployments"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-24T22:52:38.789Z"); return t}()), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentValidateOnTenant.json -func ExampleDeploymentsClient_BeginValidateAtTenantScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginValidateAtTenantScope(ctx, "my-deployment", armresources.ScopedDeployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentValidateResult = armresources.DeploymentValidateResult{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Diagnostics: []*armresources.DeploymentDiagnosticsDefinition{ - // { - // Code: to.Ptr("NestedDeploymentShortCircuited"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("A nested deployment got short-circuited and all its resources got skipped from validation. This is due to a nested template having a parameter that was not fully evaluated (e.g. contains a reference() function)."), - // }, - // { - // Code: to.Ptr("NestedDeploymentSkippedFromInternalExpansion"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("When nested deployments are expanded, all its inner resources are retrieved for further validation. This process is performed in batch of: '10' at a time. Nested deployments exceeding this batch count are skipped from expansion."), - // }, - // { - // Code: to.Ptr("NestedDeploymentExpansionLimitReached"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("Nested deployments are expanded up to: '50' in total. Nested deployments exceeding this count are skipped from expansion."), - // }}, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyDefinitions"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // URI: to.Ptr("https://example.com/exampleTemplate.json"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // ValidatedResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/policy-definition-name"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentWhatIfOnTenant.json -func ExampleDeploymentsClient_BeginWhatIfAtTenantScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIfAtTenantScope(ctx, "exampleDeploymentName", armresources.ScopedDeploymentWhatIf{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "name": "myManagementGroup", - // "type": "Microsoft.Management/managementGroups", - // "apiVersion": "2019-11-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), - // }}, - // }, - // Status: to.Ptr("Succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentAtManagementGroup.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtManagementGroupScope(ctx, "my-management-group-id", "my-deployment", armresources.ScopedDeployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Resources/deployments/my-deployment"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyDefinitions/policy-definition-name"), - // ResourceName: to.Ptr("policy-definition-name"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // }}, - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyAssignments/location-lock"), - // ResourceName: to.Ptr("location-lock"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyAssignments"), - // }}, - // Duration: to.Ptr("PT1.2970875S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyDefinitions"), - // }, - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyAssignments"), - // }}, - // }, - // { - // Namespace: to.Ptr("Microsoft.Resources"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("deployments"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-24T22:52:38.789Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentValidateOnManagementGroup.json -func ExampleDeploymentsClient_BeginValidateAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginValidateAtManagementGroupScope(ctx, "my-management-group-id", "my-deployment", armresources.ScopedDeployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentValidateResult = armresources.DeploymentValidateResult{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Diagnostics: []*armresources.DeploymentDiagnosticsDefinition{ - // { - // Code: to.Ptr("NestedDeploymentShortCircuited"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("A nested deployment got short-circuited and all its resources got skipped from validation. This is due to a nested template having a parameter that was not fully evaluated (e.g. contains a reference() function)."), - // }, - // { - // Code: to.Ptr("NestedDeploymentSkippedFromInternalExpansion"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("When nested deployments are expanded, all its inner resources are retrieved for further validation. This process is performed in batch of: '10' at a time. Nested deployments exceeding this batch count are skipped from expansion."), - // }, - // { - // Code: to.Ptr("NestedDeploymentExpansionLimitReached"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("Nested deployments are expanded up to: '50' in total. Nested deployments exceeding this count are skipped from expansion."), - // }}, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyAssignments"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // URI: to.Ptr("https://example.com/exampleTemplate.json"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // ValidatedResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentWhatIfOnManagementGroup.json -func ExampleDeploymentsClient_BeginWhatIfAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIfAtManagementGroupScope(ctx, "myManagementGruop", "exampleDeploymentName", armresources.ScopedDeploymentWhatIf{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "before":map[string]any{ - // "name": "myPolicyAssignment", - // "type": "Microsoft.Authorization/policyAssignments", - // "apiVersion": "2019-06-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment", - // "location": "westus2", - // "properties":map[string]any{ - // "enforcementMode": "DoNotEnforce", - // "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyDefinition", - // "scope": "/subscriptions/00000000-0000-0000-0000-000000000001", - // }, - // }, - // "changeType": "Modify", - // "delta":[]any{ - // map[string]any{ - // "path": "properties.enforcementMode", - // "after": "DoNotEnforce", - // "before": "Default", - // "propertyChangeType": "Modify", - // }, - // }, - // "resourceId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment", - // }, - // Before: map[string]any{ - // "name": "myPolicyAssignment", - // "type": "Microsoft.Authorization/policyAssignments", - // "apiVersion": "2019-06-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment", - // "location": "westus2", - // "properties":map[string]any{ - // "enforcementMode": "Default", - // "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyDefinition", - // "scope": "/subscriptions/00000000-0000-0000-0000-000000000001", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeModify), - // ResourceID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), - // }, - // { - // After: map[string]any{ - // "name": "myPolicyAssignment2", - // "type": "Microsoft.Authorization/policyAssignments", - // "apiVersion": "2019-06-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2", - // "location": "westus2", - // "properties":map[string]any{ - // "enforcementMode": "Default", - // "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyDefinition", - // "scope": "/subscriptions/00000000-0000-0000-0000-000000000002", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2"), - // }}, - // }, - // Status: to.Ptr("Succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentSubscriptionTemplateSpecsWithId.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtSubscriptionScope(ctx, "my-deployment", armresources.Deployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.Resources/deployments/my-deployment"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Duration: to.Ptr("PT1.2637681S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // OutputResources: []*armresources.ResourceReference{ - // }, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // }, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:51:58.628Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentValidateOnSubscription.json -func ExampleDeploymentsClient_BeginValidateAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginValidateAtSubscriptionScope(ctx, "my-deployment", armresources.Deployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentValidateResult = armresources.DeploymentValidateResult{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Diagnostics: []*armresources.DeploymentDiagnosticsDefinition{ - // { - // Code: to.Ptr("NestedDeploymentShortCircuited"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("A nested deployment got short-circuited and all its resources got skipped from validation. This is due to a nested template having a parameter that was not fully evaluated (e.g. contains a reference() function)."), - // }, - // { - // Code: to.Ptr("NestedDeploymentSkippedFromInternalExpansion"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("When nested deployments are expanded, all its inner resources are retrieved for further validation. This process is performed in batch of: '10' at a time. Nested deployments exceeding this batch count are skipped from expansion."), - // }, - // { - // Code: to.Ptr("NestedDeploymentExpansionLimitReached"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("Nested deployments are expanded up to: '50' in total. Nested deployments exceeding this count are skipped from expansion."), - // }}, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Resources"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("resourceGroups"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // URI: to.Ptr("https://example.com/exampleTemplate.json"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // ValidatedResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group2"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentWhatIfOnSubscription.json -func ExampleDeploymentsClient_BeginWhatIfAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIfAtSubscriptionScope(ctx, "my-deployment", armresources.DeploymentWhatIf{ - Location: to.Ptr("westus"), - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // "tags":map[string]any{ - // "myNewTag": "my tag value", - // }, - // }, - // Before: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeModify), - // Delta: []*armresources.WhatIfPropertyChange{ - // { - // Path: to.Ptr("tags.myNewTag"), - // After: "my tag value", - // PropertyChangeType: to.Ptr(armresources.PropertyChangeTypeCreate), - // }}, - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity"), - // }, - // { - // After: map[string]any{ - // "name": "myNewIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity", - // "location": "eastus", - // "tags":map[string]any{ - // "myOtherNewTag": "another new tag value", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity"), - // }, - // { - // After: map[string]any{ - // "name": "my-resource-group2", - // "type": "Microsoft.Resources/resourceGroups", - // "apiVersion": "2019-03-01", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group2", - // "location": "{location3}", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group2"), - // }}, - // }, - // Status: to.Ptr("Succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentResourceGroup.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillDeployATemplateWithAUriAndQueryString() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - QueryString: to.Ptr("sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d"), - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // OutputResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/my-storage-account"), - // }}, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentResourceGroupTemplateSpecsWithId.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // OutputResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/my-storage-account"), - // }}, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeComplete), - OnErrorDeployment: &armresources.OnErrorDeployment{ - Type: to.Ptr(armresources.OnErrorDeploymentTypeSpecificDeployment), - DeploymentName: to.Ptr("name-of-deployment-to-use"), - }, - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }, - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }, - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet2"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // Duration: to.Ptr("PT0.8204881S"), - // Mode: to.Ptr(armresources.DeploymentModeComplete), - // OnErrorDeployment: &armresources.OnErrorDeploymentExtended{ - // Type: to.Ptr(armresources.OnErrorDeploymentTypeSpecificDeployment), - // DeploymentName: to.Ptr("name-of-deployment-to-use"), - // }, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Network"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks"), - // }, - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks/subnets"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // URI: to.Ptr("https://example.com/exampleTemplate.json"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeComplete), - OnErrorDeployment: &armresources.OnErrorDeployment{ - Type: to.Ptr(armresources.OnErrorDeploymentTypeLastSuccessful), - }, - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }, - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }, - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet2"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // Duration: to.Ptr("PT0.8204881S"), - // Mode: to.Ptr(armresources.DeploymentModeComplete), - // OnErrorDeployment: &armresources.OnErrorDeploymentExtended{ - // Type: to.Ptr(armresources.OnErrorDeploymentTypeLastSuccessful), - // DeploymentName: to.Ptr("{nameOfLastSuccesfulDeployment}"), - // }, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Network"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks"), - // }, - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks/subnets"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // URI: to.Ptr("https://example.com/exampleTemplate.json"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentValidateOnResourceGroup.json -func ExampleDeploymentsClient_BeginValidate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginValidate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - QueryString: to.Ptr("sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d"), - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentValidateResult = armresources.DeploymentValidateResult{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Diagnostics: []*armresources.DeploymentDiagnosticsDefinition{ - // { - // Code: to.Ptr("NestedDeploymentShortCircuited"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("A nested deployment got short-circuited and all its resources got skipped from validation. This is due to a nested template having a parameter that was not fully evaluated (e.g. contains a reference() function)."), - // }, - // { - // Code: to.Ptr("NestedDeploymentSkippedFromInternalExpansion"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("When nested deployments are expanded, all its inner resources are retrieved for further validation. This process is performed in batch of: '10' at a time. Nested deployments exceeding this batch count are skipped from expansion."), - // }, - // { - // Code: to.Ptr("NestedDeploymentExpansionLimitReached"), - // Level: to.Ptr(armresources.LevelWarning), - // Message: to.Ptr("Nested deployments are expanded up to: '50' in total. Nested deployments exceeding this count are skipped from expansion."), - // }}, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // ValidatedResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/my-storage-account"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PostDeploymentWhatIfOnResourceGroup.json -func ExampleDeploymentsClient_BeginWhatIf() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIf(ctx, "my-resource-group", "my-deployment", armresources.DeploymentWhatIf{ - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]*armresources.DeploymentParameter{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // "tags":map[string]any{ - // "myNewTag": "my tag value", - // }, - // }, - // Before: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeModify), - // Delta: []*armresources.WhatIfPropertyChange{ - // { - // Path: to.Ptr("tags.myNewTag"), - // After: "my tag value", - // PropertyChangeType: to.Ptr(armresources.PropertyChangeTypeCreate), - // }}, - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity"), - // }, - // { - // After: map[string]any{ - // "name": "myNewIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity", - // "location": "eastus", - // "tags":map[string]any{ - // "myOtherNewTag": "another new tag value", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity"), - // }}, - // }, - // Status: to.Ptr("Succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/CalculateTemplateHash.json -func ExampleDeploymentsClient_CalculateTemplateHash() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeploymentsClient().CalculateTemplateHash(ctx, map[string]any{ - "$schema": "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview", - "contentVersion": "1.0.0.0", - "outputs": map[string]any{ - "string": map[string]any{ - "type": "string", - "value": "myvalue", - }, - }, - "parameters": map[string]any{ - "string": map[string]any{ - "type": "string", - }, - }, - "resources": []any{}, - "variables": map[string]any{ - "array": []any{ - float64(1), - float64(2), - float64(3), - float64(4), - }, - "bool": true, - "int": float64(42), - "object": map[string]any{ - "object": map[string]any{ - "location": "West US", - "vmSize": "Large", - }, - }, - "string": "string", - }, - }, 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.TemplateHashResult = armresources.TemplateHashResult{ - // MinifiedTemplate: to.Ptr("{\"$SCHEMA\":\"HTTP://SCHEMAS.MANAGEMENT.AZURE.COM/DEPLOYMENTTEMPLATE?API-VERSION=2014-04-01-PREVIEW\",\"CONTENTVERSION\":\"1.0.0.0\",\"PARAMETERS\":{\"STRING\":{\"TYPE\":\"STRING\"}},\"VARIABLES\":{\"STRING\":\"STRING\",\"INT\":42,\"BOOL\":TRUE,\"ARRAY\":[1,2,3,4],\"OBJECT\":{\"OBJECT\":{\"VMSIZE\":\"LARGE\",\"LOCATION\":\"WEST US\"}}},\"RESOURCES\":[],\"OUTPUTS\":{\"STRING\":{\"TYPE\":\"STRING\",\"VALUE\":\"MYVALUE\"}}}"), - // TemplateHash: to.Ptr("695440707931307747"), - // } -} diff --git a/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go b/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go index 7fe4b7056833..a00d4f905bff 100644 --- a/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/fake/internal.go b/sdk/resourcemanager/resources/armresources/fake/internal.go index 7d2f89ba4bb2..c614f8d5643a 100644 --- a/sdk/resourcemanager/resources/armresources/fake/internal.go +++ b/sdk/resourcemanager/resources/armresources/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/resources/armresources/fake/operations_server.go b/sdk/resourcemanager/resources/armresources/fake/operations_server.go index 5dc57b498004..bc3ba9c5d9b9 100644 --- a/sdk/resourcemanager/resources/armresources/fake/operations_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "net/http" ) @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go b/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go index 7b03ede2c258..344a4b7a89b3 100644 --- a/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (p *ProviderResourceTypesServerTransport) Do(req *http.Request) (*http.Resp return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProviderResourceTypesClient.List": - resp, err = p.dispatchList(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProviderResourceTypesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if providerResourceTypesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = providerResourceTypesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProviderResourceTypesClient.List": + res.resp, res.err = p.dispatchList(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProviderResourceTypesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { @@ -106,3 +122,9 @@ func (p *ProviderResourceTypesServerTransport) dispatchList(req *http.Request) ( } return resp, nil } + +// set this to conditionally intercept incoming requests to ProviderResourceTypesServerTransport +var providerResourceTypesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armresources/fake/providers_server.go b/sdk/resourcemanager/resources/armresources/fake/providers_server.go index 896d5989fd68..5a8a3f1d0b35 100644 --- a/sdk/resourcemanager/resources/armresources/fake/providers_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/providers_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "net/http" "net/url" "reflect" @@ -85,35 +82,54 @@ func (p *ProvidersServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "ProvidersClient.Get": - resp, err = p.dispatchGet(req) - case "ProvidersClient.GetAtTenantScope": - resp, err = p.dispatchGetAtTenantScope(req) - case "ProvidersClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - case "ProvidersClient.NewListAtTenantScopePager": - resp, err = p.dispatchNewListAtTenantScopePager(req) - case "ProvidersClient.ProviderPermissions": - resp, err = p.dispatchProviderPermissions(req) - case "ProvidersClient.Register": - resp, err = p.dispatchRegister(req) - case "ProvidersClient.RegisterAtManagementGroupScope": - resp, err = p.dispatchRegisterAtManagementGroupScope(req) - case "ProvidersClient.Unregister": - resp, err = p.dispatchUnregister(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *ProvidersServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if providersServerTransportInterceptor != nil { + res.resp, res.err, intercepted = providersServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ProvidersClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "ProvidersClient.GetAtTenantScope": + res.resp, res.err = p.dispatchGetAtTenantScope(req) + case "ProvidersClient.NewListPager": + res.resp, res.err = p.dispatchNewListPager(req) + case "ProvidersClient.NewListAtTenantScopePager": + res.resp, res.err = p.dispatchNewListAtTenantScopePager(req) + case "ProvidersClient.ProviderPermissions": + res.resp, res.err = p.dispatchProviderPermissions(req) + case "ProvidersClient.Register": + res.resp, res.err = p.dispatchRegister(req) + case "ProvidersClient.RegisterAtManagementGroupScope": + res.resp, res.err = p.dispatchRegisterAtManagementGroupScope(req) + case "ProvidersClient.Unregister": + res.resp, res.err = p.dispatchUnregister(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (p *ProvidersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -411,3 +427,9 @@ func (p *ProvidersServerTransport) dispatchUnregister(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to ProvidersServerTransport +var providersServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go b/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go index bb13d0fcb29a..27793acc068b 100644 --- a/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "net/http" "net/url" "regexp" @@ -34,7 +31,7 @@ type ResourceGroupsServer struct { CreateOrUpdate func(ctx context.Context, resourceGroupName string, parameters armresources.ResourceGroup, options *armresources.ResourceGroupsClientCreateOrUpdateOptions) (resp azfake.Responder[armresources.ResourceGroupsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method ResourceGroupsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, options *armresources.ResourceGroupsClientBeginDeleteOptions) (resp azfake.PollerResponder[armresources.ResourceGroupsClientDeleteResponse], errResp azfake.ErrorResponder) // BeginExportTemplate is the fake for method ResourceGroupsClient.BeginExportTemplate @@ -83,33 +80,52 @@ func (r *ResourceGroupsServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ResourceGroupsClient.CheckExistence": - resp, err = r.dispatchCheckExistence(req) - case "ResourceGroupsClient.CreateOrUpdate": - resp, err = r.dispatchCreateOrUpdate(req) - case "ResourceGroupsClient.BeginDelete": - resp, err = r.dispatchBeginDelete(req) - case "ResourceGroupsClient.BeginExportTemplate": - resp, err = r.dispatchBeginExportTemplate(req) - case "ResourceGroupsClient.Get": - resp, err = r.dispatchGet(req) - case "ResourceGroupsClient.NewListPager": - resp, err = r.dispatchNewListPager(req) - case "ResourceGroupsClient.Update": - resp, err = r.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ResourceGroupsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if resourceGroupsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = resourceGroupsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ResourceGroupsClient.CheckExistence": + res.resp, res.err = r.dispatchCheckExistence(req) + case "ResourceGroupsClient.CreateOrUpdate": + res.resp, res.err = r.dispatchCreateOrUpdate(req) + case "ResourceGroupsClient.BeginDelete": + res.resp, res.err = r.dispatchBeginDelete(req) + case "ResourceGroupsClient.BeginExportTemplate": + res.resp, res.err = r.dispatchBeginExportTemplate(req) + case "ResourceGroupsClient.Get": + res.resp, res.err = r.dispatchGet(req) + case "ResourceGroupsClient.NewListPager": + res.resp, res.err = r.dispatchNewListPager(req) + case "ResourceGroupsClient.Update": + res.resp, res.err = r.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ResourceGroupsServerTransport) dispatchCheckExistence(req *http.Request) (*http.Response, error) { @@ -215,9 +231,9 @@ func (r *ResourceGroupsServerTransport) dispatchBeginDelete(req *http.Request) ( return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { r.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { r.beginDelete.remove(req) @@ -391,3 +407,9 @@ func (r *ResourceGroupsServerTransport) dispatchUpdate(req *http.Request) (*http } return resp, nil } + +// set this to conditionally intercept incoming requests to ResourceGroupsServerTransport +var resourceGroupsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armresources/fake/server.go b/sdk/resourcemanager/resources/armresources/fake/server.go index d9785bc844c6..f715cc9cbe88 100644 --- a/sdk/resourcemanager/resources/armresources/fake/server.go +++ b/sdk/resourcemanager/resources/armresources/fake/server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "net/http" "net/url" "regexp" @@ -66,7 +63,7 @@ type Server struct { NewListByResourceGroupPager func(resourceGroupName string, options *armresources.ClientListByResourceGroupOptions) (resp azfake.PagerResponder[armresources.ClientListByResourceGroupResponse]) // BeginMoveResources is the fake for method Client.BeginMoveResources - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginMoveResources func(ctx context.Context, sourceResourceGroupName string, parameters armresources.MoveInfo, options *armresources.ClientBeginMoveResourcesOptions) (resp azfake.PollerResponder[armresources.ClientMoveResourcesResponse], errResp azfake.ErrorResponder) // BeginUpdate is the fake for method Client.BeginUpdate @@ -78,7 +75,7 @@ type Server struct { BeginUpdateByID func(ctx context.Context, resourceID string, apiVersion string, parameters armresources.GenericResource, options *armresources.ClientBeginUpdateByIDOptions) (resp azfake.PollerResponder[armresources.ClientUpdateByIDResponse], errResp azfake.ErrorResponder) // BeginValidateMoveResources is the fake for method Client.BeginValidateMoveResources - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginValidateMoveResources func(ctx context.Context, sourceResourceGroupName string, parameters armresources.MoveInfo, options *armresources.ClientBeginValidateMoveResourcesOptions) (resp azfake.PollerResponder[armresources.ClientValidateMoveResourcesResponse], errResp azfake.ErrorResponder) } @@ -125,47 +122,66 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "Client.CheckExistence": - resp, err = s.dispatchCheckExistence(req) - case "Client.CheckExistenceByID": - resp, err = s.dispatchCheckExistenceByID(req) - case "Client.BeginCreateOrUpdate": - resp, err = s.dispatchBeginCreateOrUpdate(req) - case "Client.BeginCreateOrUpdateByID": - resp, err = s.dispatchBeginCreateOrUpdateByID(req) - case "Client.BeginDelete": - resp, err = s.dispatchBeginDelete(req) - case "Client.BeginDeleteByID": - resp, err = s.dispatchBeginDeleteByID(req) - case "Client.Get": - resp, err = s.dispatchGet(req) - case "Client.GetByID": - resp, err = s.dispatchGetByID(req) - case "Client.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "Client.NewListByResourceGroupPager": - resp, err = s.dispatchNewListByResourceGroupPager(req) - case "Client.BeginMoveResources": - resp, err = s.dispatchBeginMoveResources(req) - case "Client.BeginUpdate": - resp, err = s.dispatchBeginUpdate(req) - case "Client.BeginUpdateByID": - resp, err = s.dispatchBeginUpdateByID(req) - case "Client.BeginValidateMoveResources": - resp, err = s.dispatchBeginValidateMoveResources(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return s.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.CheckExistence": + res.resp, res.err = s.dispatchCheckExistence(req) + case "Client.CheckExistenceByID": + res.resp, res.err = s.dispatchCheckExistenceByID(req) + case "Client.BeginCreateOrUpdate": + res.resp, res.err = s.dispatchBeginCreateOrUpdate(req) + case "Client.BeginCreateOrUpdateByID": + res.resp, res.err = s.dispatchBeginCreateOrUpdateByID(req) + case "Client.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "Client.BeginDeleteByID": + res.resp, res.err = s.dispatchBeginDeleteByID(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.GetByID": + res.resp, res.err = s.dispatchGetByID(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "Client.BeginMoveResources": + res.resp, res.err = s.dispatchBeginMoveResources(req) + case "Client.BeginUpdate": + res.resp, res.err = s.dispatchBeginUpdate(req) + case "Client.BeginUpdateByID": + res.resp, res.err = s.dispatchBeginUpdateByID(req) + case "Client.BeginValidateMoveResources": + res.resp, res.err = s.dispatchBeginValidateMoveResources(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServerTransport) dispatchCheckExistence(req *http.Request) (*http.Response, error) { @@ -725,9 +741,9 @@ func (s *ServerTransport) dispatchBeginMoveResources(req *http.Request) (*http.R return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { s.beginMoveResources.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginMoveResources) { s.beginMoveResources.remove(req) @@ -883,9 +899,9 @@ func (s *ServerTransport) dispatchBeginValidateMoveResources(req *http.Request) return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { s.beginValidateMoveResources.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginValidateMoveResources) { s.beginValidateMoveResources.remove(req) @@ -893,3 +909,9 @@ func (s *ServerTransport) dispatchBeginValidateMoveResources(req *http.Request) return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armresources/fake/server_factory.go b/sdk/resourcemanager/resources/armresources/fake/server_factory.go index 9b10cbd19f1d..bd4d3211acc4 100644 --- a/sdk/resourcemanager/resources/armresources/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armresources/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,14 +16,23 @@ import ( // ServerFactory is a fake server for instances of the armresources.ClientFactory type. type ServerFactory struct { - Server Server - DeploymentOperationsServer DeploymentOperationsServer - DeploymentsServer DeploymentsServer - OperationsServer OperationsServer + // Server contains the fakes for client Client + Server Server + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // ProviderResourceTypesServer contains the fakes for client ProviderResourceTypesClient ProviderResourceTypesServer ProviderResourceTypesServer - ProvidersServer ProvidersServer - ResourceGroupsServer ResourceGroupsServer - TagsServer TagsServer + + // ProvidersServer contains the fakes for client ProvidersClient + ProvidersServer ProvidersServer + + // ResourceGroupsServer contains the fakes for client ResourceGroupsClient + ResourceGroupsServer ResourceGroupsServer + + // TagsServer contains the fakes for client TagsClient + TagsServer TagsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -44,8 +50,6 @@ type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex trServer *ServerTransport - trDeploymentOperationsServer *DeploymentOperationsServerTransport - trDeploymentsServer *DeploymentsServerTransport trOperationsServer *OperationsServerTransport trProviderResourceTypesServer *ProviderResourceTypesServerTransport trProvidersServer *ProvidersServerTransport @@ -69,14 +73,6 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "Client": initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) resp, err = s.trServer.Do(req) - case "DeploymentOperationsClient": - initServer(s, &s.trDeploymentOperationsServer, func() *DeploymentOperationsServerTransport { - return NewDeploymentOperationsServerTransport(&s.srv.DeploymentOperationsServer) - }) - resp, err = s.trDeploymentOperationsServer.Do(req) - case "DeploymentsClient": - initServer(s, &s.trDeploymentsServer, func() *DeploymentsServerTransport { return NewDeploymentsServerTransport(&s.srv.DeploymentsServer) }) - resp, err = s.trDeploymentsServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) diff --git a/sdk/resourcemanager/resources/armresources/fake/tags_server.go b/sdk/resourcemanager/resources/armresources/fake/tags_server.go index 5c9395d85920..e05ee6a81c87 100644 --- a/sdk/resourcemanager/resources/armresources/fake/tags_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/tags_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "net/http" "net/url" "regexp" @@ -41,7 +38,7 @@ type TagsServer struct { Delete func(ctx context.Context, tagName string, options *armresources.TagsClientDeleteOptions) (resp azfake.Responder[armresources.TagsClientDeleteResponse], errResp azfake.ErrorResponder) // BeginDeleteAtScope is the fake for method TagsClient.BeginDeleteAtScope - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent BeginDeleteAtScope func(ctx context.Context, scope string, options *armresources.TagsClientBeginDeleteAtScopeOptions) (resp azfake.PollerResponder[armresources.TagsClientDeleteAtScopeResponse], errResp azfake.ErrorResponder) // DeleteValue is the fake for method TagsClient.DeleteValue @@ -92,37 +89,56 @@ func (t *TagsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "TagsClient.CreateOrUpdate": - resp, err = t.dispatchCreateOrUpdate(req) - case "TagsClient.BeginCreateOrUpdateAtScope": - resp, err = t.dispatchBeginCreateOrUpdateAtScope(req) - case "TagsClient.CreateOrUpdateValue": - resp, err = t.dispatchCreateOrUpdateValue(req) - case "TagsClient.Delete": - resp, err = t.dispatchDelete(req) - case "TagsClient.BeginDeleteAtScope": - resp, err = t.dispatchBeginDeleteAtScope(req) - case "TagsClient.DeleteValue": - resp, err = t.dispatchDeleteValue(req) - case "TagsClient.GetAtScope": - resp, err = t.dispatchGetAtScope(req) - case "TagsClient.NewListPager": - resp, err = t.dispatchNewListPager(req) - case "TagsClient.BeginUpdateAtScope": - resp, err = t.dispatchBeginUpdateAtScope(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return t.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (t *TagsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - return resp, nil + go func() { + var intercepted bool + var res result + if tagsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tagsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TagsClient.CreateOrUpdate": + res.resp, res.err = t.dispatchCreateOrUpdate(req) + case "TagsClient.BeginCreateOrUpdateAtScope": + res.resp, res.err = t.dispatchBeginCreateOrUpdateAtScope(req) + case "TagsClient.CreateOrUpdateValue": + res.resp, res.err = t.dispatchCreateOrUpdateValue(req) + case "TagsClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TagsClient.BeginDeleteAtScope": + res.resp, res.err = t.dispatchBeginDeleteAtScope(req) + case "TagsClient.DeleteValue": + res.resp, res.err = t.dispatchDeleteValue(req) + case "TagsClient.GetAtScope": + res.resp, res.err = t.dispatchGetAtScope(req) + case "TagsClient.NewListPager": + res.resp, res.err = t.dispatchNewListPager(req) + case "TagsClient.BeginUpdateAtScope": + res.resp, res.err = t.dispatchBeginUpdateAtScope(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TagsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -289,9 +305,9 @@ func (t *TagsServerTransport) dispatchBeginDeleteAtScope(req *http.Request) (*ht return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { t.beginDeleteAtScope.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDeleteAtScope) { t.beginDeleteAtScope.remove(req) @@ -438,3 +454,9 @@ func (t *TagsServerTransport) dispatchBeginUpdateAtScope(req *http.Request) (*ht return resp, nil } + +// set this to conditionally intercept incoming requests to TagsServerTransport +var tagsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armresources/go.mod b/sdk/resourcemanager/resources/armresources/go.mod index 784ba9fbef28..248a9e0375eb 100644 --- a/sdk/resourcemanager/resources/armresources/go.mod +++ b/sdk/resourcemanager/resources/armresources/go.mod @@ -1,10 +1,9 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2 +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3 go 1.23.0 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.2.0 @@ -13,6 +12,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.2 // indirect diff --git a/sdk/resourcemanager/resources/armresources/models.go b/sdk/resourcemanager/resources/armresources/models.go index 383387672f86..9747a028a588 100644 --- a/sdk/resourcemanager/resources/armresources/models.go +++ b/sdk/resourcemanager/resources/armresources/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -74,357 +71,6 @@ type AliasPattern struct { Variable *string } -// BasicDependency - Deployment dependency information. -type BasicDependency struct { - // The ID of the dependency. - ID *string - - // The dependency resource name. - ResourceName *string - - // The dependency resource type. - ResourceType *string -} - -// DebugSetting - The debug setting. -type DebugSetting struct { - // Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, - // or both requestContent and responseContent separated by a comma. The default is - // none. When setting this value, carefully consider the type of information you are passing in during deployment. By logging - // information about the request or response, you could potentially expose - // sensitive data that is retrieved through the deployment operations. - DetailLevel *string -} - -// Dependency - Deployment dependency information. -type Dependency struct { - // The list of dependencies. - DependsOn []*BasicDependency - - // The ID of the dependency. - ID *string - - // The dependency resource name. - ResourceName *string - - // The dependency resource type. - ResourceType *string -} - -// Deployment operation parameters. -type Deployment struct { - // REQUIRED; The deployment properties. - Properties *DeploymentProperties - - // The location to store the deployment data. - Location *string - - // Deployment tags - Tags map[string]*string -} - -type DeploymentDiagnosticsDefinition struct { - // READ-ONLY; The error code. - Code *string - - // READ-ONLY; Denotes the additional response level. - Level *Level - - // READ-ONLY; The error message. - Message *string - - // READ-ONLY; The error additional info. - AdditionalInfo []*ErrorAdditionalInfo - - // READ-ONLY; The error target. - Target *string -} - -// DeploymentExportResult - The deployment export result. -type DeploymentExportResult struct { - // The template content. - Template any -} - -// DeploymentExtended - Deployment information. -type DeploymentExtended struct { - // the location of the deployment. - Location *string - - // Deployment properties. - Properties *DeploymentPropertiesExtended - - // Deployment tags - Tags map[string]*string - - // READ-ONLY; The ID of the deployment. - ID *string - - // READ-ONLY; The name of the deployment. - Name *string - - // READ-ONLY; The type of the deployment. - Type *string -} - -// DeploymentExtendedFilter - Deployment filter. -type DeploymentExtendedFilter struct { - // The provisioning state. - ProvisioningState *string -} - -// DeploymentListResult - List of deployments. -type DeploymentListResult struct { - // An array of deployments. - Value []*DeploymentExtended - - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string -} - -// DeploymentOperation - Deployment operation information. -type DeploymentOperation struct { - // Deployment properties. - Properties *DeploymentOperationProperties - - // READ-ONLY; Full deployment operation ID. - ID *string - - // READ-ONLY; Deployment operation ID. - OperationID *string -} - -// DeploymentOperationProperties - Deployment operation properties. -type DeploymentOperationProperties struct { - // READ-ONLY; The duration of the operation. - Duration *string - - // READ-ONLY; The name of the current provisioning operation. - ProvisioningOperation *ProvisioningOperation - - // READ-ONLY; The state of the provisioning. - ProvisioningState *string - - // READ-ONLY; The HTTP request message. - Request *HTTPMessage - - // READ-ONLY; The HTTP response message. - Response *HTTPMessage - - // READ-ONLY; Deployment operation service request id. - ServiceRequestID *string - - // READ-ONLY; Operation status code from the resource provider. This property may not be set if a response has not yet been - // received. - StatusCode *string - - // READ-ONLY; Operation status message from the resource provider. This property is optional. It will only be provided if - // an error was received from the resource provider. - StatusMessage *StatusMessage - - // READ-ONLY; The target resource. - TargetResource *TargetResource - - // READ-ONLY; The date and time of the operation. - Timestamp *time.Time -} - -// DeploymentOperationsListResult - List of deployment operations. -type DeploymentOperationsListResult struct { - // An array of deployment operations. - Value []*DeploymentOperation - - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string -} - -// DeploymentParameter - Deployment parameter for the template. -type DeploymentParameter struct { - // Azure Key Vault parameter reference. - Reference *KeyVaultParameterReference - - // Input value to the parameter . - Value any -} - -// DeploymentProperties - Deployment properties. -type DeploymentProperties struct { - // REQUIRED; The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, - // resources are deployed without deleting existing resources that are not included in - // the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included - // in the template are deleted. Be careful when using Complete mode as you may - // unintentionally delete resources. - Mode *DeploymentMode - - // The debug setting of the deployment. - DebugSetting *DebugSetting - - // Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable - // to nested templates. If not specified, default value is outer. - ExpressionEvaluationOptions *ExpressionEvaluationOptions - - // The deployment on error behavior. - OnErrorDeployment *OnErrorDeployment - - // Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide - // the parameter values directly in the request rather than link to an existing - // parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or - // a well formed JSON string. - Parameters map[string]*DeploymentParameter - - // The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink - // property or the parameters property, but not both. - ParametersLink *ParametersLink - - // The template content. You use this element when you want to pass the template syntax directly in the request rather than - // link to an existing template. It can be a JObject or well-formed JSON string. - // Use either the templateLink property or the template property, but not both. - Template any - - // The URI of the template. Use either the templateLink property or the template property, but not both. - TemplateLink *TemplateLink - - // The validation level of the deployment - ValidationLevel *ValidationLevel -} - -// DeploymentPropertiesExtended - Deployment properties with additional details. -type DeploymentPropertiesExtended struct { - // The validation level of the deployment - ValidationLevel *ValidationLevel - - // READ-ONLY; The correlation ID of the deployment. - CorrelationID *string - - // READ-ONLY; The debug setting of the deployment. - DebugSetting *DebugSetting - - // READ-ONLY; The list of deployment dependencies. - Dependencies []*Dependency - - // READ-ONLY; Contains diagnostic information collected during validation process. - Diagnostics []*DeploymentDiagnosticsDefinition - - // READ-ONLY; The duration of the template deployment. - Duration *string - - // READ-ONLY; The deployment error. - Error *ErrorResponse - - // READ-ONLY; The deployment mode. Possible values are Incremental and Complete. - Mode *DeploymentMode - - // READ-ONLY; The deployment on error behavior. - OnErrorDeployment *OnErrorDeploymentExtended - - // READ-ONLY; Array of provisioned resources. - OutputResources []*ResourceReference - - // READ-ONLY; Key/value pairs that represent deployment output. - Outputs any - - // READ-ONLY; Deployment parameters. - Parameters any - - // READ-ONLY; The URI referencing the parameters. - ParametersLink *ParametersLink - - // READ-ONLY; The list of resource providers needed for the deployment. - Providers []*Provider - - // READ-ONLY; Denotes the state of provisioning. - ProvisioningState *ProvisioningState - - // READ-ONLY; The hash produced for the template. - TemplateHash *string - - // READ-ONLY; The URI referencing the template. - TemplateLink *TemplateLink - - // READ-ONLY; The timestamp of the template deployment. - Timestamp *time.Time - - // READ-ONLY; Array of validated resources. - ValidatedResources []*ResourceReference -} - -// DeploymentValidateResult - Information from validate template deployment response. -type DeploymentValidateResult struct { - // The template deployment properties. - Properties *DeploymentPropertiesExtended - - // READ-ONLY; The deployment validation error. - Error *ErrorResponse - - // READ-ONLY; The ID of the deployment. - ID *string - - // READ-ONLY; The name of the deployment. - Name *string - - // READ-ONLY; The type of the deployment. - Type *string -} - -// DeploymentWhatIf - Deployment What-if operation parameters. -type DeploymentWhatIf struct { - // REQUIRED; The deployment properties. - Properties *DeploymentWhatIfProperties - - // The location to store the deployment data. - Location *string -} - -// DeploymentWhatIfProperties - Deployment What-if properties. -type DeploymentWhatIfProperties struct { - // REQUIRED; The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, - // resources are deployed without deleting existing resources that are not included in - // the template. In Complete mode, resources are deployed and existing resources in the resource group that are not included - // in the template are deleted. Be careful when using Complete mode as you may - // unintentionally delete resources. - Mode *DeploymentMode - - // The debug setting of the deployment. - DebugSetting *DebugSetting - - // Specifies whether template expressions are evaluated within the scope of the parent template or nested template. Only applicable - // to nested templates. If not specified, default value is outer. - ExpressionEvaluationOptions *ExpressionEvaluationOptions - - // The deployment on error behavior. - OnErrorDeployment *OnErrorDeployment - - // Name and value pairs that define the deployment parameters for the template. You use this element when you want to provide - // the parameter values directly in the request rather than link to an existing - // parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or - // a well formed JSON string. - Parameters map[string]*DeploymentParameter - - // The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink - // property or the parameters property, but not both. - ParametersLink *ParametersLink - - // The template content. You use this element when you want to pass the template syntax directly in the request rather than - // link to an existing template. It can be a JObject or well-formed JSON string. - // Use either the templateLink property or the template property, but not both. - Template any - - // The URI of the template. Use either the templateLink property or the template property, but not both. - TemplateLink *TemplateLink - - // The validation level of the deployment - ValidationLevel *ValidationLevel - - // Optional What-If operation settings. - WhatIfSettings *DeploymentWhatIfSettings -} - -// DeploymentWhatIfSettings - Deployment What-If operation settings. -type DeploymentWhatIfSettings struct { - // The format of the What-If results - ResultFormat *WhatIfResultFormat -} - // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. @@ -467,13 +113,6 @@ type ExportTemplateRequest struct { Resources []*string } -// ExpressionEvaluationOptions - Specifies whether template expressions are evaluated within the scope of the parent template -// or nested template. -type ExpressionEvaluationOptions struct { - // The scope to be used for evaluation of parameters, variables and functions in a nested template. - Scope *ExpressionEvaluationOptionsScopeType -} - // ExtendedLocation - Resource extended location. type ExtendedLocation struct { // The extended location name. @@ -582,12 +221,6 @@ type GenericResourceFilter struct { Tagvalue *string } -// HTTPMessage - HTTP message. -type HTTPMessage struct { - // HTTP message content. - Content any -} - // Identity for the resource. type Identity struct { // The identity type. @@ -613,24 +246,6 @@ type IdentityUserAssignedIdentitiesValue struct { PrincipalID *string } -// KeyVaultParameterReference - Azure Key Vault parameter reference. -type KeyVaultParameterReference struct { - // REQUIRED; Azure Key Vault reference. - KeyVault *KeyVaultReference - - // REQUIRED; Azure Key Vault secret name. - SecretName *string - - // Azure Key Vault secret version. - SecretVersion *string -} - -// KeyVaultReference - Azure Key Vault reference. -type KeyVaultReference struct { - // REQUIRED; Azure Key Vault resource id. - ID *string -} - // MoveInfo - Parameters of move resources. type MoveInfo struct { // The IDs of the resources. @@ -640,27 +255,6 @@ type MoveInfo struct { TargetResourceGroup *string } -// OnErrorDeployment - Deployment on error behavior. -type OnErrorDeployment struct { - // The deployment to be used on error case. - DeploymentName *string - - // The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. - Type *OnErrorDeploymentType -} - -// OnErrorDeploymentExtended - Deployment on error behavior with additional details. -type OnErrorDeploymentExtended struct { - // The deployment to be used on error case. - DeploymentName *string - - // The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. - Type *OnErrorDeploymentType - - // READ-ONLY; The state of the provisioning for the on error deployment. - ProvisioningState *string -} - // Operation - Microsoft.Resources operation type Operation struct { // The object that represents the operation. @@ -695,15 +289,6 @@ type OperationListResult struct { Value []*Operation } -// ParametersLink - Entity representing the reference to the deployment parameters. -type ParametersLink struct { - // REQUIRED; The URI of the parameters file. - URI *string - - // If included, must match the ContentVersion in the template. - ContentVersion *string -} - // Permission - Role definition permissions. type Permission struct { // Allowed actions. @@ -979,12 +564,6 @@ type ResourceProviderOperationDisplayProperties struct { Resource *string } -// ResourceReference - The resource Id model. -type ResourceReference struct { - // READ-ONLY; The fully qualified resource Id. - ID *string -} - // RoleDefinition - Role definition properties. type RoleDefinition struct { // The role definition ID. @@ -1024,36 +603,6 @@ type SKU struct { Tier *string } -// ScopedDeployment - Deployment operation parameters. -type ScopedDeployment struct { - // REQUIRED; The location to store the deployment data. - Location *string - - // REQUIRED; The deployment properties. - Properties *DeploymentProperties - - // Deployment tags - Tags map[string]*string -} - -// ScopedDeploymentWhatIf - Deployment What-if operation parameters. -type ScopedDeploymentWhatIf struct { - // REQUIRED; The location to store the deployment data. - Location *string - - // REQUIRED; The deployment properties. - Properties *DeploymentWhatIfProperties -} - -// StatusMessage - Operation status message object. -type StatusMessage struct { - // The error reported by the operation. - Error *ErrorResponse - - // Status of the deployment operation. - Status *string -} - // SubResource - Sub-resource. type SubResource struct { // Resource ID @@ -1136,123 +685,6 @@ type TagsResource struct { Type *string } -// TargetResource - Target resource. -type TargetResource struct { - // The ID of the resource. - ID *string - - // The name of the resource. - ResourceName *string - - // The type of the resource. - ResourceType *string -} - -// TemplateHashResult - Result of the request to calculate template hash. It contains a string of minified template and its -// hash. -type TemplateHashResult struct { - // The minified template string. - MinifiedTemplate *string - - // The template hash. - TemplateHash *string -} - -// TemplateLink - Entity representing the reference to the template. -type TemplateLink struct { - // If included, must match the ContentVersion in the template. - ContentVersion *string - - // The resource id of a Template Spec. Use either the id or uri property, but not both. - ID *string - - // The query string (for example, a SAS token) to be used with the templateLink URI. - QueryString *string - - // The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template - // was linked with a TemplateSpec, this will reference an artifact in the - // TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath - // URIs - RelativePath *string - - // The URI of the template to deploy. Use either the uri or id property, but not both. - URI *string -} - -// WhatIfChange - Information about a single resource change predicted by What-If operation. -type WhatIfChange struct { - // REQUIRED; Type of change that will be made to the resource when the deployment is executed. - ChangeType *ChangeType - - // REQUIRED; Resource ID - ResourceID *string - - // The predicted snapshot of the resource after the deployment is executed. - After any - - // The snapshot of the resource before the deployment is executed. - Before any - - // The predicted changes to resource properties. - Delta []*WhatIfPropertyChange - - // The resource id of the Deployment responsible for this change. - DeploymentID *string - - // A subset of properties that uniquely identify a Bicep extensible resource because it lacks a resource id like an Azure - // resource has. - Identifiers any - - // The symbolic name of the resource responsible for this change. - SymbolicName *string - - // The explanation about why the resource is unsupported by What-If. - UnsupportedReason *string -} - -// WhatIfOperationProperties - Deployment operation properties. -type WhatIfOperationProperties struct { - // List of resource changes predicted by What-If operation. - Changes []*WhatIfChange - - // List of resource changes predicted by What-If operation. - PotentialChanges []*WhatIfChange - - // READ-ONLY; List of resource diagnostics detected by What-If operation. - Diagnostics []*DeploymentDiagnosticsDefinition -} - -// WhatIfOperationResult - Result of the What-If operation. Contains a list of predicted changes and a URL link to get to -// the next set of results. -type WhatIfOperationResult struct { - // Error when What-If operation fails. - Error *ErrorResponse - - // What-If operation properties. - Properties *WhatIfOperationProperties - - // Status of the What-If operation. - Status *string -} - -// WhatIfPropertyChange - The predicted change to the resource property. -type WhatIfPropertyChange struct { - // REQUIRED; The path of the property. - Path *string - - // REQUIRED; The type of property change. - PropertyChangeType *PropertyChangeType - - // The value of the property after the deployment is executed. - After any - - // The value of the property before the deployment is executed. - Before any - - // Nested property changes. - Children []*WhatIfPropertyChange -} - type ZoneMapping struct { // The location of the zone mapping. Location *string diff --git a/sdk/resourcemanager/resources/armresources/models_serde.go b/sdk/resourcemanager/resources/armresources/models_serde.go index b7ce40ebba22..74cd2f05e8d2 100644 --- a/sdk/resourcemanager/resources/armresources/models_serde.go +++ b/sdk/resourcemanager/resources/armresources/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -198,1316 +195,407 @@ func (a *AliasPattern) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type BasicDependency. -func (b BasicDependency) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", b.ID) - populate(objectMap, "resourceName", b.ResourceName) - populate(objectMap, "resourceType", b.ResourceType) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicDependency. -func (b *BasicDependency) UnmarshalJSON(data []byte) error { +// 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", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &b.ID) - delete(rawMsg, key) - case "resourceName": - err = unpopulate(val, "ResourceName", &b.ResourceName) + case "info": + err = unpopulate(val, "Info", &e.Info) delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &b.ResourceType) + case "type": + err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DebugSetting. -func (d DebugSetting) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "detailLevel", d.DetailLevel) + 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 DebugSetting. -func (d *DebugSetting) UnmarshalJSON(data []byte) error { +// 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", d, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "detailLevel": - err = unpopulate(val, "DetailLevel", &d.DetailLevel) + 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", d, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Dependency. -func (d Dependency) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExportTemplateRequest. +func (e ExportTemplateRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "dependsOn", d.DependsOn) - populate(objectMap, "id", d.ID) - populate(objectMap, "resourceName", d.ResourceName) - populate(objectMap, "resourceType", d.ResourceType) + populate(objectMap, "options", e.Options) + populate(objectMap, "outputFormat", e.OutputFormat) + populate(objectMap, "resources", e.Resources) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Dependency. -func (d *Dependency) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportTemplateRequest. +func (e *ExportTemplateRequest) 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) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "dependsOn": - err = unpopulate(val, "DependsOn", &d.DependsOn) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &d.ID) + case "options": + err = unpopulate(val, "Options", &e.Options) delete(rawMsg, key) - case "resourceName": - err = unpopulate(val, "ResourceName", &d.ResourceName) + case "outputFormat": + err = unpopulate(val, "OutputFormat", &e.OutputFormat) delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &d.ResourceType) + case "resources": + err = unpopulate(val, "Resources", &e.Resources) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Deployment. -func (d Deployment) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtendedLocation. +func (e ExtendedLocation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "location", d.Location) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "tags", d.Tags) + populate(objectMap, "name", e.Name) + populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Deployment. -func (d *Deployment) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedLocation. +func (e *ExtendedLocation) 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) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "location": - err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) + case "name": + err = unpopulate(val, "Name", &e.Name) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &d.Tags) + case "type": + err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentDiagnosticsDefinition. -func (d DeploymentDiagnosticsDefinition) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GenericResource. +func (g GenericResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "additionalInfo", d.AdditionalInfo) - populate(objectMap, "code", d.Code) - populate(objectMap, "level", d.Level) - populate(objectMap, "message", d.Message) - populate(objectMap, "target", d.Target) + populate(objectMap, "extendedLocation", g.ExtendedLocation) + populate(objectMap, "id", g.ID) + populate(objectMap, "identity", g.Identity) + populate(objectMap, "kind", g.Kind) + populate(objectMap, "location", g.Location) + populate(objectMap, "managedBy", g.ManagedBy) + populate(objectMap, "name", g.Name) + populate(objectMap, "plan", g.Plan) + populateAny(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentDiagnosticsDefinition. -func (d *DeploymentDiagnosticsDefinition) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResource. +func (g *GenericResource) 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) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } for key, val := range rawMsg { var err error switch key { - case "additionalInfo": - err = unpopulate(val, "AdditionalInfo", &d.AdditionalInfo) + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &g.ExtendedLocation) delete(rawMsg, key) - case "code": - err = unpopulate(val, "Code", &d.Code) + case "id": + err = unpopulate(val, "ID", &g.ID) delete(rawMsg, key) - case "level": - err = unpopulate(val, "Level", &d.Level) + case "identity": + err = unpopulate(val, "Identity", &g.Identity) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &d.Message) + case "kind": + err = unpopulate(val, "Kind", &g.Kind) delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &d.Target) + case "location": + err = unpopulate(val, "Location", &g.Location) 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 DeploymentExportResult. -func (d DeploymentExportResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateAny(objectMap, "template", d.Template) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExportResult. -func (d *DeploymentExportResult) 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 "template": - err = unpopulate(val, "Template", &d.Template) + case "managedBy": + err = unpopulate(val, "ManagedBy", &g.ManagedBy) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &g.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentExtended. -func (d DeploymentExtended) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GenericResourceExpanded. +func (g GenericResourceExpanded) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) + populateDateTimeRFC3339(objectMap, "changedTime", g.ChangedTime) + populateDateTimeRFC3339(objectMap, "createdTime", g.CreatedTime) + populate(objectMap, "extendedLocation", g.ExtendedLocation) + populate(objectMap, "id", g.ID) + populate(objectMap, "identity", g.Identity) + populate(objectMap, "kind", g.Kind) + populate(objectMap, "location", g.Location) + populate(objectMap, "managedBy", g.ManagedBy) + populate(objectMap, "name", g.Name) + populate(objectMap, "plan", g.Plan) + populateAny(objectMap, "properties", g.Properties) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExtended. -func (d *DeploymentExtended) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResourceExpanded. +func (g *GenericResourceExpanded) 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) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } for key, val := range rawMsg { var err error switch key { + case "changedTime": + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &g.ChangedTime) + delete(rawMsg, key) + case "createdTime": + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &g.CreatedTime) + delete(rawMsg, key) + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &g.ExtendedLocation) + delete(rawMsg, key) case "id": - err = unpopulate(val, "ID", &d.ID) + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &g.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &g.Kind) delete(rawMsg, key) case "location": - err = unpopulate(val, "Location", &d.Location) + err = unpopulate(val, "Location", &g.Location) + delete(rawMsg, key) + case "managedBy": + err = unpopulate(val, "ManagedBy", &g.ManagedBy) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &d.Name) + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &g.Plan) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &d.Properties) + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) delete(rawMsg, key) case "tags": - err = unpopulate(val, "Tags", &d.Tags) + err = unpopulate(val, "Tags", &g.Tags) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &d.Type) + err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentExtendedFilter. -func (d DeploymentExtendedFilter) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GenericResourceFilter. +func (g GenericResourceFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "resourceType", g.ResourceType) + populate(objectMap, "tagname", g.Tagname) + populate(objectMap, "tagvalue", g.Tagvalue) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentExtendedFilter. -func (d *DeploymentExtendedFilter) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResourceFilter. +func (g *GenericResourceFilter) 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) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } for key, val := range rawMsg { var err error switch key { - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + case "resourceType": + err = unpopulate(val, "ResourceType", &g.ResourceType) + delete(rawMsg, key) + case "tagname": + err = unpopulate(val, "Tagname", &g.Tagname) + delete(rawMsg, key) + case "tagvalue": + err = unpopulate(val, "Tagvalue", &g.Tagvalue) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", g, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentListResult. -func (d DeploymentListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", d.NextLink) - populate(objectMap, "value", d.Value) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentListResult. -func (d *DeploymentListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) 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) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentOperation. -func (d DeploymentOperation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type IdentityUserAssignedIdentitiesValue. +func (i IdentityUserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", d.ID) - populate(objectMap, "operationId", d.OperationID) - populate(objectMap, "properties", d.Properties) + populate(objectMap, "clientId", i.ClientID) + populate(objectMap, "principalId", i.PrincipalID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentOperation. -func (d *DeploymentOperation) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentityUserAssignedIdentitiesValue. +func (i *IdentityUserAssignedIdentitiesValue) 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) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "operationId": - err = unpopulate(val, "OperationID", &d.OperationID) + case "clientId": + err = unpopulate(val, "ClientID", &i.ClientID) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentOperationProperties. -func (d DeploymentOperationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "duration", d.Duration) - populate(objectMap, "provisioningOperation", d.ProvisioningOperation) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "request", d.Request) - populate(objectMap, "response", d.Response) - populate(objectMap, "serviceRequestId", d.ServiceRequestID) - populate(objectMap, "statusCode", d.StatusCode) - populate(objectMap, "statusMessage", d.StatusMessage) - populate(objectMap, "targetResource", d.TargetResource) - populateDateTimeRFC3339(objectMap, "timestamp", d.Timestamp) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentOperationProperties. -func (d *DeploymentOperationProperties) 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 "duration": - err = unpopulate(val, "Duration", &d.Duration) - delete(rawMsg, key) - case "provisioningOperation": - err = unpopulate(val, "ProvisioningOperation", &d.ProvisioningOperation) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) - case "request": - err = unpopulate(val, "Request", &d.Request) - delete(rawMsg, key) - case "response": - err = unpopulate(val, "Response", &d.Response) - delete(rawMsg, key) - case "serviceRequestId": - err = unpopulate(val, "ServiceRequestID", &d.ServiceRequestID) - delete(rawMsg, key) - case "statusCode": - err = unpopulate(val, "StatusCode", &d.StatusCode) - delete(rawMsg, key) - case "statusMessage": - err = unpopulate(val, "StatusMessage", &d.StatusMessage) - delete(rawMsg, key) - case "targetResource": - err = unpopulate(val, "TargetResource", &d.TargetResource) - delete(rawMsg, key) - case "timestamp": - err = unpopulateDateTimeRFC3339(val, "Timestamp", &d.Timestamp) - 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 DeploymentOperationsListResult. -func (d DeploymentOperationsListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", d.NextLink) - populate(objectMap, "value", d.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentOperationsListResult. -func (d *DeploymentOperationsListResult) 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 "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) - 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 DeploymentParameter. -func (d DeploymentParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "reference", d.Reference) - populateAny(objectMap, "value", d.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentParameter. -func (d *DeploymentParameter) 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 "reference": - err = unpopulate(val, "Reference", &d.Reference) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) - 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 DeploymentProperties. -func (d DeploymentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "debugSetting", d.DebugSetting) - populate(objectMap, "expressionEvaluationOptions", d.ExpressionEvaluationOptions) - populate(objectMap, "mode", d.Mode) - populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) - populate(objectMap, "parameters", d.Parameters) - populate(objectMap, "parametersLink", d.ParametersLink) - populateAny(objectMap, "template", d.Template) - populate(objectMap, "templateLink", d.TemplateLink) - populate(objectMap, "validationLevel", d.ValidationLevel) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentProperties. -func (d *DeploymentProperties) 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 "debugSetting": - err = unpopulate(val, "DebugSetting", &d.DebugSetting) - delete(rawMsg, key) - case "expressionEvaluationOptions": - err = unpopulate(val, "ExpressionEvaluationOptions", &d.ExpressionEvaluationOptions) - delete(rawMsg, key) - case "mode": - err = unpopulate(val, "Mode", &d.Mode) - delete(rawMsg, key) - case "onErrorDeployment": - err = unpopulate(val, "OnErrorDeployment", &d.OnErrorDeployment) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &d.Parameters) - delete(rawMsg, key) - case "parametersLink": - err = unpopulate(val, "ParametersLink", &d.ParametersLink) - delete(rawMsg, key) - case "template": - err = unpopulate(val, "Template", &d.Template) - delete(rawMsg, key) - case "templateLink": - err = unpopulate(val, "TemplateLink", &d.TemplateLink) - delete(rawMsg, key) - case "validationLevel": - err = unpopulate(val, "ValidationLevel", &d.ValidationLevel) - 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 DeploymentPropertiesExtended. -func (d DeploymentPropertiesExtended) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "correlationId", d.CorrelationID) - populate(objectMap, "debugSetting", d.DebugSetting) - populate(objectMap, "dependencies", d.Dependencies) - populate(objectMap, "diagnostics", d.Diagnostics) - populate(objectMap, "duration", d.Duration) - populate(objectMap, "error", d.Error) - populate(objectMap, "mode", d.Mode) - populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) - populate(objectMap, "outputResources", d.OutputResources) - populateAny(objectMap, "outputs", d.Outputs) - populateAny(objectMap, "parameters", d.Parameters) - populate(objectMap, "parametersLink", d.ParametersLink) - populate(objectMap, "providers", d.Providers) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "templateHash", d.TemplateHash) - populate(objectMap, "templateLink", d.TemplateLink) - populateDateTimeRFC3339(objectMap, "timestamp", d.Timestamp) - populate(objectMap, "validatedResources", d.ValidatedResources) - populate(objectMap, "validationLevel", d.ValidationLevel) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentPropertiesExtended. -func (d *DeploymentPropertiesExtended) 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 "correlationId": - err = unpopulate(val, "CorrelationID", &d.CorrelationID) - delete(rawMsg, key) - case "debugSetting": - err = unpopulate(val, "DebugSetting", &d.DebugSetting) - delete(rawMsg, key) - case "dependencies": - err = unpopulate(val, "Dependencies", &d.Dependencies) - delete(rawMsg, key) - case "diagnostics": - err = unpopulate(val, "Diagnostics", &d.Diagnostics) - delete(rawMsg, key) - case "duration": - err = unpopulate(val, "Duration", &d.Duration) - delete(rawMsg, key) - case "error": - err = unpopulate(val, "Error", &d.Error) - delete(rawMsg, key) - case "mode": - err = unpopulate(val, "Mode", &d.Mode) - delete(rawMsg, key) - case "onErrorDeployment": - err = unpopulate(val, "OnErrorDeployment", &d.OnErrorDeployment) - delete(rawMsg, key) - case "outputResources": - err = unpopulate(val, "OutputResources", &d.OutputResources) - delete(rawMsg, key) - case "outputs": - err = unpopulate(val, "Outputs", &d.Outputs) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &d.Parameters) - delete(rawMsg, key) - case "parametersLink": - err = unpopulate(val, "ParametersLink", &d.ParametersLink) - delete(rawMsg, key) - case "providers": - err = unpopulate(val, "Providers", &d.Providers) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) - case "templateHash": - err = unpopulate(val, "TemplateHash", &d.TemplateHash) - delete(rawMsg, key) - case "templateLink": - err = unpopulate(val, "TemplateLink", &d.TemplateLink) - delete(rawMsg, key) - case "timestamp": - err = unpopulateDateTimeRFC3339(val, "Timestamp", &d.Timestamp) - delete(rawMsg, key) - case "validatedResources": - err = unpopulate(val, "ValidatedResources", &d.ValidatedResources) - delete(rawMsg, key) - case "validationLevel": - err = unpopulate(val, "ValidationLevel", &d.ValidationLevel) - 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 DeploymentValidateResult. -func (d DeploymentValidateResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", d.Error) - populate(objectMap, "id", d.ID) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentValidateResult. -func (d *DeploymentValidateResult) 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 "error": - err = unpopulate(val, "Error", &d.Error) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - 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 DeploymentWhatIf. -func (d DeploymentWhatIf) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "location", d.Location) - populate(objectMap, "properties", d.Properties) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWhatIf. -func (d *DeploymentWhatIf) 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 "location": - err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - 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 DeploymentWhatIfProperties. -func (d DeploymentWhatIfProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "debugSetting", d.DebugSetting) - populate(objectMap, "expressionEvaluationOptions", d.ExpressionEvaluationOptions) - populate(objectMap, "mode", d.Mode) - populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) - populate(objectMap, "parameters", d.Parameters) - populate(objectMap, "parametersLink", d.ParametersLink) - populateAny(objectMap, "template", d.Template) - populate(objectMap, "templateLink", d.TemplateLink) - populate(objectMap, "validationLevel", d.ValidationLevel) - populate(objectMap, "whatIfSettings", d.WhatIfSettings) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWhatIfProperties. -func (d *DeploymentWhatIfProperties) 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 "debugSetting": - err = unpopulate(val, "DebugSetting", &d.DebugSetting) - delete(rawMsg, key) - case "expressionEvaluationOptions": - err = unpopulate(val, "ExpressionEvaluationOptions", &d.ExpressionEvaluationOptions) - delete(rawMsg, key) - case "mode": - err = unpopulate(val, "Mode", &d.Mode) - delete(rawMsg, key) - case "onErrorDeployment": - err = unpopulate(val, "OnErrorDeployment", &d.OnErrorDeployment) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &d.Parameters) - delete(rawMsg, key) - case "parametersLink": - err = unpopulate(val, "ParametersLink", &d.ParametersLink) - delete(rawMsg, key) - case "template": - err = unpopulate(val, "Template", &d.Template) - delete(rawMsg, key) - case "templateLink": - err = unpopulate(val, "TemplateLink", &d.TemplateLink) - delete(rawMsg, key) - case "validationLevel": - err = unpopulate(val, "ValidationLevel", &d.ValidationLevel) - delete(rawMsg, key) - case "whatIfSettings": - err = unpopulate(val, "WhatIfSettings", &d.WhatIfSettings) - 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 DeploymentWhatIfSettings. -func (d DeploymentWhatIfSettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "resultFormat", d.ResultFormat) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentWhatIfSettings. -func (d *DeploymentWhatIfSettings) 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 "resultFormat": - err = unpopulate(val, "ResultFormat", &d.ResultFormat) - 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) - populateAny(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 ErrorResponse. -func (e ErrorResponse) 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 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 "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 ExportTemplateRequest. -func (e ExportTemplateRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "options", e.Options) - populate(objectMap, "outputFormat", e.OutputFormat) - populate(objectMap, "resources", e.Resources) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExportTemplateRequest. -func (e *ExportTemplateRequest) 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 "options": - err = unpopulate(val, "Options", &e.Options) - delete(rawMsg, key) - case "outputFormat": - err = unpopulate(val, "OutputFormat", &e.OutputFormat) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &e.Resources) - 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 ExpressionEvaluationOptions. -func (e ExpressionEvaluationOptions) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "scope", e.Scope) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExpressionEvaluationOptions. -func (e *ExpressionEvaluationOptions) 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 "scope": - err = unpopulate(val, "Scope", &e.Scope) - 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 ExtendedLocation. -func (e ExtendedLocation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "name", e.Name) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedLocation. -func (e *ExtendedLocation) 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 "name": - err = unpopulate(val, "Name", &e.Name) - 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 GenericResource. -func (g GenericResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "extendedLocation", g.ExtendedLocation) - populate(objectMap, "id", g.ID) - populate(objectMap, "identity", g.Identity) - populate(objectMap, "kind", g.Kind) - populate(objectMap, "location", g.Location) - populate(objectMap, "managedBy", g.ManagedBy) - populate(objectMap, "name", g.Name) - populate(objectMap, "plan", g.Plan) - populateAny(objectMap, "properties", g.Properties) - populate(objectMap, "sku", g.SKU) - populate(objectMap, "tags", g.Tags) - populate(objectMap, "type", g.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResource. -func (g *GenericResource) 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", g, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "extendedLocation": - err = unpopulate(val, "ExtendedLocation", &g.ExtendedLocation) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &g.ID) - delete(rawMsg, key) - case "identity": - err = unpopulate(val, "Identity", &g.Identity) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &g.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &g.Location) - delete(rawMsg, key) - case "managedBy": - err = unpopulate(val, "ManagedBy", &g.ManagedBy) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &g.Name) - delete(rawMsg, key) - case "plan": - err = unpopulate(val, "Plan", &g.Plan) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &g.Properties) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &g.SKU) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &g.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &g.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type GenericResourceExpanded. -func (g GenericResourceExpanded) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "changedTime", g.ChangedTime) - populateDateTimeRFC3339(objectMap, "createdTime", g.CreatedTime) - populate(objectMap, "extendedLocation", g.ExtendedLocation) - populate(objectMap, "id", g.ID) - populate(objectMap, "identity", g.Identity) - populate(objectMap, "kind", g.Kind) - populate(objectMap, "location", g.Location) - populate(objectMap, "managedBy", g.ManagedBy) - populate(objectMap, "name", g.Name) - populate(objectMap, "plan", g.Plan) - populateAny(objectMap, "properties", g.Properties) - populate(objectMap, "provisioningState", g.ProvisioningState) - populate(objectMap, "sku", g.SKU) - populate(objectMap, "tags", g.Tags) - populate(objectMap, "type", g.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResourceExpanded. -func (g *GenericResourceExpanded) 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", g, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "changedTime": - err = unpopulateDateTimeRFC3339(val, "ChangedTime", &g.ChangedTime) - delete(rawMsg, key) - case "createdTime": - err = unpopulateDateTimeRFC3339(val, "CreatedTime", &g.CreatedTime) - delete(rawMsg, key) - case "extendedLocation": - err = unpopulate(val, "ExtendedLocation", &g.ExtendedLocation) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &g.ID) - delete(rawMsg, key) - case "identity": - err = unpopulate(val, "Identity", &g.Identity) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &g.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &g.Location) - delete(rawMsg, key) - case "managedBy": - err = unpopulate(val, "ManagedBy", &g.ManagedBy) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &g.Name) - delete(rawMsg, key) - case "plan": - err = unpopulate(val, "Plan", &g.Plan) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &g.Properties) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &g.SKU) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &g.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &g.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type GenericResourceFilter. -func (g GenericResourceFilter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "resourceType", g.ResourceType) - populate(objectMap, "tagname", g.Tagname) - populate(objectMap, "tagvalue", g.Tagvalue) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResourceFilter. -func (g *GenericResourceFilter) 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", g, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "resourceType": - err = unpopulate(val, "ResourceType", &g.ResourceType) - delete(rawMsg, key) - case "tagname": - err = unpopulate(val, "Tagname", &g.Tagname) - delete(rawMsg, key) - case "tagvalue": - err = unpopulate(val, "Tagvalue", &g.Tagvalue) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type HTTPMessage. -func (h HTTPMessage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateAny(objectMap, "content", h.Content) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPMessage. -func (h *HTTPMessage) 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", h, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "content": - err = unpopulate(val, "Content", &h.Content) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", h, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Identity. -func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "principalId", i.PrincipalID) - populate(objectMap, "tenantId", i.TenantID) - populate(objectMap, "type", i.Type) - populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. -func (i *Identity) 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", i, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "principalId": - err = unpopulate(val, "PrincipalID", &i.PrincipalID) - delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &i.TenantID) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &i.Type) - delete(rawMsg, key) - case "userAssignedIdentities": - err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type IdentityUserAssignedIdentitiesValue. -func (i IdentityUserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "clientId", i.ClientID) - populate(objectMap, "principalId", i.PrincipalID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type IdentityUserAssignedIdentitiesValue. -func (i *IdentityUserAssignedIdentitiesValue) 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", i, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "clientId": - err = unpopulate(val, "ClientID", &i.ClientID) - delete(rawMsg, key) - case "principalId": - err = unpopulate(val, "PrincipalID", &i.PrincipalID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type KeyVaultParameterReference. -func (k KeyVaultParameterReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "keyVault", k.KeyVault) - populate(objectMap, "secretName", k.SecretName) - populate(objectMap, "secretVersion", k.SecretVersion) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultParameterReference. -func (k *KeyVaultParameterReference) 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", k, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "keyVault": - err = unpopulate(val, "KeyVault", &k.KeyVault) - delete(rawMsg, key) - case "secretName": - err = unpopulate(val, "SecretName", &k.SecretName) - delete(rawMsg, key) - case "secretVersion": - err = unpopulate(val, "SecretVersion", &k.SecretVersion) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", k, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type KeyVaultReference. -func (k KeyVaultReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", k.ID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultReference. -func (k *KeyVaultReference) 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", k, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &k.ID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", k, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type MoveInfo. -func (m MoveInfo) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MoveInfo. +func (m MoveInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "resources", m.Resources) populate(objectMap, "targetResourceGroup", m.TargetResourceGroup) @@ -1537,72 +625,6 @@ func (m *MoveInfo) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OnErrorDeployment. -func (o OnErrorDeployment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "deploymentName", o.DeploymentName) - populate(objectMap, "type", o.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OnErrorDeployment. -func (o *OnErrorDeployment) 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 "deploymentName": - err = unpopulate(val, "DeploymentName", &o.DeploymentName) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &o.Type) - 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 OnErrorDeploymentExtended. -func (o OnErrorDeploymentExtended) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "deploymentName", o.DeploymentName) - populate(objectMap, "provisioningState", o.ProvisioningState) - populate(objectMap, "type", o.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OnErrorDeploymentExtended. -func (o *OnErrorDeploymentExtended) 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 "deploymentName": - err = unpopulate(val, "DeploymentName", &o.DeploymentName) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &o.Type) - 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 Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1704,37 +726,6 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ParametersLink. -func (p ParametersLink) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "contentVersion", p.ContentVersion) - populate(objectMap, "uri", p.URI) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ParametersLink. -func (p *ParametersLink) 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 "contentVersion": - err = unpopulate(val, "ContentVersion", &p.ContentVersion) - delete(rawMsg, key) - case "uri": - err = unpopulate(val, "URI", &p.URI) - 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 Permission. func (p Permission) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2445,53 +1436,14 @@ func (r ResourceProviderOperationDisplayProperties) MarshalJSON() ([]byte, error objectMap := make(map[string]any) populate(objectMap, "description", r.Description) populate(objectMap, "operation", r.Operation) - populate(objectMap, "provider", r.Provider) - populate(objectMap, "publisher", r.Publisher) - populate(objectMap, "resource", r.Resource) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDisplayProperties. -func (r *ResourceProviderOperationDisplayProperties) 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 "description": - err = unpopulate(val, "Description", &r.Description) - delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &r.Operation) - delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &r.Provider) - delete(rawMsg, key) - case "publisher": - err = unpopulate(val, "Publisher", &r.Publisher) - delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &r.Resource) - 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 ResourceReference. -func (r ResourceReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) + populate(objectMap, "provider", r.Provider) + populate(objectMap, "publisher", r.Publisher) + populate(objectMap, "resource", r.Resource) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReference. -func (r *ResourceReference) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDisplayProperties. +func (r *ResourceProviderOperationDisplayProperties) 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) @@ -2499,8 +1451,20 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &r.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &r.Provider) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &r.Publisher) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &r.Resource) delete(rawMsg, key) } if err != nil { @@ -2600,103 +1564,6 @@ func (s *SKU) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ScopedDeployment. -func (s ScopedDeployment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "location", s.Location) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ScopedDeployment. -func (s *ScopedDeployment) 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 "location": - err = unpopulate(val, "Location", &s.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &s.Properties) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &s.Tags) - 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 ScopedDeploymentWhatIf. -func (s ScopedDeploymentWhatIf) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "location", s.Location) - populate(objectMap, "properties", s.Properties) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ScopedDeploymentWhatIf. -func (s *ScopedDeploymentWhatIf) 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 "location": - err = unpopulate(val, "Location", &s.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &s.Properties) - 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 StatusMessage. -func (s StatusMessage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", s.Error) - populate(objectMap, "status", s.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type StatusMessage. -func (s *StatusMessage) 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 "error": - err = unpopulate(val, "Error", &s.Error) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &s.Status) - 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 SubResource. func (s SubResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2957,287 +1824,6 @@ func (t *TagsResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type TargetResource. -func (t TargetResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", t.ID) - populate(objectMap, "resourceName", t.ResourceName) - populate(objectMap, "resourceType", t.ResourceType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TargetResource. -func (t *TargetResource) 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 "resourceName": - err = unpopulate(val, "ResourceName", &t.ResourceName) - delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &t.ResourceType) - 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 TemplateHashResult. -func (t TemplateHashResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "minifiedTemplate", t.MinifiedTemplate) - populate(objectMap, "templateHash", t.TemplateHash) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateHashResult. -func (t *TemplateHashResult) 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 "minifiedTemplate": - err = unpopulate(val, "MinifiedTemplate", &t.MinifiedTemplate) - delete(rawMsg, key) - case "templateHash": - err = unpopulate(val, "TemplateHash", &t.TemplateHash) - 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 TemplateLink. -func (t TemplateLink) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "contentVersion", t.ContentVersion) - populate(objectMap, "id", t.ID) - populate(objectMap, "queryString", t.QueryString) - populate(objectMap, "relativePath", t.RelativePath) - populate(objectMap, "uri", t.URI) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateLink. -func (t *TemplateLink) 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 "contentVersion": - err = unpopulate(val, "ContentVersion", &t.ContentVersion) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) - case "queryString": - err = unpopulate(val, "QueryString", &t.QueryString) - delete(rawMsg, key) - case "relativePath": - err = unpopulate(val, "RelativePath", &t.RelativePath) - delete(rawMsg, key) - case "uri": - err = unpopulate(val, "URI", &t.URI) - 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 WhatIfChange. -func (w WhatIfChange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateAny(objectMap, "after", w.After) - populateAny(objectMap, "before", w.Before) - populate(objectMap, "changeType", w.ChangeType) - populate(objectMap, "delta", w.Delta) - populate(objectMap, "deploymentId", w.DeploymentID) - populateAny(objectMap, "identifiers", w.Identifiers) - populate(objectMap, "resourceId", w.ResourceID) - populate(objectMap, "symbolicName", w.SymbolicName) - populate(objectMap, "unsupportedReason", w.UnsupportedReason) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfChange. -func (w *WhatIfChange) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "after": - err = unpopulate(val, "After", &w.After) - delete(rawMsg, key) - case "before": - err = unpopulate(val, "Before", &w.Before) - delete(rawMsg, key) - case "changeType": - err = unpopulate(val, "ChangeType", &w.ChangeType) - delete(rawMsg, key) - case "delta": - err = unpopulate(val, "Delta", &w.Delta) - delete(rawMsg, key) - case "deploymentId": - err = unpopulate(val, "DeploymentID", &w.DeploymentID) - delete(rawMsg, key) - case "identifiers": - err = unpopulate(val, "Identifiers", &w.Identifiers) - delete(rawMsg, key) - case "resourceId": - err = unpopulate(val, "ResourceID", &w.ResourceID) - delete(rawMsg, key) - case "symbolicName": - err = unpopulate(val, "SymbolicName", &w.SymbolicName) - delete(rawMsg, key) - case "unsupportedReason": - err = unpopulate(val, "UnsupportedReason", &w.UnsupportedReason) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WhatIfOperationProperties. -func (w WhatIfOperationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "changes", w.Changes) - populate(objectMap, "diagnostics", w.Diagnostics) - populate(objectMap, "potentialChanges", w.PotentialChanges) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfOperationProperties. -func (w *WhatIfOperationProperties) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "changes": - err = unpopulate(val, "Changes", &w.Changes) - delete(rawMsg, key) - case "diagnostics": - err = unpopulate(val, "Diagnostics", &w.Diagnostics) - delete(rawMsg, key) - case "potentialChanges": - err = unpopulate(val, "PotentialChanges", &w.PotentialChanges) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WhatIfOperationResult. -func (w WhatIfOperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", w.Error) - populate(objectMap, "properties", w.Properties) - populate(objectMap, "status", w.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfOperationResult. -func (w *WhatIfOperationResult) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &w.Error) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &w.Properties) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &w.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type WhatIfPropertyChange. -func (w WhatIfPropertyChange) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateAny(objectMap, "after", w.After) - populateAny(objectMap, "before", w.Before) - populate(objectMap, "children", w.Children) - populate(objectMap, "path", w.Path) - populate(objectMap, "propertyChangeType", w.PropertyChangeType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type WhatIfPropertyChange. -func (w *WhatIfPropertyChange) 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", w, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "after": - err = unpopulate(val, "After", &w.After) - delete(rawMsg, key) - case "before": - err = unpopulate(val, "Before", &w.Before) - delete(rawMsg, key) - case "children": - err = unpopulate(val, "Children", &w.Children) - delete(rawMsg, key) - case "path": - err = unpopulate(val, "Path", &w.Path) - delete(rawMsg, key) - case "propertyChangeType": - err = unpopulate(val, "PropertyChangeType", &w.PropertyChangeType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", w, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ZoneMapping. func (z ZoneMapping) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) diff --git a/sdk/resourcemanager/resources/armresources/operations_client.go b/sdk/resourcemanager/resources/armresources/operations_client.go index 74d72b842957..a7857b48366d 100644 --- a/sdk/resourcemanager/resources/armresources/operations_client.go +++ b/sdk/resourcemanager/resources/armresources/operations_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -39,7 +36,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available Microsoft.Resources REST API operations. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - 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]{ @@ -65,14 +62,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/options.go b/sdk/resourcemanager/resources/armresources/options.go index a7335a3e4f75..6cdbf05d7fb7 100644 --- a/sdk/resourcemanager/resources/armresources/options.go +++ b/sdk/resourcemanager/resources/armresources/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,49 +7,49 @@ package armresources // ClientBeginCreateOrUpdateByIDOptions contains the optional parameters for the Client.BeginCreateOrUpdateByID method. type ClientBeginCreateOrUpdateByIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. type ClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientBeginDeleteByIDOptions contains the optional parameters for the Client.BeginDeleteByID method. type ClientBeginDeleteByIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. type ClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientBeginMoveResourcesOptions contains the optional parameters for the Client.BeginMoveResources method. type ClientBeginMoveResourcesOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientBeginUpdateByIDOptions contains the optional parameters for the Client.BeginUpdateByID method. type ClientBeginUpdateByIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. type ClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientBeginValidateMoveResourcesOptions contains the optional parameters for the Client.BeginValidateMoveResources method. type ClientBeginValidateMoveResourcesOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -134,368 +131,6 @@ type ClientListOptions struct { Top *int32 } -// DeploymentOperationsClientGetAtManagementGroupScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtManagementGroupScope -// method. -type DeploymentOperationsClientGetAtManagementGroupScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentOperationsClientGetAtScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtScope -// method. -type DeploymentOperationsClientGetAtScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentOperationsClientGetAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtSubscriptionScope -// method. -type DeploymentOperationsClientGetAtSubscriptionScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentOperationsClientGetAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtTenantScope -// method. -type DeploymentOperationsClientGetAtTenantScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentOperationsClientGetOptions contains the optional parameters for the DeploymentOperationsClient.Get method. -type DeploymentOperationsClientGetOptions struct { - // placeholder for future optional parameters -} - -// DeploymentOperationsClientListAtManagementGroupScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtManagementGroupScopePager -// method. -type DeploymentOperationsClientListAtManagementGroupScopeOptions struct { - // The number of results to return. - Top *int32 -} - -// DeploymentOperationsClientListAtScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtScopePager -// method. -type DeploymentOperationsClientListAtScopeOptions struct { - // The number of results to return. - Top *int32 -} - -// DeploymentOperationsClientListAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtSubscriptionScopePager -// method. -type DeploymentOperationsClientListAtSubscriptionScopeOptions struct { - // The number of results to return. - Top *int32 -} - -// DeploymentOperationsClientListAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtTenantScopePager -// method. -type DeploymentOperationsClientListAtTenantScopeOptions struct { - // The number of results to return. - Top *int32 -} - -// DeploymentOperationsClientListOptions contains the optional parameters for the DeploymentOperationsClient.NewListPager -// method. -type DeploymentOperationsClientListOptions struct { - // The number of results to return. - Top *int32 -} - -// DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope -// method. -type DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtScope -// method. -type DeploymentsClientBeginCreateOrUpdateAtScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope -// method. -type DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtTenantScope -// method. -type DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdate -// method. -type DeploymentsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginDeleteAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtManagementGroupScope -// method. -type DeploymentsClientBeginDeleteAtManagementGroupScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginDeleteAtScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtScope -// method. -type DeploymentsClientBeginDeleteAtScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginDeleteAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtSubscriptionScope -// method. -type DeploymentsClientBeginDeleteAtSubscriptionScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginDeleteAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtTenantScope -// method. -type DeploymentsClientBeginDeleteAtTenantScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. -type DeploymentsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginValidateAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtManagementGroupScope -// method. -type DeploymentsClientBeginValidateAtManagementGroupScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginValidateAtScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtScope -// method. -type DeploymentsClientBeginValidateAtScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginValidateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtSubscriptionScope -// method. -type DeploymentsClientBeginValidateAtSubscriptionScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginValidateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtTenantScope -// method. -type DeploymentsClientBeginValidateAtTenantScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginValidateOptions contains the optional parameters for the DeploymentsClient.BeginValidate method. -type DeploymentsClientBeginValidateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtManagementGroupScope -// method. -type DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtSubscriptionScope -// method. -type DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginWhatIfAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtTenantScope -// method. -type DeploymentsClientBeginWhatIfAtTenantScopeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientBeginWhatIfOptions contains the optional parameters for the DeploymentsClient.BeginWhatIf method. -type DeploymentsClientBeginWhatIfOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeploymentsClientCalculateTemplateHashOptions contains the optional parameters for the DeploymentsClient.CalculateTemplateHash -// method. -type DeploymentsClientCalculateTemplateHashOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCancelAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtManagementGroupScope -// method. -type DeploymentsClientCancelAtManagementGroupScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCancelAtScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtScope method. -type DeploymentsClientCancelAtScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCancelAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtSubscriptionScope -// method. -type DeploymentsClientCancelAtSubscriptionScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCancelAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtTenantScope -// method. -type DeploymentsClientCancelAtTenantScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCancelOptions contains the optional parameters for the DeploymentsClient.Cancel method. -type DeploymentsClientCancelOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCheckExistenceAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtManagementGroupScope -// method. -type DeploymentsClientCheckExistenceAtManagementGroupScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCheckExistenceAtScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtScope -// method. -type DeploymentsClientCheckExistenceAtScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCheckExistenceAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtSubscriptionScope -// method. -type DeploymentsClientCheckExistenceAtSubscriptionScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCheckExistenceAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtTenantScope -// method. -type DeploymentsClientCheckExistenceAtTenantScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientCheckExistenceOptions contains the optional parameters for the DeploymentsClient.CheckExistence method. -type DeploymentsClientCheckExistenceOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientExportTemplateAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtManagementGroupScope -// method. -type DeploymentsClientExportTemplateAtManagementGroupScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientExportTemplateAtScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtScope -// method. -type DeploymentsClientExportTemplateAtScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientExportTemplateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtSubscriptionScope -// method. -type DeploymentsClientExportTemplateAtSubscriptionScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientExportTemplateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtTenantScope -// method. -type DeploymentsClientExportTemplateAtTenantScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientExportTemplateOptions contains the optional parameters for the DeploymentsClient.ExportTemplate method. -type DeploymentsClientExportTemplateOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientGetAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.GetAtManagementGroupScope -// method. -type DeploymentsClientGetAtManagementGroupScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientGetAtScopeOptions contains the optional parameters for the DeploymentsClient.GetAtScope method. -type DeploymentsClientGetAtScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientGetAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.GetAtSubscriptionScope -// method. -type DeploymentsClientGetAtSubscriptionScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientGetAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.GetAtTenantScope method. -type DeploymentsClientGetAtTenantScopeOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. -type DeploymentsClientGetOptions struct { - // placeholder for future optional parameters -} - -// DeploymentsClientListAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtManagementGroupScopePager -// method. -type DeploymentsClientListAtManagementGroupScopeOptions struct { - // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. - Filter *string - - // The number of results to get. If null is passed, returns all deployments. - Top *int32 -} - -// DeploymentsClientListAtScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtScopePager method. -type DeploymentsClientListAtScopeOptions struct { - // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. - Filter *string - - // The number of results to get. If null is passed, returns all deployments. - Top *int32 -} - -// DeploymentsClientListAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtSubscriptionScopePager -// method. -type DeploymentsClientListAtSubscriptionScopeOptions struct { - // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. - Filter *string - - // The number of results to get. If null is passed, returns all deployments. - Top *int32 -} - -// DeploymentsClientListAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtTenantScopePager -// method. -type DeploymentsClientListAtTenantScopeOptions struct { - // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. - Filter *string - - // The number of results to get. If null is passed, returns all deployments. - Top *int32 -} - -// DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByResourceGroupPager -// method. -type DeploymentsClientListByResourceGroupOptions struct { - // The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. - Filter *string - - // The number of results to get. If null is passed, returns all deployments. - Top *int32 -} - // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters @@ -564,14 +199,14 @@ type ResourceGroupsClientBeginDeleteOptions struct { // The resource types you want to force delete. Currently, only the following is supported: forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets ForceDeletionTypes *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ResourceGroupsClientBeginExportTemplateOptions contains the optional parameters for the ResourceGroupsClient.BeginExportTemplate // method. type ResourceGroupsClientBeginExportTemplateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -611,19 +246,19 @@ type ResourceGroupsClientUpdateOptions struct { // TagsClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginCreateOrUpdateAtScope // method. type TagsClientBeginCreateOrUpdateAtScopeOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // TagsClientBeginDeleteAtScopeOptions contains the optional parameters for the TagsClient.BeginDeleteAtScope method. type TagsClientBeginDeleteAtScopeOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // TagsClientBeginUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginUpdateAtScope method. type TagsClientBeginUpdateAtScopeOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } diff --git a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go b/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go index 25e69d186f97..9defe9d0c369 100644 --- a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go +++ b/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -46,7 +43,7 @@ func NewProviderResourceTypesClient(subscriptionID string, credential azcore.Tok // List - List the resource types for a specified resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProviderResourceTypesClientListOptions contains the optional parameters for the ProviderResourceTypesClient.List // method. @@ -91,7 +88,7 @@ func (client *ProviderResourceTypesClient) listCreateRequest(ctx context.Context if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client_example_test.go b/sdk/resourcemanager/resources/armresources/providerresourcetypes_client_example_test.go deleted file mode 100644 index 069c556f23e5..000000000000 --- a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client_example_test.go +++ /dev/null @@ -1,67 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armresources_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/GetProviderResourceTypes.json -func ExampleProviderResourceTypesClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProviderResourceTypesClient().List(ctx, "Microsoft.TestRP", &armresources.ProviderResourceTypesClientListOptions{Expand: 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.ProviderResourceTypeListResult = armresources.ProviderResourceTypeListResult{ - // Value: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/providers_client.go b/sdk/resourcemanager/resources/armresources/providers_client.go index f6ff3ce5dded..9eab8b972f72 100644 --- a/sdk/resourcemanager/resources/armresources/providers_client.go +++ b/sdk/resourcemanager/resources/armresources/providers_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -46,7 +43,7 @@ func NewProvidersClient(subscriptionID string, credential azcore.TokenCredential // Get - Gets the specified resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProvidersClientGetOptions contains the optional parameters for the ProvidersClient.Get method. func (client *ProvidersClient) Get(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientGetOptions) (ProvidersClientGetResponse, error) { @@ -90,7 +87,7 @@ func (client *ProvidersClient) getCreateRequest(ctx context.Context, resourcePro if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -108,7 +105,7 @@ func (client *ProvidersClient) getHandleResponse(resp *http.Response) (Providers // GetAtTenantScope - Gets the specified resource provider at the tenant level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProvidersClientGetAtTenantScopeOptions contains the optional parameters for the ProvidersClient.GetAtTenantScope // method. @@ -149,7 +146,7 @@ func (client *ProvidersClient) getAtTenantScopeCreateRequest(ctx context.Context if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -166,7 +163,7 @@ func (client *ProvidersClient) getAtTenantScopeHandleResponse(resp *http.Respons // NewListPager - Gets all resource providers for a subscription. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - options - ProvidersClientListOptions contains the optional parameters for the ProvidersClient.NewListPager method. func (client *ProvidersClient) NewListPager(options *ProvidersClientListOptions) *runtime.Pager[ProvidersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ProvidersClientListResponse]{ @@ -206,7 +203,7 @@ func (client *ProvidersClient) listCreateRequest(ctx context.Context, options *P if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -223,7 +220,7 @@ func (client *ProvidersClient) listHandleResponse(resp *http.Response) (Provider // NewListAtTenantScopePager - Gets all resource providers for the tenant. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - options - ProvidersClientListAtTenantScopeOptions contains the optional parameters for the ProvidersClient.NewListAtTenantScopePager // method. func (client *ProvidersClient) NewListAtTenantScopePager(options *ProvidersClientListAtTenantScopeOptions) *runtime.Pager[ProvidersClientListAtTenantScopeResponse] { @@ -260,7 +257,7 @@ func (client *ProvidersClient) listAtTenantScopeCreateRequest(ctx context.Contex if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -278,7 +275,7 @@ func (client *ProvidersClient) listAtTenantScopeHandleResponse(resp *http.Respon // ProviderPermissions - Get the provider permissions. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProvidersClientProviderPermissionsOptions contains the optional parameters for the ProvidersClient.ProviderPermissions // method. @@ -305,7 +302,7 @@ func (client *ProvidersClient) ProviderPermissions(ctx context.Context, resource } // providerPermissionsCreateRequest creates the ProviderPermissions request. -func (client *ProvidersClient) providerPermissionsCreateRequest(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientProviderPermissionsOptions) (*policy.Request, error) { +func (client *ProvidersClient) providerPermissionsCreateRequest(ctx context.Context, resourceProviderNamespace string, _ *ProvidersClientProviderPermissionsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/providerPermissions" if resourceProviderNamespace == "" { return nil, errors.New("parameter resourceProviderNamespace cannot be empty") @@ -320,7 +317,7 @@ func (client *ProvidersClient) providerPermissionsCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,7 +335,7 @@ func (client *ProvidersClient) providerPermissionsHandleResponse(resp *http.Resp // Register - Registers a subscription with a resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceProviderNamespace - The namespace of the resource provider to register. // - options - ProvidersClientRegisterOptions contains the optional parameters for the ProvidersClient.Register method. func (client *ProvidersClient) Register(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientRegisterOptions) (ProvidersClientRegisterResponse, error) { @@ -379,7 +376,7 @@ func (client *ProvidersClient) registerCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Properties != nil { @@ -405,7 +402,7 @@ func (client *ProvidersClient) registerHandleResponse(resp *http.Response) (Prov // recursively register subscriptions within the management group. Instead, you must register subscriptions individually. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceProviderNamespace - The namespace of the resource provider to register. // - groupID - The management group ID. // - options - ProvidersClientRegisterAtManagementGroupScopeOptions contains the optional parameters for the ProvidersClient.RegisterAtManagementGroupScope @@ -432,7 +429,7 @@ func (client *ProvidersClient) RegisterAtManagementGroupScope(ctx context.Contex } // registerAtManagementGroupScopeCreateRequest creates the RegisterAtManagementGroupScope request. -func (client *ProvidersClient) registerAtManagementGroupScopeCreateRequest(ctx context.Context, resourceProviderNamespace string, groupID string, options *ProvidersClientRegisterAtManagementGroupScopeOptions) (*policy.Request, error) { +func (client *ProvidersClient) registerAtManagementGroupScopeCreateRequest(ctx context.Context, resourceProviderNamespace string, groupID string, _ *ProvidersClientRegisterAtManagementGroupScopeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/providers/{resourceProviderNamespace}/register" if resourceProviderNamespace == "" { return nil, errors.New("parameter resourceProviderNamespace cannot be empty") @@ -447,7 +444,7 @@ func (client *ProvidersClient) registerAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -456,7 +453,7 @@ func (client *ProvidersClient) registerAtManagementGroupScopeCreateRequest(ctx c // Unregister - Unregisters a subscription from a resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceProviderNamespace - The namespace of the resource provider to unregister. // - options - ProvidersClientUnregisterOptions contains the optional parameters for the ProvidersClient.Unregister method. func (client *ProvidersClient) Unregister(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientUnregisterOptions) (ProvidersClientUnregisterResponse, error) { @@ -482,7 +479,7 @@ func (client *ProvidersClient) Unregister(ctx context.Context, resourceProviderN } // unregisterCreateRequest creates the Unregister request. -func (client *ProvidersClient) unregisterCreateRequest(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientUnregisterOptions) (*policy.Request, error) { +func (client *ProvidersClient) unregisterCreateRequest(ctx context.Context, resourceProviderNamespace string, _ *ProvidersClientUnregisterOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister" if resourceProviderNamespace == "" { return nil, errors.New("parameter resourceProviderNamespace cannot be empty") @@ -497,7 +494,7 @@ func (client *ProvidersClient) unregisterCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/providers_client_example_test.go b/sdk/resourcemanager/resources/armresources/providers_client_example_test.go deleted file mode 100644 index d9d29129539b..000000000000 --- a/sdk/resourcemanager/resources/armresources/providers_client_example_test.go +++ /dev/null @@ -1,532 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armresources_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/armresources/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/GetProviderPermissions.json -func ExampleProvidersClient_ProviderPermissions() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProvidersClient().ProviderPermissions(ctx, "Microsoft.TestRP", 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.ProviderPermissionListResult = armresources.ProviderPermissionListResult{ - // Value: []*armresources.ProviderPermission{ - // { - // ApplicationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProviderAuthorizationConsentState: to.Ptr(armresources.ProviderAuthorizationConsentStateConsented), - // RoleDefinition: &armresources.RoleDefinition{ - // Name: to.Ptr("Contoso service role"), - // ID: to.Ptr("00000000000000000000000000000000"), - // IsServiceRole: to.Ptr(true), - // Permissions: []*armresources.Permission{ - // { - // Actions: []*string{ - // to.Ptr("Microsoft.Contoso/*")}, - // DataActions: []*string{ - // }, - // NotActions: []*string{ - // }, - // NotDataActions: []*string{ - // }, - // }}, - // Scopes: []*string{ - // to.Ptr("/")}, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/GetProviders.json -func ExampleProvidersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProvidersClient().NewListPager(&armresources.ProvidersClientListOptions{Expand: 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.ProviderListResult = armresources.ProviderListResult{ - // Value: []*armresources.Provider{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.TestRP1"), - // Namespace: to.Ptr("Microsoft.TestRP1"), - // RegistrationPolicy: to.Ptr("RegistrationRequired"), - // RegistrationState: to.Ptr("Registering"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Resources"), - // Namespace: to.Ptr("Microsoft.Resources"), - // RegistrationPolicy: to.Ptr("RegistrationFree"), - // RegistrationState: to.Ptr("Registered"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2016-09-01"), - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("eastus"), - // to.Ptr("eastus2"), - // to.Ptr("westus")}, - // ResourceType: to.Ptr("subscriptions"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2016-09-01"), - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("centralus"), - // to.Ptr("eastasia"), - // to.Ptr("southeastasia")}, - // ResourceType: to.Ptr("resourceGroups"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2016-09-01"), - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("eastus"), - // to.Ptr("eastus2"), - // to.Ptr("westus")}, - // ResourceType: to.Ptr("subscriptions/resourceGroups"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("centralus"), - // to.Ptr("eastasia")}, - // ResourceType: to.Ptr("bulkDelete"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2017-08-01"), - // to.Ptr("2017-06-01")}, - // Capabilities: to.Ptr("SupportsTags"), - // Locations: []*string{ - // }, - // ResourceType: to.Ptr("deployments"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // }, - // Capabilities: to.Ptr("SupportsExtension"), - // Locations: []*string{ - // to.Ptr("DevFabric")}, - // ResourceType: to.Ptr("tags"), - // }}, - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.TestRP2"), - // Namespace: to.Ptr("Microsoft.TestRP2"), - // RegistrationPolicy: to.Ptr("RegistrationRequired"), - // RegistrationState: to.Ptr("NotRegistered"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/GetProvider.json -func ExampleProvidersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProvidersClient().Get(ctx, "Microsoft.TestRP1", &armresources.ProvidersClientGetOptions{Expand: 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.Provider = armresources.Provider{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.TestRP1"), - // Namespace: to.Ptr("Microsoft.TestRP1"), - // RegistrationPolicy: to.Ptr("RegistrationRequired"), - // RegistrationState: to.Ptr("Registering"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/GetNamedProviderAtTenant.json -func ExampleProvidersClient_GetAtTenantScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProvidersClient().GetAtTenantScope(ctx, "Microsoft.Storage", &armresources.ProvidersClientGetAtTenantScopeOptions{Expand: to.Ptr("resourceTypes/aliases")}) - 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.Provider = armresources.Provider{ - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Aliases: []*armresources.Alias{ - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/accountType"), - // DefaultPath: to.Ptr("sku.name"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.accountType"), - // APIVersions: []*string{ - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }, - // { - // Path: to.Ptr("sku.name"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/sku.name"), - // DefaultPath: to.Ptr("sku.name"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.accountType"), - // APIVersions: []*string{ - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }, - // { - // Path: to.Ptr("sku.name"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/accessTier"), - // DefaultPath: to.Ptr("properties.accessTier"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.accessTier"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/enableBlobEncryption"), - // DefaultPath: to.Ptr("properties.encryption.services.blob.enabled"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.encryption.services.blob.enabled"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/enableFileEncryption"), - // DefaultPath: to.Ptr("properties.encryption.services.file.enabled"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.encryption.services.file.enabled"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly"), - // DefaultMetadata: &armresources.AliasPathMetadata{ - // Type: to.Ptr(armresources.AliasPathTokenTypeBoolean), - // Attributes: to.Ptr(armresources.AliasPathAttributesModifiable), - // }, - // DefaultPath: to.Ptr("properties.supportsHttpsTrafficOnly"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.supportsHttpsTrafficOnly"), - // APIVersions: []*string{ - // to.Ptr("2018-11-09"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // Metadata: &armresources.AliasPathMetadata{ - // Type: to.Ptr(armresources.AliasPathTokenTypeNotSpecified), - // Attributes: to.Ptr(armresources.AliasPathAttributesNone), - // }, - // }}, - // }}, - // APIProfiles: []*armresources.APIProfile{ - // { - // APIVersion: to.Ptr("2017-10-01"), - // ProfileVersion: to.Ptr("2019-03-01-hybrid"), - // }, - // { - // APIVersion: to.Ptr("2016-01-01"), - // ProfileVersion: to.Ptr("2017-03-09-profile"), - // }, - // { - // APIVersion: to.Ptr("2016-01-01"), - // ProfileVersion: to.Ptr("2018-03-01-hybrid"), - // }, - // { - // APIVersion: to.Ptr("2017-10-01"), - // ProfileVersion: to.Ptr("2018-06-01-profile"), - // }}, - // APIVersions: []*string{ - // to.Ptr("2019-06-01"), - // to.Ptr("2019-04-01"), - // to.Ptr("2018-11-01"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // Capabilities: to.Ptr("SupportsTags, SupportsLocation"), - // DefaultAPIVersion: to.Ptr("2019-06-01"), - // Locations: []*string{ - // to.Ptr("East US"), - // to.Ptr("East US 2"), - // to.Ptr("East US 2 (Stage)"), - // to.Ptr("West US"), - // to.Ptr("West Europe"), - // to.Ptr("East Asia"), - // to.Ptr("Southeast Asia"), - // to.Ptr("Japan East"), - // to.Ptr("Japan West"), - // to.Ptr("North Central US"), - // to.Ptr("South Central US"), - // to.Ptr("Central US"), - // to.Ptr("North Europe"), - // to.Ptr("Brazil South"), - // to.Ptr("Australia East"), - // to.Ptr("Australia Southeast"), - // to.Ptr("South India"), - // to.Ptr("Central India"), - // to.Ptr("West India"), - // to.Ptr("Canada East"), - // to.Ptr("Canada Central"), - // to.Ptr("West US 2"), - // to.Ptr("West Central US"), - // to.Ptr("UK South"), - // to.Ptr("UK West"), - // to.Ptr("Korea Central"), - // to.Ptr("Korea South"), - // to.Ptr("East US 2 EUAP"), - // to.Ptr("Central US EUAP"), - // to.Ptr("France Central"), - // to.Ptr("France South"), - // to.Ptr("Australia Central"), - // to.Ptr("Australia Central 2"), - // to.Ptr("South Africa West"), - // to.Ptr("South Africa North"), - // to.Ptr("UAE Central"), - // to.Ptr("UAE North"), - // to.Ptr("Switzerland North"), - // to.Ptr("Switzerland West"), - // to.Ptr("Germany West Central"), - // to.Ptr("Germany North"), - // to.Ptr("Norway East"), - // to.Ptr("Norway West"), - // to.Ptr("South Central US STG"), - // to.Ptr("Brazil Southeast")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/resourcegroups_client.go b/sdk/resourcemanager/resources/armresources/resourcegroups_client.go index 9b3c5581320d..7964e0c1bf00 100644 --- a/sdk/resourcemanager/resources/armresources/resourcegroups_client.go +++ b/sdk/resourcemanager/resources/armresources/resourcegroups_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -46,7 +43,7 @@ func NewResourceGroupsClient(subscriptionID string, credential azcore.TokenCrede // CheckExistence - Checks whether a resource group exists. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group to check. The name is case insensitive. // - options - ResourceGroupsClientCheckExistenceOptions contains the optional parameters for the ResourceGroupsClient.CheckExistence // method. @@ -72,7 +69,7 @@ func (client *ResourceGroupsClient) CheckExistence(ctx context.Context, resource } // checkExistenceCreateRequest creates the CheckExistence request. -func (client *ResourceGroupsClient) checkExistenceCreateRequest(ctx context.Context, resourceGroupName string, options *ResourceGroupsClientCheckExistenceOptions) (*policy.Request, error) { +func (client *ResourceGroupsClient) checkExistenceCreateRequest(ctx context.Context, resourceGroupName string, _ *ResourceGroupsClientCheckExistenceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -87,7 +84,7 @@ func (client *ResourceGroupsClient) checkExistenceCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -96,7 +93,7 @@ func (client *ResourceGroupsClient) checkExistenceCreateRequest(ctx context.Cont // CreateOrUpdate - Creates or updates a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, // hyphen, period (except at end), and Unicode characters that match the allowed characters. // - parameters - Parameters supplied to the create or update a resource group. @@ -125,7 +122,7 @@ func (client *ResourceGroupsClient) CreateOrUpdate(ctx context.Context, resource } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ResourceGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, parameters ResourceGroup, options *ResourceGroupsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ResourceGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, parameters ResourceGroup, _ *ResourceGroupsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -140,7 +137,7 @@ func (client *ResourceGroupsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -162,7 +159,7 @@ func (client *ResourceGroupsClient) createOrUpdateHandleResponse(resp *http.Resp // all of its template deployments and currently stored operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group to delete. The name is case insensitive. // - options - ResourceGroupsClientBeginDeleteOptions contains the optional parameters for the ResourceGroupsClient.BeginDelete // method. @@ -187,7 +184,7 @@ func (client *ResourceGroupsClient) BeginDelete(ctx context.Context, resourceGro // of its template deployments and currently stored operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *ResourceGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, options *ResourceGroupsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ResourceGroupsClient.BeginDelete" @@ -225,7 +222,7 @@ func (client *ResourceGroupsClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") if options != nil && options.ForceDeletionTypes != nil { reqQP.Set("forceDeletionTypes", *options.ForceDeletionTypes) } @@ -237,7 +234,7 @@ func (client *ResourceGroupsClient) deleteCreateRequest(ctx context.Context, res // BeginExportTemplate - Captures the specified resource group as a template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - parameters - Parameters for exporting the template. // - options - ResourceGroupsClientBeginExportTemplateOptions contains the optional parameters for the ResourceGroupsClient.BeginExportTemplate @@ -263,7 +260,7 @@ func (client *ResourceGroupsClient) BeginExportTemplate(ctx context.Context, res // ExportTemplate - Captures the specified resource group as a template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *ResourceGroupsClient) exportTemplate(ctx context.Context, resourceGroupName string, parameters ExportTemplateRequest, options *ResourceGroupsClientBeginExportTemplateOptions) (*http.Response, error) { var err error const operationName = "ResourceGroupsClient.BeginExportTemplate" @@ -286,7 +283,7 @@ func (client *ResourceGroupsClient) exportTemplate(ctx context.Context, resource } // exportTemplateCreateRequest creates the ExportTemplate request. -func (client *ResourceGroupsClient) exportTemplateCreateRequest(ctx context.Context, resourceGroupName string, parameters ExportTemplateRequest, options *ResourceGroupsClientBeginExportTemplateOptions) (*policy.Request, error) { +func (client *ResourceGroupsClient) exportTemplateCreateRequest(ctx context.Context, resourceGroupName string, parameters ExportTemplateRequest, _ *ResourceGroupsClientBeginExportTemplateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -301,7 +298,7 @@ func (client *ResourceGroupsClient) exportTemplateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -313,7 +310,7 @@ func (client *ResourceGroupsClient) exportTemplateCreateRequest(ctx context.Cont // Get - Gets a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group to get. The name is case insensitive. // - options - ResourceGroupsClientGetOptions contains the optional parameters for the ResourceGroupsClient.Get method. func (client *ResourceGroupsClient) Get(ctx context.Context, resourceGroupName string, options *ResourceGroupsClientGetOptions) (ResourceGroupsClientGetResponse, error) { @@ -339,7 +336,7 @@ func (client *ResourceGroupsClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *ResourceGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, options *ResourceGroupsClientGetOptions) (*policy.Request, error) { +func (client *ResourceGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, _ *ResourceGroupsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -354,7 +351,7 @@ func (client *ResourceGroupsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,7 +368,7 @@ func (client *ResourceGroupsClient) getHandleResponse(resp *http.Response) (Reso // NewListPager - Gets all the resource groups for a subscription. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - options - ResourceGroupsClientListOptions contains the optional parameters for the ResourceGroupsClient.NewListPager method. func (client *ResourceGroupsClient) NewListPager(options *ResourceGroupsClientListOptions) *runtime.Pager[ResourceGroupsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourceGroupsClientListResponse]{ @@ -414,7 +411,7 @@ func (client *ResourceGroupsClient) listCreateRequest(ctx context.Context, optio if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -434,7 +431,7 @@ func (client *ResourceGroupsClient) listHandleResponse(resp *http.Response) (Res // value is retained. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - resourceGroupName - The name of the resource group to update. The name is case insensitive. // - parameters - Parameters supplied to update a resource group. // - options - ResourceGroupsClientUpdateOptions contains the optional parameters for the ResourceGroupsClient.Update method. @@ -461,7 +458,7 @@ func (client *ResourceGroupsClient) Update(ctx context.Context, resourceGroupNam } // updateCreateRequest creates the Update request. -func (client *ResourceGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, parameters ResourceGroupPatchable, options *ResourceGroupsClientUpdateOptions) (*policy.Request, error) { +func (client *ResourceGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, parameters ResourceGroupPatchable, _ *ResourceGroupsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -476,7 +473,7 @@ func (client *ResourceGroupsClient) updateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armresources/resourcegroups_client_example_test.go b/sdk/resourcemanager/resources/armresources/resourcegroups_client_example_test.go deleted file mode 100644 index 1dbadc210493..000000000000 --- a/sdk/resourcemanager/resources/armresources/resourcegroups_client_example_test.go +++ /dev/null @@ -1,258 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armresources_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/armresources/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/CreateResourceGroup.json -func ExampleResourceGroupsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGroupsClient().CreateOrUpdate(ctx, "my-resource-group", armresources.ResourceGroup{ - Location: to.Ptr("eastus"), - }, 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.ResourceGroup = armresources.ResourceGroup{ - // Name: to.Ptr("my-resource-group"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.ResourceGroupProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json -func ExampleResourceGroupsClient_BeginDelete_forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginDelete(ctx, "my-resource-group", &armresources.ResourceGroupsClientBeginDeleteOptions{ForceDeletionTypes: to.Ptr("Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets")}) - 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/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/ForceDeleteVMsInResourceGroup.json -func ExampleResourceGroupsClient_BeginDelete_forceDeleteAllTheVirtualMachinesInAResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginDelete(ctx, "my-resource-group", &armresources.ResourceGroupsClientBeginDeleteOptions{ForceDeletionTypes: to.Ptr("Microsoft.Compute/virtualMachines")}) - 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/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/ExportResourceGroup.json -func ExampleResourceGroupsClient_BeginExportTemplate_exportAResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginExportTemplate(ctx, "my-resource-group", armresources.ExportTemplateRequest{ - Options: to.Ptr("IncludeParameterDefaultValue,IncludeComments"), - Resources: []*string{ - to.Ptr("*")}, - }, 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.ResourceGroupExportResult = armresources.ResourceGroupExportResult{ - // Error: &armresources.ErrorResponse{ - // Code: to.Ptr("ExportTemplateCompletedWithErrors"), - // Message: to.Ptr("Export template operation completed with errors. Some resources were not exported. Please see details for more information."), - // Details: []*armresources.ErrorResponse{ - // }, - // }, - // Template: map[string]any{ - // "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "parameters":map[string]any{ - // "myResourceType_myFirstResource_name":map[string]any{ - // "type": "String", - // "defaultValue": "myFirstResource", - // }, - // "myResourceType_myFirstResource_secret":map[string]any{ - // "type": "SecureString", - // "defaultValue": nil, - // }, - // "myResourceType_mySecondResource_name":map[string]any{ - // "type": "String", - // "defaultValue": "mySecondResource", - // }, - // }, - // "resources":[]any{ - // map[string]any{ - // "name": "[parameters('myResourceType_myFirstResource_name')]", - // "type": "My.RP/myResourceType", - // "apiVersion": "2019-01-01", - // "location": "West US", - // "properties":map[string]any{ - // "secret": "[parameters('myResourceType_myFirstResource_secret')]", - // }, - // }, - // map[string]any{ - // "name": "[parameters('myResourceType_mySecondResource_name')]", - // "type": "My.RP/myResourceType", - // "apiVersion": "2019-01-01", - // "location": "West US", - // "properties":map[string]any{ - // "customProperty": "hello!", - // }, - // }, - // }, - // "variables":map[string]any{ - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/ExportResourceGroupAsBicep.json -func ExampleResourceGroupsClient_BeginExportTemplate_exportAResourceGroupAsBicep() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginExportTemplate(ctx, "my-resource-group", armresources.ExportTemplateRequest{ - Options: to.Ptr("IncludeParameterDefaultValue,IncludeComments"), - OutputFormat: to.Ptr(armresources.ExportTemplateOutputFormatBicep), - Resources: []*string{ - to.Ptr("*")}, - }, 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.ResourceGroupExportResult = armresources.ResourceGroupExportResult{ - // Error: &armresources.ErrorResponse{ - // Code: to.Ptr("ExportTemplateCompletedWithErrors"), - // Message: to.Ptr("Export template operation completed with errors. Some resources were not exported. Please see details for more information."), - // Details: []*armresources.ErrorResponse{ - // }, - // }, - // Output: to.Ptr("\nparam myResourceType_myFirstResource_name string = 'myFirstResource'\nparam myResourceType_mySecondResource_name string = 'mySecondResource'\n\n@secure()\nparam myResourceType_myFirstResource_secret string = null\n\nresource myResourceType_myFirstResource_name_resource 'My.RP/myResourceType@2019-01-01' = {\n name: myResourceType_myFirstResource_name\n location: 'West US'\n properties: {\n secret: myResourceType_myFirstResource_secret\n }\n}\n\nresource myResourceType_mySecondResource_name_resource 'My.RP/myResourceType@2019-01-01' = {\n name: myResourceType_mySecondResource_name\n location: 'West US'\n properties: {\n customProperty: 'hello!'\n }\n}\n"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/ExportResourceGroupWithFiltering.json -func ExampleResourceGroupsClient_BeginExportTemplate_exportAResourceGroupWithFiltering() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginExportTemplate(ctx, "my-resource-group", armresources.ExportTemplateRequest{ - Options: to.Ptr("SkipResourceNameParameterization"), - Resources: []*string{ - to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource")}, - }, 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.ResourceGroupExportResult = armresources.ResourceGroupExportResult{ - // Template: map[string]any{ - // "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "parameters":map[string]any{ - // "myResourceType_myFirstResource_secret":map[string]any{ - // "type": "SecureString", - // "defaultValue": nil, - // }, - // }, - // "resources":[]any{ - // map[string]any{ - // "name": "myFirstResource", - // "type": "My.RP/myResourceType", - // "apiVersion": "2019-01-01", - // "location": "West US", - // "properties":map[string]any{ - // "secret": "[parameters('myResourceType_myFirstResource_secret')]", - // }, - // }, - // }, - // "variables":map[string]any{ - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go b/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go index c5a867561cda..c0f5743e2ff2 100644 --- a/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/resources_client_live_test.go b/sdk/resourcemanager/resources/armresources/resources_client_live_test.go index 0479a8b6197c..7e28db3fb22b 100644 --- a/sdk/resourcemanager/resources/armresources/resources_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/resources_client_live_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/responses.go b/sdk/resourcemanager/resources/armresources/responses.go index 76df28e353b2..10aed66a0e51 100644 --- a/sdk/resourcemanager/resources/armresources/responses.go +++ b/sdk/resourcemanager/resources/armresources/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -88,326 +85,6 @@ type ClientValidateMoveResourcesResponse struct { // placeholder for future response values } -// DeploymentOperationsClientGetAtManagementGroupScopeResponse contains the response from method DeploymentOperationsClient.GetAtManagementGroupScope. -type DeploymentOperationsClientGetAtManagementGroupScopeResponse struct { - // Deployment operation information. - DeploymentOperation -} - -// DeploymentOperationsClientGetAtScopeResponse contains the response from method DeploymentOperationsClient.GetAtScope. -type DeploymentOperationsClientGetAtScopeResponse struct { - // Deployment operation information. - DeploymentOperation -} - -// DeploymentOperationsClientGetAtSubscriptionScopeResponse contains the response from method DeploymentOperationsClient.GetAtSubscriptionScope. -type DeploymentOperationsClientGetAtSubscriptionScopeResponse struct { - // Deployment operation information. - DeploymentOperation -} - -// DeploymentOperationsClientGetAtTenantScopeResponse contains the response from method DeploymentOperationsClient.GetAtTenantScope. -type DeploymentOperationsClientGetAtTenantScopeResponse struct { - // Deployment operation information. - DeploymentOperation -} - -// DeploymentOperationsClientGetResponse contains the response from method DeploymentOperationsClient.Get. -type DeploymentOperationsClientGetResponse struct { - // Deployment operation information. - DeploymentOperation -} - -// DeploymentOperationsClientListAtManagementGroupScopeResponse contains the response from method DeploymentOperationsClient.NewListAtManagementGroupScopePager. -type DeploymentOperationsClientListAtManagementGroupScopeResponse struct { - // List of deployment operations. - DeploymentOperationsListResult -} - -// DeploymentOperationsClientListAtScopeResponse contains the response from method DeploymentOperationsClient.NewListAtScopePager. -type DeploymentOperationsClientListAtScopeResponse struct { - // List of deployment operations. - DeploymentOperationsListResult -} - -// DeploymentOperationsClientListAtSubscriptionScopeResponse contains the response from method DeploymentOperationsClient.NewListAtSubscriptionScopePager. -type DeploymentOperationsClientListAtSubscriptionScopeResponse struct { - // List of deployment operations. - DeploymentOperationsListResult -} - -// DeploymentOperationsClientListAtTenantScopeResponse contains the response from method DeploymentOperationsClient.NewListAtTenantScopePager. -type DeploymentOperationsClientListAtTenantScopeResponse struct { - // List of deployment operations. - DeploymentOperationsListResult -} - -// DeploymentOperationsClientListResponse contains the response from method DeploymentOperationsClient.NewListPager. -type DeploymentOperationsClientListResponse struct { - // List of deployment operations. - DeploymentOperationsListResult -} - -// DeploymentsClientCalculateTemplateHashResponse contains the response from method DeploymentsClient.CalculateTemplateHash. -type DeploymentsClientCalculateTemplateHashResponse struct { - // Result of the request to calculate template hash. It contains a string of minified template and its hash. - TemplateHashResult -} - -// DeploymentsClientCancelAtManagementGroupScopeResponse contains the response from method DeploymentsClient.CancelAtManagementGroupScope. -type DeploymentsClientCancelAtManagementGroupScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientCancelAtScopeResponse contains the response from method DeploymentsClient.CancelAtScope. -type DeploymentsClientCancelAtScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientCancelAtSubscriptionScopeResponse contains the response from method DeploymentsClient.CancelAtSubscriptionScope. -type DeploymentsClientCancelAtSubscriptionScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientCancelAtTenantScopeResponse contains the response from method DeploymentsClient.CancelAtTenantScope. -type DeploymentsClientCancelAtTenantScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientCancelResponse contains the response from method DeploymentsClient.Cancel. -type DeploymentsClientCancelResponse struct { - // placeholder for future response values -} - -// DeploymentsClientCheckExistenceAtManagementGroupScopeResponse contains the response from method DeploymentsClient.CheckExistenceAtManagementGroupScope. -type DeploymentsClientCheckExistenceAtManagementGroupScopeResponse struct { - // Success indicates if the operation succeeded or failed. - Success bool -} - -// DeploymentsClientCheckExistenceAtScopeResponse contains the response from method DeploymentsClient.CheckExistenceAtScope. -type DeploymentsClientCheckExistenceAtScopeResponse struct { - // Success indicates if the operation succeeded or failed. - Success bool -} - -// DeploymentsClientCheckExistenceAtSubscriptionScopeResponse contains the response from method DeploymentsClient.CheckExistenceAtSubscriptionScope. -type DeploymentsClientCheckExistenceAtSubscriptionScopeResponse struct { - // Success indicates if the operation succeeded or failed. - Success bool -} - -// DeploymentsClientCheckExistenceAtTenantScopeResponse contains the response from method DeploymentsClient.CheckExistenceAtTenantScope. -type DeploymentsClientCheckExistenceAtTenantScopeResponse struct { - // Success indicates if the operation succeeded or failed. - Success bool -} - -// DeploymentsClientCheckExistenceResponse contains the response from method DeploymentsClient.CheckExistence. -type DeploymentsClientCheckExistenceResponse struct { - // Success indicates if the operation succeeded or failed. - Success bool -} - -// DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse contains the response from method DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope. -type DeploymentsClientCreateOrUpdateAtManagementGroupScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientCreateOrUpdateAtScopeResponse contains the response from method DeploymentsClient.BeginCreateOrUpdateAtScope. -type DeploymentsClientCreateOrUpdateAtScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse contains the response from method DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope. -type DeploymentsClientCreateOrUpdateAtSubscriptionScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientCreateOrUpdateAtTenantScopeResponse contains the response from method DeploymentsClient.BeginCreateOrUpdateAtTenantScope. -type DeploymentsClientCreateOrUpdateAtTenantScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientCreateOrUpdateResponse contains the response from method DeploymentsClient.BeginCreateOrUpdate. -type DeploymentsClientCreateOrUpdateResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientDeleteAtManagementGroupScopeResponse contains the response from method DeploymentsClient.BeginDeleteAtManagementGroupScope. -type DeploymentsClientDeleteAtManagementGroupScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientDeleteAtScopeResponse contains the response from method DeploymentsClient.BeginDeleteAtScope. -type DeploymentsClientDeleteAtScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientDeleteAtSubscriptionScopeResponse contains the response from method DeploymentsClient.BeginDeleteAtSubscriptionScope. -type DeploymentsClientDeleteAtSubscriptionScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientDeleteAtTenantScopeResponse contains the response from method DeploymentsClient.BeginDeleteAtTenantScope. -type DeploymentsClientDeleteAtTenantScopeResponse struct { - // placeholder for future response values -} - -// DeploymentsClientDeleteResponse contains the response from method DeploymentsClient.BeginDelete. -type DeploymentsClientDeleteResponse struct { - // placeholder for future response values -} - -// DeploymentsClientExportTemplateAtManagementGroupScopeResponse contains the response from method DeploymentsClient.ExportTemplateAtManagementGroupScope. -type DeploymentsClientExportTemplateAtManagementGroupScopeResponse struct { - // The deployment export result. - DeploymentExportResult -} - -// DeploymentsClientExportTemplateAtScopeResponse contains the response from method DeploymentsClient.ExportTemplateAtScope. -type DeploymentsClientExportTemplateAtScopeResponse struct { - // The deployment export result. - DeploymentExportResult -} - -// DeploymentsClientExportTemplateAtSubscriptionScopeResponse contains the response from method DeploymentsClient.ExportTemplateAtSubscriptionScope. -type DeploymentsClientExportTemplateAtSubscriptionScopeResponse struct { - // The deployment export result. - DeploymentExportResult -} - -// DeploymentsClientExportTemplateAtTenantScopeResponse contains the response from method DeploymentsClient.ExportTemplateAtTenantScope. -type DeploymentsClientExportTemplateAtTenantScopeResponse struct { - // The deployment export result. - DeploymentExportResult -} - -// DeploymentsClientExportTemplateResponse contains the response from method DeploymentsClient.ExportTemplate. -type DeploymentsClientExportTemplateResponse struct { - // The deployment export result. - DeploymentExportResult -} - -// DeploymentsClientGetAtManagementGroupScopeResponse contains the response from method DeploymentsClient.GetAtManagementGroupScope. -type DeploymentsClientGetAtManagementGroupScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientGetAtScopeResponse contains the response from method DeploymentsClient.GetAtScope. -type DeploymentsClientGetAtScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientGetAtSubscriptionScopeResponse contains the response from method DeploymentsClient.GetAtSubscriptionScope. -type DeploymentsClientGetAtSubscriptionScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientGetAtTenantScopeResponse contains the response from method DeploymentsClient.GetAtTenantScope. -type DeploymentsClientGetAtTenantScopeResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientGetResponse contains the response from method DeploymentsClient.Get. -type DeploymentsClientGetResponse struct { - // Deployment information. - DeploymentExtended -} - -// DeploymentsClientListAtManagementGroupScopeResponse contains the response from method DeploymentsClient.NewListAtManagementGroupScopePager. -type DeploymentsClientListAtManagementGroupScopeResponse struct { - // List of deployments. - DeploymentListResult -} - -// DeploymentsClientListAtScopeResponse contains the response from method DeploymentsClient.NewListAtScopePager. -type DeploymentsClientListAtScopeResponse struct { - // List of deployments. - DeploymentListResult -} - -// DeploymentsClientListAtSubscriptionScopeResponse contains the response from method DeploymentsClient.NewListAtSubscriptionScopePager. -type DeploymentsClientListAtSubscriptionScopeResponse struct { - // List of deployments. - DeploymentListResult -} - -// DeploymentsClientListAtTenantScopeResponse contains the response from method DeploymentsClient.NewListAtTenantScopePager. -type DeploymentsClientListAtTenantScopeResponse struct { - // List of deployments. - DeploymentListResult -} - -// DeploymentsClientListByResourceGroupResponse contains the response from method DeploymentsClient.NewListByResourceGroupPager. -type DeploymentsClientListByResourceGroupResponse struct { - // List of deployments. - DeploymentListResult -} - -// DeploymentsClientValidateAtManagementGroupScopeResponse contains the response from method DeploymentsClient.BeginValidateAtManagementGroupScope. -type DeploymentsClientValidateAtManagementGroupScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult -} - -// DeploymentsClientValidateAtScopeResponse contains the response from method DeploymentsClient.BeginValidateAtScope. -type DeploymentsClientValidateAtScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult -} - -// DeploymentsClientValidateAtSubscriptionScopeResponse contains the response from method DeploymentsClient.BeginValidateAtSubscriptionScope. -type DeploymentsClientValidateAtSubscriptionScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult -} - -// DeploymentsClientValidateAtTenantScopeResponse contains the response from method DeploymentsClient.BeginValidateAtTenantScope. -type DeploymentsClientValidateAtTenantScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult -} - -// DeploymentsClientValidateResponse contains the response from method DeploymentsClient.BeginValidate. -type DeploymentsClientValidateResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult -} - -// DeploymentsClientWhatIfAtManagementGroupScopeResponse contains the response from method DeploymentsClient.BeginWhatIfAtManagementGroupScope. -type DeploymentsClientWhatIfAtManagementGroupScopeResponse struct { - // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - WhatIfOperationResult -} - -// DeploymentsClientWhatIfAtSubscriptionScopeResponse contains the response from method DeploymentsClient.BeginWhatIfAtSubscriptionScope. -type DeploymentsClientWhatIfAtSubscriptionScopeResponse struct { - // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - WhatIfOperationResult -} - -// DeploymentsClientWhatIfAtTenantScopeResponse contains the response from method DeploymentsClient.BeginWhatIfAtTenantScope. -type DeploymentsClientWhatIfAtTenantScopeResponse struct { - // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - WhatIfOperationResult -} - -// DeploymentsClientWhatIfResponse contains the response from method DeploymentsClient.BeginWhatIf. -type DeploymentsClientWhatIfResponse struct { - // Result of the What-If operation. Contains a list of predicted changes and a URL link to get to the next set of results. - WhatIfOperationResult -} - // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { // Result of the request to list Microsoft.Resources operations. It contains a list of operations and a URL link to get the diff --git a/sdk/resourcemanager/resources/armresources/tags_client.go b/sdk/resourcemanager/resources/armresources/tags_client.go index 2909d61c54f0..ca9713c28e3a 100644 --- a/sdk/resourcemanager/resources/armresources/tags_client.go +++ b/sdk/resourcemanager/resources/armresources/tags_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -48,7 +45,7 @@ func NewTagsClient(subscriptionID string, credential azcore.TokenCredential, opt // following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - tagName - The name of the tag to create. // - options - TagsClientCreateOrUpdateOptions contains the optional parameters for the TagsClient.CreateOrUpdate method. func (client *TagsClient) CreateOrUpdate(ctx context.Context, tagName string, options *TagsClientCreateOrUpdateOptions) (TagsClientCreateOrUpdateResponse, error) { @@ -74,7 +71,7 @@ func (client *TagsClient) CreateOrUpdate(ctx context.Context, tagName string, op } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *TagsClient) createOrUpdateCreateRequest(ctx context.Context, tagName string, options *TagsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *TagsClient) createOrUpdateCreateRequest(ctx context.Context, tagName string, _ *TagsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/tagNames/{tagName}" if tagName == "" { return nil, errors.New("parameter tagName cannot be empty") @@ -89,7 +86,7 @@ func (client *TagsClient) createOrUpdateCreateRequest(ctx context.Context, tagNa return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -108,7 +105,7 @@ func (client *TagsClient) createOrUpdateHandleResponse(resp *http.Response) (Tag // or subscription. The specified entity can have a maximum of 50 tags. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - options - TagsClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginCreateOrUpdateAtScope // method. @@ -133,7 +130,7 @@ func (client *TagsClient) BeginCreateOrUpdateAtScope(ctx context.Context, scope // The specified entity can have a maximum of 50 tags. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *TagsClient) createOrUpdateAtScope(ctx context.Context, scope string, parameters TagsResource, options *TagsClientBeginCreateOrUpdateAtScopeOptions) (*http.Response, error) { var err error const operationName = "TagsClient.BeginCreateOrUpdateAtScope" @@ -156,7 +153,7 @@ func (client *TagsClient) createOrUpdateAtScope(ctx context.Context, scope strin } // createOrUpdateAtScopeCreateRequest creates the CreateOrUpdateAtScope request. -func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsResource, options *TagsClientBeginCreateOrUpdateAtScopeOptions) (*policy.Request, error) { +func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsResource, _ *TagsClientBeginCreateOrUpdateAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/tags/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -164,7 +161,7 @@ func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -177,7 +174,7 @@ func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context // tag name. A tag value can have a maximum of 256 characters. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - tagName - The name of the tag. // - tagValue - The value of the tag to create. // - options - TagsClientCreateOrUpdateValueOptions contains the optional parameters for the TagsClient.CreateOrUpdateValue @@ -205,7 +202,7 @@ func (client *TagsClient) CreateOrUpdateValue(ctx context.Context, tagName strin } // createOrUpdateValueCreateRequest creates the CreateOrUpdateValue request. -func (client *TagsClient) createOrUpdateValueCreateRequest(ctx context.Context, tagName string, tagValue string, options *TagsClientCreateOrUpdateValueOptions) (*policy.Request, error) { +func (client *TagsClient) createOrUpdateValueCreateRequest(ctx context.Context, tagName string, tagValue string, _ *TagsClientCreateOrUpdateValueOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}" if tagName == "" { return nil, errors.New("parameter tagName cannot be empty") @@ -224,7 +221,7 @@ func (client *TagsClient) createOrUpdateValueCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -244,7 +241,7 @@ func (client *TagsClient) createOrUpdateValueHandleResponse(resp *http.Response) // for the given name must have already been deleted. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - tagName - The name of the tag. // - options - TagsClientDeleteOptions contains the optional parameters for the TagsClient.Delete method. func (client *TagsClient) Delete(ctx context.Context, tagName string, options *TagsClientDeleteOptions) (TagsClientDeleteResponse, error) { @@ -269,7 +266,7 @@ func (client *TagsClient) Delete(ctx context.Context, tagName string, options *T } // deleteCreateRequest creates the Delete request. -func (client *TagsClient) deleteCreateRequest(ctx context.Context, tagName string, options *TagsClientDeleteOptions) (*policy.Request, error) { +func (client *TagsClient) deleteCreateRequest(ctx context.Context, tagName string, _ *TagsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/tagNames/{tagName}" if tagName == "" { return nil, errors.New("parameter tagName cannot be empty") @@ -284,7 +281,7 @@ func (client *TagsClient) deleteCreateRequest(ctx context.Context, tagName strin return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -293,7 +290,7 @@ func (client *TagsClient) deleteCreateRequest(ctx context.Context, tagName strin // BeginDeleteAtScope - Deletes the entire set of tags on a resource or subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - options - TagsClientBeginDeleteAtScopeOptions contains the optional parameters for the TagsClient.BeginDeleteAtScope method. func (client *TagsClient) BeginDeleteAtScope(ctx context.Context, scope string, options *TagsClientBeginDeleteAtScopeOptions) (*runtime.Poller[TagsClientDeleteAtScopeResponse], error) { @@ -316,7 +313,7 @@ func (client *TagsClient) BeginDeleteAtScope(ctx context.Context, scope string, // DeleteAtScope - Deletes the entire set of tags on a resource or subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *TagsClient) deleteAtScope(ctx context.Context, scope string, options *TagsClientBeginDeleteAtScopeOptions) (*http.Response, error) { var err error const operationName = "TagsClient.BeginDeleteAtScope" @@ -339,7 +336,7 @@ func (client *TagsClient) deleteAtScope(ctx context.Context, scope string, optio } // deleteAtScopeCreateRequest creates the DeleteAtScope request. -func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope string, options *TagsClientBeginDeleteAtScopeOptions) (*policy.Request, error) { +func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope string, _ *TagsClientBeginDeleteAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/tags/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -347,7 +344,7 @@ func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -358,7 +355,7 @@ func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope // resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - tagName - The name of the tag. // - tagValue - The value of the tag to delete. // - options - TagsClientDeleteValueOptions contains the optional parameters for the TagsClient.DeleteValue method. @@ -384,7 +381,7 @@ func (client *TagsClient) DeleteValue(ctx context.Context, tagName string, tagVa } // deleteValueCreateRequest creates the DeleteValue request. -func (client *TagsClient) deleteValueCreateRequest(ctx context.Context, tagName string, tagValue string, options *TagsClientDeleteValueOptions) (*policy.Request, error) { +func (client *TagsClient) deleteValueCreateRequest(ctx context.Context, tagName string, tagValue string, _ *TagsClientDeleteValueOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}" if tagName == "" { return nil, errors.New("parameter tagName cannot be empty") @@ -403,7 +400,7 @@ func (client *TagsClient) deleteValueCreateRequest(ctx context.Context, tagName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -412,7 +409,7 @@ func (client *TagsClient) deleteValueCreateRequest(ctx context.Context, tagName // GetAtScope - Gets the entire set of tags on a resource or subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - options - TagsClientGetAtScopeOptions contains the optional parameters for the TagsClient.GetAtScope method. func (client *TagsClient) GetAtScope(ctx context.Context, scope string, options *TagsClientGetAtScopeOptions) (TagsClientGetAtScopeResponse, error) { @@ -438,7 +435,7 @@ func (client *TagsClient) GetAtScope(ctx context.Context, scope string, options } // getAtScopeCreateRequest creates the GetAtScope request. -func (client *TagsClient) getAtScopeCreateRequest(ctx context.Context, scope string, options *TagsClientGetAtScopeOptions) (*policy.Request, error) { +func (client *TagsClient) getAtScopeCreateRequest(ctx context.Context, scope string, _ *TagsClientGetAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/tags/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -446,7 +443,7 @@ func (client *TagsClient) getAtScopeCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -465,7 +462,7 @@ func (client *TagsClient) getAtScopeHandleResponse(resp *http.Response) (TagsCli // tags, and returns a summary of usage for each tag name and value under the given subscription. // In case of a large number of tags, this operation may return a previously cached result. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - options - TagsClientListOptions contains the optional parameters for the TagsClient.NewListPager method. func (client *TagsClient) NewListPager(options *TagsClientListOptions) *runtime.Pager[TagsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TagsClientListResponse]{ @@ -491,7 +488,7 @@ func (client *TagsClient) NewListPager(options *TagsClientListOptions) *runtime. } // listCreateRequest creates the List request. -func (client *TagsClient) listCreateRequest(ctx context.Context, options *TagsClientListOptions) (*policy.Request, error) { +func (client *TagsClient) listCreateRequest(ctx context.Context, _ *TagsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/tagNames" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -502,7 +499,7 @@ func (client *TagsClient) listCreateRequest(ctx context.Context, options *TagsCl return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -524,7 +521,7 @@ func (client *TagsClient) listHandleResponse(resp *http.Response) (TagsClientLis // allows selectively deleting tags based on given names or name/value pairs. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 // - scope - The resource scope. // - options - TagsClientBeginUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginUpdateAtScope method. func (client *TagsClient) BeginUpdateAtScope(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientBeginUpdateAtScopeOptions) (*runtime.Poller[TagsClientUpdateAtScopeResponse], error) { @@ -551,7 +548,7 @@ func (client *TagsClient) BeginUpdateAtScope(ctx context.Context, scope string, // allows selectively deleting tags based on given names or name/value pairs. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-11-01 +// Generated from API version 2025-04-01 func (client *TagsClient) updateAtScope(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientBeginUpdateAtScopeOptions) (*http.Response, error) { var err error const operationName = "TagsClient.BeginUpdateAtScope" @@ -574,7 +571,7 @@ func (client *TagsClient) updateAtScope(ctx context.Context, scope string, param } // updateAtScopeCreateRequest creates the UpdateAtScope request. -func (client *TagsClient) updateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientBeginUpdateAtScopeOptions) (*policy.Request, error) { +func (client *TagsClient) updateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsPatchResource, _ *TagsClientBeginUpdateAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/tags/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -582,7 +579,7 @@ func (client *TagsClient) updateAtScopeCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-11-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armresources/tags_client_example_test.go b/sdk/resourcemanager/resources/armresources/tags_client_example_test.go deleted file mode 100644 index 2253af1ec9ba..000000000000 --- a/sdk/resourcemanager/resources/armresources/tags_client_example_test.go +++ /dev/null @@ -1,281 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armresources_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/armresources/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutTagsResource.json -func ExampleTagsClient_BeginCreateOrUpdateAtScope_updateTagsOnAResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTagsClient().BeginCreateOrUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm", armresources.TagsResource{ - Properties: &armresources.Tags{ - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, - }, 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.TagsResource = armresources.TagsResource{ - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"), - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PutTagsSubscription.json -func ExampleTagsClient_BeginCreateOrUpdateAtScope_updateTagsOnASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTagsClient().BeginCreateOrUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armresources.TagsResource{ - Properties: &armresources.Tags{ - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, - }, 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.TagsResource = armresources.TagsResource{ - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PatchTagsResource.json -func ExampleTagsClient_BeginUpdateAtScope_updateTagsOnAResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTagsClient().BeginUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm", armresources.TagsPatchResource{ - Operation: to.Ptr(armresources.TagsPatchOperationReplace), - Properties: &armresources.Tags{ - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, - }, 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.TagsResource = armresources.TagsResource{ - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"), - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/PatchTagsSubscription.json -func ExampleTagsClient_BeginUpdateAtScope_updateTagsOnASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTagsClient().BeginUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armresources.TagsPatchResource{ - Operation: to.Ptr(armresources.TagsPatchOperationReplace), - Properties: &armresources.Tags{ - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, - }, 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.TagsResource = armresources.TagsResource{ - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/GetTagsResource.json -func ExampleTagsClient_GetAtScope_getTagsOnAResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagsClient().GetAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm", 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.TagsResource = armresources.TagsResource{ - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"), - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/GetTagsSubscription.json -func ExampleTagsClient_GetAtScope_getTagsOnASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagsClient().GetAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", 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.TagsResource = armresources.TagsResource{ - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/DeleteTagsResource.json -func ExampleTagsClient_BeginDeleteAtScope_updateTagsOnAResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTagsClient().BeginDeleteAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm", 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/91bfc0d02eaed75e6a3bfb5b9b150c84c79400ed/specification/resources/resource-manager/Microsoft.Resources/stable/2024-11-01/examples/DeleteTagsSubscription.json -func ExampleTagsClient_BeginDeleteAtScope_updateTagsOnASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewTagsClient().BeginDeleteAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", 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/resources/armresources/tags_client_live_test.go b/sdk/resourcemanager/resources/armresources/tags_client_live_test.go index 0e96b8a13f29..47338aa900ed 100644 --- a/sdk/resourcemanager/resources/armresources/tags_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/tags_client_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v3" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/time_rfc3339.go b/sdk/resourcemanager/resources/armresources/time_rfc3339.go index 1b75ec3bc085..31370b029d12 100644 --- a/sdk/resourcemanager/resources/armresources/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armresources/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -60,6 +57,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } tzOffset := tzOffsetRegex.Match(data) hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") var layout string diff --git a/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md b/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md index 560cd95d6568..de1faf7e9c70 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.3.1 (2025-04-28) +### Other Changes + + ## 1.3.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armsubscriptions/autorest.md b/sdk/resourcemanager/resources/armsubscriptions/autorest.md index 77616e287acf..2380dfc42066 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/autorest.md +++ b/sdk/resourcemanager/resources/armsubscriptions/autorest.md @@ -5,10 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/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: 1.3.0 +module-version: 1.3.1 package-subscriptions: true -tag: package-subscriptions-2022-12 ``` diff --git a/sdk/resourcemanager/resources/armsubscriptions/client.go b/sdk/resourcemanager/resources/armsubscriptions/client.go index 8c8b99a0cc7d..7a699152584e 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/client.go +++ b/sdk/resourcemanager/resources/armsubscriptions/client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -71,7 +68,7 @@ func (client *Client) CheckZonePeers(ctx context.Context, subscriptionID string, } // checkZonePeersCreateRequest creates the CheckZonePeers request. -func (client *Client) checkZonePeersCreateRequest(ctx context.Context, subscriptionID string, parameters CheckZonePeersRequest, options *ClientCheckZonePeersOptions) (*policy.Request, error) { +func (client *Client) checkZonePeersCreateRequest(ctx context.Context, subscriptionID string, parameters CheckZonePeersRequest, _ *ClientCheckZonePeersOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/" if subscriptionID == "" { return nil, errors.New("parameter subscriptionID cannot be empty") @@ -129,7 +126,7 @@ func (client *Client) Get(ctx context.Context, subscriptionID string, options *C } // getCreateRequest creates the Get request. -func (client *Client) getCreateRequest(ctx context.Context, subscriptionID string, options *ClientGetOptions) (*policy.Request, error) { +func (client *Client) getCreateRequest(ctx context.Context, subscriptionID string, _ *ClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}" if subscriptionID == "" { return nil, errors.New("parameter subscriptionID cannot be empty") @@ -183,7 +180,7 @@ func (client *Client) NewListPager(options *ClientListOptions) *runtime.Pager[Cl } // listCreateRequest creates the List request. -func (client *Client) listCreateRequest(ctx context.Context, options *ClientListOptions) (*policy.Request, error) { +func (client *Client) listCreateRequest(ctx context.Context, _ *ClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go deleted file mode 100644 index 32fdb7da7cf4..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go +++ /dev/null @@ -1,408 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armsubscriptions_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/armsubscriptions" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocations.json -func ExampleClient_NewListLocationsPager_getLocationsWithASubscriptionId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListLocationsPager("a1ffc958-d2c7-493e-9f1e-125a0477f536", &armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: 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.LocationListResult = armsubscriptions.LocationListResult{ - // Value: []*armsubscriptions.Location{ - // { - // Name: to.Ptr("eastus"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus-az2"), - // }}, - // DisplayName: to.Ptr("East US"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("37.3719"), - // Longitude: to.Ptr("-79.8164"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("westus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/westus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US"), - // }, - // { - // Name: to.Ptr("eastus2"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus2-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus2-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus2-az2"), - // }}, - // DisplayName: to.Ptr("East US 2"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus2"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("36.6681"), - // Longitude: to.Ptr("-78.3889"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("centralus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/centralus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US 2"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocationsWithExtendedLocations.json -func ExampleClient_NewListLocationsPager_getLocationsWithExtendedLocations() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListLocationsPager("a1ffc958-d2c7-493e-9f1e-125a0477f536", &armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: to.Ptr(true)}) - 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.LocationListResult = armsubscriptions.LocationListResult{ - // Value: []*armsubscriptions.Location{ - // { - // Name: to.Ptr("eastus"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus-az2"), - // }}, - // DisplayName: to.Ptr("East US"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("37.3719"), - // Longitude: to.Ptr("-79.8164"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("westus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/westus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US"), - // }, - // { - // Name: to.Ptr("eastus2"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus2-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus2-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus2-az2"), - // }}, - // DisplayName: to.Ptr("East US 2"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus2"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("36.6681"), - // Longitude: to.Ptr("-78.3889"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("centralus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/centralus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US 2"), - // }, - // { - // Name: to.Ptr("ezecustomerlabboston1"), - // Type: to.Ptr(armsubscriptions.LocationTypeEdgeZone), - // DisplayName: to.Ptr("EZE Customer Lab Boston 1"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus/edgeZones/ezecustomerlabboston1"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("42.301218"), - // Longitude: to.Ptr("-71.219038"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryExtended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) EZE Customer Lab Boston 1"), - // }, - // { - // Name: to.Ptr("ezecustomerlabhouston1"), - // Type: to.Ptr(armsubscriptions.LocationTypeEdgeZone), - // DisplayName: to.Ptr("EZE Customer Lab Houston 1"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/southcentralus/edgeZones/ezecustomerlabhouston1"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("29.9411"), - // Longitude: to.Ptr("-95.41452"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryExtended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) EZE Customer Lab Houston 1"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "291bba3f-e0a5-47bc-a099-3bdcb2a50a05", 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.Subscription = armsubscriptions.Subscription{ - // AuthorizationSource: to.Ptr("Bypassed"), - // DisplayName: to.Ptr("Example Subscription"), - // ID: to.Ptr("/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("31c75423-32d6-4322-88b7-c478bdde4858"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscriptions.json -func ExampleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().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.SubscriptionListResult = armsubscriptions.SubscriptionListResult{ - // Value: []*armsubscriptions.Subscription{ - // { - // AuthorizationSource: to.Ptr("RoleBased"), - // DisplayName: to.Ptr("Example Subscription"), - // ID: to.Ptr("/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("31c75423-32d6-4322-88b7-c478bdde4858"), - // }, - // { - // AuthorizationSource: to.Ptr("RoleBased"), - // DisplayName: to.Ptr("Example Subscription2"), - // ID: to.Ptr("/subscriptions/72ac930a-f34e-42d8-b06d-dc2a9e12ed71"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }, - // { - // TenantID: to.Ptr("f7fb6af2-321d-47c8-9c0f-b0239eaad39a"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("72ac930a-f34e-42d8-b06d-dc2a9e12ed71"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("2a0ff0de-96b2-4859-bb7c-a430d07a3e0c"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/PostCheckZonePeers.json -func ExampleClient_CheckZonePeers() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().CheckZonePeers(ctx, "8d65815f-a5b6-402f-9298-045155da7d74", armsubscriptions.CheckZonePeersRequest{ - Location: to.Ptr("eastus"), - SubscriptionIDs: []*string{ - to.Ptr("subscriptions/11111111-1111-1111-1111-111111111111")}, - }, 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.CheckZonePeersResult = armsubscriptions.CheckZonePeersResult{ - // AvailabilityZonePeers: []*armsubscriptions.AvailabilityZonePeers{ - // { - // AvailabilityZone: to.Ptr("1"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("3"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }, - // { - // AvailabilityZone: to.Ptr("2"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("2"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }, - // { - // AvailabilityZone: to.Ptr("3"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("1"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }}, - // Location: to.Ptr("eastus2"), - // SubscriptionID: to.Ptr("8d65815f-a5b6-402f-9298-045155da7d74"), - // } -} diff --git a/sdk/resourcemanager/resources/armsubscriptions/client_factory.go b/sdk/resourcemanager/resources/armsubscriptions/client_factory.go index a6c5e5a37a85..496674a170f8 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/client_factory.go +++ b/sdk/resourcemanager/resources/armsubscriptions/client_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -16,8 +13,7 @@ import ( // 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 { - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -25,36 +21,39 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - credential: credential, - options: options.Clone(), + internal: internal, }, nil } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.credential, c.options) - return subClient + return &Client{ + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewSubscriptionClient creates a new instance of SubscriptionClient. func (c *ClientFactory) NewSubscriptionClient() *SubscriptionClient { - subClient, _ := NewSubscriptionClient(c.credential, c.options) - return subClient + return &SubscriptionClient{ + internal: c.internal, + } } // NewTenantsClient creates a new instance of TenantsClient. func (c *ClientFactory) NewTenantsClient() *TenantsClient { - subClient, _ := NewTenantsClient(c.credential, c.options) - return subClient + return &TenantsClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armsubscriptions/constants.go b/sdk/resourcemanager/resources/armsubscriptions/constants.go index a8a453259982..e7057ef9d053 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/constants.go +++ b/sdk/resourcemanager/resources/armsubscriptions/constants.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -10,7 +7,7 @@ package armsubscriptions const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" - moduleVersion = "v1.3.0" + moduleVersion = "v1.3.1" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/resources/armsubscriptions/fake/internal.go b/sdk/resourcemanager/resources/armsubscriptions/fake/internal.go index 4d8bd36394ec..0e32a8018fe4 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/fake/internal.go +++ b/sdk/resourcemanager/resources/armsubscriptions/fake/internal.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -14,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/resources/armsubscriptions/fake/operations_server.go b/sdk/resourcemanager/resources/armsubscriptions/fake/operations_server.go index f3837de2418b..d59fda11a3fa 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/fake/operations_server.go +++ b/sdk/resourcemanager/resources/armsubscriptions/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armsubscriptions/fake/server.go b/sdk/resourcemanager/resources/armsubscriptions/fake/server.go index c4a6d7f96f9c..00082f8fbb34 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/fake/server.go +++ b/sdk/resourcemanager/resources/armsubscriptions/fake/server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -69,27 +66,46 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "Client.CheckZonePeers": - resp, err = s.dispatchCheckZonePeers(req) - case "Client.Get": - resp, err = s.dispatchGet(req) - case "Client.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "Client.NewListLocationsPager": - resp, err = s.dispatchNewListLocationsPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.CheckZonePeers": + res.resp, res.err = s.dispatchCheckZonePeers(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.NewListLocationsPager": + res.resp, res.err = s.dispatchNewListLocationsPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServerTransport) dispatchCheckZonePeers(req *http.Request) (*http.Response, error) { @@ -229,3 +245,9 @@ func (s *ServerTransport) dispatchNewListLocationsPager(req *http.Request) (*htt } return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armsubscriptions/fake/server_factory.go b/sdk/resourcemanager/resources/armsubscriptions/fake/server_factory.go index cffaf2c95c9a..c4cac5c633fb 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armsubscriptions/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -19,10 +16,17 @@ import ( // ServerFactory is a fake server for instances of the armsubscriptions.ClientFactory type. type ServerFactory struct { - Server Server - OperationsServer OperationsServer + // Server contains the fakes for client Client + Server Server + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // SubscriptionServer contains the fakes for client SubscriptionClient SubscriptionServer SubscriptionServer - TenantsServer TenantsServer + + // TenantsServer contains the fakes for client TenantsClient + TenantsServer TenantsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. diff --git a/sdk/resourcemanager/resources/armsubscriptions/fake/subscription_server.go b/sdk/resourcemanager/resources/armsubscriptions/fake/subscription_server.go index a25772c365bf..d4e8fe024261 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/fake/subscription_server.go +++ b/sdk/resourcemanager/resources/armsubscriptions/fake/subscription_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -48,21 +45,40 @@ func (s *SubscriptionServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "SubscriptionClient.CheckResourceName": - resp, err = s.dispatchCheckResourceName(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *SubscriptionServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if subscriptionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = subscriptionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SubscriptionClient.CheckResourceName": + res.resp, res.err = s.dispatchCheckResourceName(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *SubscriptionServerTransport) dispatchCheckResourceName(req *http.Request) (*http.Response, error) { @@ -93,3 +109,9 @@ func (s *SubscriptionServerTransport) dispatchCheckResourceName(req *http.Reques } return resp, nil } + +// set this to conditionally intercept incoming requests to SubscriptionServerTransport +var subscriptionServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armsubscriptions/fake/tenants_server.go b/sdk/resourcemanager/resources/armsubscriptions/fake/tenants_server.go index 82341b747b3a..07cf20ca3331 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/fake/tenants_server.go +++ b/sdk/resourcemanager/resources/armsubscriptions/fake/tenants_server.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -51,21 +48,40 @@ func (t *TenantsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TenantsClient.NewListPager": - resp, err = t.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TenantsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tenantsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tenantsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TenantsClient.NewListPager": + res.resp, res.err = t.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TenantsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (t *TenantsServerTransport) dispatchNewListPager(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to TenantsServerTransport +var tenantsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/resources/armsubscriptions/go.mod b/sdk/resourcemanager/resources/armsubscriptions/go.mod index 394eae9c1c21..599c5ea026ee 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/go.mod +++ b/sdk/resourcemanager/resources/armsubscriptions/go.mod @@ -4,13 +4,13 @@ go 1.23.0 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.10.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armsubscriptions/models.go b/sdk/resourcemanager/resources/armsubscriptions/models.go index 76ddb14d0a90..044fbb93f7df 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/models.go +++ b/sdk/resourcemanager/resources/armsubscriptions/models.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armsubscriptions/models_serde.go b/sdk/resourcemanager/resources/armsubscriptions/models_serde.go index 586cf8640841..7044c768b5ed 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/models_serde.go +++ b/sdk/resourcemanager/resources/armsubscriptions/models_serde.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -1053,7 +1050,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/resources/armsubscriptions/operations_client.go b/sdk/resourcemanager/resources/armsubscriptions/operations_client.go index 39522167634c..aeaed84b9f66 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/operations_client.go +++ b/sdk/resourcemanager/resources/armsubscriptions/operations_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -65,7 +62,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/sdk/resourcemanager/resources/armsubscriptions/options.go b/sdk/resourcemanager/resources/armsubscriptions/options.go index fee9ef953de4..eb9e0428fc81 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/options.go +++ b/sdk/resourcemanager/resources/armsubscriptions/options.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armsubscriptions/response_types.go b/sdk/resourcemanager/resources/armsubscriptions/responses.go similarity index 98% rename from sdk/resourcemanager/resources/armsubscriptions/response_types.go rename to sdk/resourcemanager/resources/armsubscriptions/responses.go index 9d684b4761be..3bf39b05297f 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/response_types.go +++ b/sdk/resourcemanager/resources/armsubscriptions/responses.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go b/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go index b45d6a248c3b..e7d1a11be0fa 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go +++ b/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. diff --git a/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go deleted file mode 100644 index b49b1c435dea..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go +++ /dev/null @@ -1,43 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armsubscriptions_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/CheckResourceName.json -func ExampleSubscriptionClient_CheckResourceName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionClient().CheckResourceName(ctx, &armsubscriptions.SubscriptionClientCheckResourceNameOptions{ResourceNameDefinition: 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.CheckResourceNameResult = armsubscriptions.CheckResourceNameResult{ - // Name: to.Ptr("isxbox"), - // Type: to.Ptr("ResourceProviderTestHost/TestResourceType"), - // Status: to.Ptr(armsubscriptions.ResourceNameStatusAllowed), - // } -} diff --git a/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go b/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go index 2ee5b85a9298..84e6d8adc57e 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go +++ b/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go @@ -1,6 +1,3 @@ -//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. DO NOT EDIT. @@ -65,7 +62,7 @@ func (client *TenantsClient) NewListPager(options *TenantsClientListOptions) *ru } // listCreateRequest creates the List request. -func (client *TenantsClient) listCreateRequest(ctx context.Context, options *TenantsClientListOptions) (*policy.Request, error) { +func (client *TenantsClient) listCreateRequest(ctx context.Context, _ *TenantsClientListOptions) (*policy.Request, error) { urlPath := "/tenants" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { diff --git a/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go deleted file mode 100644 index fa85a8e6395d..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go +++ /dev/null @@ -1,82 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armsubscriptions_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetTenants.json -func ExampleTenantsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTenantsClient().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.TenantListResult = armsubscriptions.TenantListResult{ - // Value: []*armsubscriptions.TenantIDDescription{ - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("aad50.ccsctp.net"), - // DisplayName: to.Ptr("Test_Test_aad50"), - // Domains: []*string{ - // to.Ptr("aad50.ccsctp.net")}, - // ID: to.Ptr("/tenants/a70a1586-9c4a-4373-b907-1d310660dbd1"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryManagedBy), - // TenantID: to.Ptr("a70a1586-9c4a-4373-b907-1d310660dbd1"), - // TenantType: to.Ptr("AAD"), - // }, - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("auxteststagemanual.ccsctp.net"), - // DisplayName: to.Ptr("Contoso Corp."), - // Domains: []*string{ - // to.Ptr("auxteststagemanual.ccsctp.net")}, - // ID: to.Ptr("/tenants/83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryHome), - // TenantID: to.Ptr("83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // TenantType: to.Ptr("AAD"), - // }, - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("rdvmohoro.ccsctp.net"), - // DisplayName: to.Ptr("TEST_TEST_RDV"), - // Domains: []*string{ - // to.Ptr("rdvmohoro.ccsctp.net"), - // to.Ptr("rdvmohoro.mail.ccsctp.net"), - // to.Ptr("rdvmohoro.com")}, - // ID: to.Ptr("/tenants/daea2e9b-847b-4c93-850d-2aa6f2d7af33"), - // TenantBrandingLogoURL: to.Ptr("logo1.logo.rdvmohoro.com"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryProjectedBy), - // TenantID: to.Ptr("daea2e9b-847b-4c93-850d-2aa6f2d7af33"), - // TenantType: to.Ptr("AAD"), - // }}, - // } - } -}