diff --git a/sdk/resourcemanager/resources/armlinks/CHANGELOG.md b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md index 678e3a1a36b8..b860343c4ef6 100644 --- a/sdk/resourcemanager/resources/armlinks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md @@ -1,5 +1,14 @@ # Release History +## 1.1.0 (2023-03-25) +### Features Added + +- New function `NewClientFactory(string, azcore.TokenCredential, *arm.ClientOptions) (*ClientFactory, error)` +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `*ClientFactory.NewResourceLinksClient() *ResourceLinksClient` +- New struct `ClientFactory` + + ## 1.0.0 (2022-05-16) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlinks` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/resources/armlinks/autorest.md b/sdk/resourcemanager/resources/armlinks/autorest.md index 46cf034f953f..d1c317d5d1a5 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.0.0 +module-version: 1.1.0 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 new file mode 100644 index 000000000000..0a6acdd93eda --- /dev/null +++ b/sdk/resourcemanager/resources/armlinks/client_factory.go @@ -0,0 +1,49 @@ +//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 armlinks + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourceLinksClient() *ResourceLinksClient { + subClient, _ := NewResourceLinksClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_constants.go b/sdk/resourcemanager/resources/armlinks/constants.go similarity index 90% rename from sdk/resourcemanager/resources/armlinks/zz_generated_constants.go rename to sdk/resourcemanager/resources/armlinks/constants.go index f67616136de4..813498521f63 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_constants.go +++ b/sdk/resourcemanager/resources/armlinks/constants.go @@ -5,10 +5,11 @@ // 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 armlinks const ( moduleName = "armlinks" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) diff --git a/sdk/resourcemanager/resources/armlinks/go.mod b/sdk/resourcemanager/resources/armlinks/go.mod index 3a720fa45ea0..b3af0441ac61 100644 --- a/sdk/resourcemanager/resources/armlinks/go.mod +++ b/sdk/resourcemanager/resources/armlinks/go.mod @@ -2,10 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlinks go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/text v0.3.7 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armlinks/go.sum b/sdk/resourcemanager/resources/armlinks/go.sum index 3f874a3bc5a6..d39a720dafd8 100644 --- a/sdk/resourcemanager/resources/armlinks/go.sum +++ b/sdk/resourcemanager/resources/armlinks/go.sum @@ -1,12 +1,12 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_models.go b/sdk/resourcemanager/resources/armlinks/models.go similarity index 94% rename from sdk/resourcemanager/resources/armlinks/zz_generated_models.go rename to sdk/resourcemanager/resources/armlinks/models.go index a8b72785668d..09f7aa89f4fe 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_models.go +++ b/sdk/resourcemanager/resources/armlinks/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlinks @@ -42,7 +43,7 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -59,7 +60,7 @@ type ResourceLink struct { Name *string `json:"name,omitempty" azure:"ro"` // READ-ONLY; The resource link object. - Type interface{} `json:"type,omitempty" azure:"ro"` + Type any `json:"type,omitempty" azure:"ro"` } // ResourceLinkFilter - Resource link filter. @@ -104,7 +105,7 @@ type ResourceLinksClientGetOptions struct { // placeholder for future optional parameters } -// ResourceLinksClientListAtSourceScopeOptions contains the optional parameters for the ResourceLinksClient.ListAtSourceScope +// ResourceLinksClientListAtSourceScopeOptions contains the optional parameters for the ResourceLinksClient.NewListAtSourceScopePager // method. type ResourceLinksClientListAtSourceScopeOptions struct { // The filter to apply when getting resource links. To get links only at the specified scope (not below the scope), use Filter.atScope().. @@ -112,7 +113,7 @@ type ResourceLinksClientListAtSourceScopeOptions struct { Filter *string } -// ResourceLinksClientListAtSubscriptionOptions contains the optional parameters for the ResourceLinksClient.ListAtSubscription +// ResourceLinksClientListAtSubscriptionOptions contains the optional parameters for the ResourceLinksClient.NewListAtSubscriptionPager // method. type ResourceLinksClientListAtSubscriptionOptions struct { // The filter to apply on the list resource links operation. The supported filter for list resource links is targetId. For diff --git a/sdk/resourcemanager/resources/armlinks/models_serde.go b/sdk/resourcemanager/resources/armlinks/models_serde.go new file mode 100644 index 000000000000..4a5600a274fb --- /dev/null +++ b/sdk/resourcemanager/resources/armlinks/models_serde.go @@ -0,0 +1,270 @@ +//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 armlinks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceLink. +func (r ResourceLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", &r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLink. +func (r *ResourceLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceLinkFilter. +func (r ResourceLinkFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetId", r.TargetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLinkFilter. +func (r *ResourceLinkFilter) 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 "targetId": + err = unpopulate(val, "TargetID", &r.TargetID) + 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 ResourceLinkProperties. +func (r ResourceLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "notes", r.Notes) + populate(objectMap, "sourceId", r.SourceID) + populate(objectMap, "targetId", r.TargetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLinkProperties. +func (r *ResourceLinkProperties) 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 "notes": + err = unpopulate(val, "Notes", &r.Notes) + delete(rawMsg, key) + case "sourceId": + err = unpopulate(val, "SourceID", &r.SourceID) + delete(rawMsg, key) + case "targetId": + err = unpopulate(val, "TargetID", &r.TargetID) + 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 ResourceLinkResult. +func (r ResourceLinkResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLinkResult. +func (r *ResourceLinkResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_operations_client.go b/sdk/resourcemanager/resources/armlinks/operations_client.go similarity index 77% rename from sdk/resourcemanager/resources/armlinks/zz_generated_operations_client.go rename to sdk/resourcemanager/resources/armlinks/operations_client.go index 8de802d76232..3d1c08dc739b 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_operations_client.go +++ b/sdk/resourcemanager/resources/armlinks/operations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlinks @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all of the available Microsoft.Resources REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2016-09-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Resources/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_resourcelinks_client.go b/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go similarity index 78% rename from sdk/resourcemanager/resources/armlinks/zz_generated_resourcelinks_client.go rename to sdk/resourcemanager/resources/armlinks/resourcelinks_client.go index 2f849054fc7e..7856e5cb23a1 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_resourcelinks_client.go +++ b/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armlinks @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,51 +24,43 @@ import ( // ResourceLinksClient contains the methods for the ResourceLinks group. // Don't use this type directly, use NewResourceLinksClient() instead. type ResourceLinksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewResourceLinksClient creates a new instance of ResourceLinksClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewResourceLinksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceLinksClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ResourceLinksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourceLinksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates or updates a resource link between the specified resources. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2016-09-01 -// linkID - The fully qualified ID of the resource link. Use the format, -// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. -// For example, -// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink -// parameters - Parameters for creating or updating a resource link. -// options - ResourceLinksClientCreateOrUpdateOptions contains the optional parameters for the ResourceLinksClient.CreateOrUpdate -// method. +// - linkID - The fully qualified ID of the resource link. Use the format, +// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. +// For example, +// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink +// - parameters - Parameters for creating or updating a resource link. +// - options - ResourceLinksClientCreateOrUpdateOptions contains the optional parameters for the ResourceLinksClient.CreateOrUpdate +// method. func (client *ResourceLinksClient) CreateOrUpdate(ctx context.Context, linkID string, parameters ResourceLink, options *ResourceLinksClientCreateOrUpdateOptions) (ResourceLinksClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, linkID, parameters, options) if err != nil { return ResourceLinksClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceLinksClientCreateOrUpdateResponse{}, err } @@ -83,7 +74,7 @@ func (client *ResourceLinksClient) CreateOrUpdate(ctx context.Context, linkID st func (client *ResourceLinksClient) createOrUpdateCreateRequest(ctx context.Context, linkID string, parameters ResourceLink, options *ResourceLinksClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{linkId}" urlPath = strings.ReplaceAll(urlPath, "{linkId}", linkID) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -105,18 +96,19 @@ func (client *ResourceLinksClient) createOrUpdateHandleResponse(resp *http.Respo // Delete - Deletes a resource link with the specified ID. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2016-09-01 -// linkID - The fully qualified ID of the resource link. Use the format, -// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. -// For example, -// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink -// options - ResourceLinksClientDeleteOptions contains the optional parameters for the ResourceLinksClient.Delete method. +// - linkID - The fully qualified ID of the resource link. Use the format, +// /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. +// For example, +// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink +// - options - ResourceLinksClientDeleteOptions contains the optional parameters for the ResourceLinksClient.Delete method. func (client *ResourceLinksClient) Delete(ctx context.Context, linkID string, options *ResourceLinksClientDeleteOptions) (ResourceLinksClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, linkID, options) if err != nil { return ResourceLinksClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceLinksClientDeleteResponse{}, err } @@ -130,7 +122,7 @@ func (client *ResourceLinksClient) Delete(ctx context.Context, linkID string, op func (client *ResourceLinksClient) deleteCreateRequest(ctx context.Context, linkID string, options *ResourceLinksClientDeleteOptions) (*policy.Request, error) { urlPath := "/{linkId}" urlPath = strings.ReplaceAll(urlPath, "{linkId}", linkID) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -142,15 +134,16 @@ func (client *ResourceLinksClient) deleteCreateRequest(ctx context.Context, link // Get - Gets a resource link with the specified ID. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2016-09-01 -// linkID - The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink -// options - ResourceLinksClientGetOptions contains the optional parameters for the ResourceLinksClient.Get method. +// - linkID - The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink +// - options - ResourceLinksClientGetOptions contains the optional parameters for the ResourceLinksClient.Get method. func (client *ResourceLinksClient) Get(ctx context.Context, linkID string, options *ResourceLinksClientGetOptions) (ResourceLinksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, linkID, options) if err != nil { return ResourceLinksClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceLinksClientGetResponse{}, err } @@ -164,7 +157,7 @@ func (client *ResourceLinksClient) Get(ctx context.Context, linkID string, optio func (client *ResourceLinksClient) getCreateRequest(ctx context.Context, linkID string, options *ResourceLinksClientGetOptions) (*policy.Request, error) { urlPath := "/{linkId}" urlPath = strings.ReplaceAll(urlPath, "{linkId}", linkID) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -185,13 +178,13 @@ func (client *ResourceLinksClient) getHandleResponse(resp *http.Response) (Resou } // NewListAtSourceScopePager - Gets a list of resource links at and below the specified source scope. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2016-09-01 -// scope - The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and -// under a resource group, set the scope to -// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. -// options - ResourceLinksClientListAtSourceScopeOptions contains the optional parameters for the ResourceLinksClient.ListAtSourceScope -// method. +// - scope - The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and +// under a resource group, set the scope to +// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. +// - options - ResourceLinksClientListAtSourceScopeOptions contains the optional parameters for the ResourceLinksClient.NewListAtSourceScopePager +// method. func (client *ResourceLinksClient) NewListAtSourceScopePager(scope string, options *ResourceLinksClientListAtSourceScopeOptions) *runtime.Pager[ResourceLinksClientListAtSourceScopeResponse] { return runtime.NewPager(runtime.PagingHandler[ResourceLinksClientListAtSourceScopeResponse]{ More: func(page ResourceLinksClientListAtSourceScopeResponse) bool { @@ -208,7 +201,7 @@ func (client *ResourceLinksClient) NewListAtSourceScopePager(scope string, optio if err != nil { return ResourceLinksClientListAtSourceScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceLinksClientListAtSourceScopeResponse{}, err } @@ -224,7 +217,7 @@ func (client *ResourceLinksClient) NewListAtSourceScopePager(scope string, optio func (client *ResourceLinksClient) listAtSourceScopeCreateRequest(ctx context.Context, scope string, options *ResourceLinksClientListAtSourceScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/links" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -248,10 +241,10 @@ func (client *ResourceLinksClient) listAtSourceScopeHandleResponse(resp *http.Re } // NewListAtSubscriptionPager - Gets all the linked resources for the subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2016-09-01 -// options - ResourceLinksClientListAtSubscriptionOptions contains the optional parameters for the ResourceLinksClient.ListAtSubscription -// method. +// - options - ResourceLinksClientListAtSubscriptionOptions contains the optional parameters for the ResourceLinksClient.NewListAtSubscriptionPager +// method. func (client *ResourceLinksClient) NewListAtSubscriptionPager(options *ResourceLinksClientListAtSubscriptionOptions) *runtime.Pager[ResourceLinksClientListAtSubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ResourceLinksClientListAtSubscriptionResponse]{ More: func(page ResourceLinksClientListAtSubscriptionResponse) bool { @@ -268,7 +261,7 @@ func (client *ResourceLinksClient) NewListAtSubscriptionPager(options *ResourceL if err != nil { return ResourceLinksClientListAtSubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceLinksClientListAtSubscriptionResponse{}, err } @@ -287,7 +280,7 @@ func (client *ResourceLinksClient) listAtSubscriptionCreateRequest(ctx context.C return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_response_types.go b/sdk/resourcemanager/resources/armlinks/response_types.go similarity index 87% rename from sdk/resourcemanager/resources/armlinks/zz_generated_response_types.go rename to sdk/resourcemanager/resources/armlinks/response_types.go index 8dd273290ed0..057a520fa12a 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_response_types.go +++ b/sdk/resourcemanager/resources/armlinks/response_types.go @@ -5,10 +5,11 @@ // 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 armlinks -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } @@ -28,12 +29,12 @@ type ResourceLinksClientGetResponse struct { ResourceLink } -// ResourceLinksClientListAtSourceScopeResponse contains the response from method ResourceLinksClient.ListAtSourceScope. +// ResourceLinksClientListAtSourceScopeResponse contains the response from method ResourceLinksClient.NewListAtSourceScopePager. type ResourceLinksClientListAtSourceScopeResponse struct { ResourceLinkResult } -// ResourceLinksClientListAtSubscriptionResponse contains the response from method ResourceLinksClient.ListAtSubscription. +// ResourceLinksClientListAtSubscriptionResponse contains the response from method ResourceLinksClient.NewListAtSubscriptionPager. type ResourceLinksClientListAtSubscriptionResponse struct { ResourceLinkResult }