diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md index a4ffed40ebaa..d7db631c9a49 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md @@ -1,5 +1,33 @@ # Release History +## 1.3.0-beta.2 (2025-04-22) +### Breaking Changes + +- Function `*CustomLocationsClient.NewListOperationsPager` has been removed +- Operation `*ResourceSyncRulesClient.BeginUpdate` has been changed to non-LRO, use `*ResourceSyncRulesClient.Update` instead. +- Struct `CustomLocationOperation` has been removed +- Struct `CustomLocationOperationValueDisplay` has been removed +- Struct `CustomLocationOperationsList` has been removed +- Struct `EnabledResourceTypesListResult` has been removed +- Field `EnabledResourceTypesListResult` of struct `CustomLocationsClientListEnabledResourceTypesResponse` has been removed + +### Features Added + +- New enum type `ActionType` with values `ActionTypeInternal` +- New enum type `Origin` with values `OriginSystem`, `OriginUser`, `OriginUserSystem` +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `NewOperationsClient(azcore.TokenCredential, *arm.ClientOptions) (*OperationsClient, error)` +- New function `*OperationsClient.NewListPager(*OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]` +- New struct `EnabledResourceTypeListResult` +- New struct `Operation` +- New struct `OperationDisplay` +- New struct `OperationListResult` +- New anonymous field `EnabledResourceTypeListResult` in struct `CustomLocationsClientListEnabledResourceTypesResponse` +- New field `SystemData` in struct `ProxyResource` +- New field `SystemData` in struct `Resource` +- New field `SystemData` in struct `TrackedResource` + + ## 1.3.0-beta.1 (2023-11-30) ### Features Added diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md index 6362fb552e32..98e396f32e35 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md @@ -5,8 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/extendedlocation/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/extendedlocation/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.3.0-beta.1 +module-version: 1.3.0-beta.2 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/client_factory.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/client_factory.go index fa5f6aac504b..0ad11532b9f7 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/client_factory.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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,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 } // NewCustomLocationsClient creates a new instance of CustomLocationsClient. func (c *ClientFactory) NewCustomLocationsClient() *CustomLocationsClient { - subClient, _ := NewCustomLocationsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &CustomLocationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } } // NewResourceSyncRulesClient creates a new instance of ResourceSyncRulesClient. func (c *ClientFactory) NewResourceSyncRulesClient() *ResourceSyncRulesClient { - subClient, _ := NewResourceSyncRulesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ResourceSyncRulesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/constants.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/constants.go index c8f5ab7ec0f3..7127370875f3 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/constants.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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,9 +7,23 @@ package armextendedlocation const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/armextendedlocation" - moduleVersion = "v1.3.0-beta.1" + moduleVersion = "v1.3.0-beta.2" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" ) +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -47,6 +58,25 @@ func PossibleHostTypeValues() []HostType { } } +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + // ResourceIdentityType - The identity type. type ResourceIdentityType string diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client.go index 8042848088a9..ba8d63b46c1f 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_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. @@ -96,7 +93,7 @@ func (client *CustomLocationsClient) createOrUpdate(ctx context.Context, resourc } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *CustomLocationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocation, options *CustomLocationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocation, _ *CustomLocationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -176,7 +173,7 @@ func (client *CustomLocationsClient) deleteOperation(ctx context.Context, resour } // deleteCreateRequest creates the Delete request. -func (client *CustomLocationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *CustomLocationsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -234,7 +231,7 @@ func (client *CustomLocationsClient) FindTargetResourceGroup(ctx context.Context } // findTargetResourceGroupCreateRequest creates the FindTargetResourceGroup request. -func (client *CustomLocationsClient) findTargetResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocationFindTargetResourceGroupProperties, options *CustomLocationsClientFindTargetResourceGroupOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) findTargetResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocationFindTargetResourceGroupProperties, _ *CustomLocationsClientFindTargetResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/findTargetResourceGroup" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -301,7 +298,7 @@ func (client *CustomLocationsClient) Get(ctx context.Context, resourceGroupName } // getCreateRequest creates the Get request. -func (client *CustomLocationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsClientGetOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *CustomLocationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -366,7 +363,7 @@ func (client *CustomLocationsClient) NewListByResourceGroupPager(resourceGroupNa } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *CustomLocationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CustomLocationsClientListByResourceGroupOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *CustomLocationsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -426,7 +423,7 @@ func (client *CustomLocationsClient) NewListBySubscriptionPager(options *CustomL } // listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *CustomLocationsClient) listBySubscriptionCreateRequest(ctx context.Context, options *CustomLocationsClientListBySubscriptionOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *CustomLocationsClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -483,7 +480,7 @@ func (client *CustomLocationsClient) NewListEnabledResourceTypesPager(resourceGr } // listEnabledResourceTypesCreateRequest creates the ListEnabledResourceTypes request. -func (client *CustomLocationsClient) listEnabledResourceTypesCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsClientListEnabledResourceTypesOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) listEnabledResourceTypesCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *CustomLocationsClientListEnabledResourceTypesOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -511,63 +508,12 @@ func (client *CustomLocationsClient) listEnabledResourceTypesCreateRequest(ctx c // listEnabledResourceTypesHandleResponse handles the ListEnabledResourceTypes response. func (client *CustomLocationsClient) listEnabledResourceTypesHandleResponse(resp *http.Response) (CustomLocationsClientListEnabledResourceTypesResponse, error) { result := CustomLocationsClientListEnabledResourceTypesResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.EnabledResourceTypesListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.EnabledResourceTypeListResult); err != nil { return CustomLocationsClientListEnabledResourceTypesResponse{}, err } return result, nil } -// NewListOperationsPager - Lists all available Custom Locations operations. -// -// Generated from API version 2021-08-31-preview -// - options - CustomLocationsClientListOperationsOptions contains the optional parameters for the CustomLocationsClient.NewListOperationsPager -// method. -func (client *CustomLocationsClient) NewListOperationsPager(options *CustomLocationsClientListOperationsOptions) *runtime.Pager[CustomLocationsClientListOperationsResponse] { - return runtime.NewPager(runtime.PagingHandler[CustomLocationsClientListOperationsResponse]{ - More: func(page CustomLocationsClientListOperationsResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *CustomLocationsClientListOperationsResponse) (CustomLocationsClientListOperationsResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CustomLocationsClient.NewListOperationsPager") - 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.listOperationsCreateRequest(ctx, options) - }, nil) - if err != nil { - return CustomLocationsClientListOperationsResponse{}, err - } - return client.listOperationsHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listOperationsCreateRequest creates the ListOperations request. -func (client *CustomLocationsClient) listOperationsCreateRequest(ctx context.Context, options *CustomLocationsClientListOperationsOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.ExtendedLocation/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", "2021-08-31-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listOperationsHandleResponse handles the ListOperations response. -func (client *CustomLocationsClient) listOperationsHandleResponse(resp *http.Response) (CustomLocationsClientListOperationsResponse, error) { - result := CustomLocationsClientListOperationsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.CustomLocationOperationsList); err != nil { - return CustomLocationsClientListOperationsResponse{}, err - } - return result, nil -} - // Update - Updates a Custom Location with the specified Resource Name in the specified Resource Group and Subscription. // If the operation fails it returns an *azcore.ResponseError type. // @@ -599,7 +545,7 @@ func (client *CustomLocationsClient) Update(ctx context.Context, resourceGroupNa } // updateCreateRequest creates the Update request. -func (client *CustomLocationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters PatchableCustomLocations, options *CustomLocationsClientUpdateOptions) (*policy.Request, error) { +func (client *CustomLocationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters PatchableCustomLocations, _ *CustomLocationsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client_example_test.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client_example_test.go deleted file mode 100644 index b4f8f203ea9e..000000000000 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client_example_test.go +++ /dev/null @@ -1,699 +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 armextendedlocation_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/extendedlocation/armextendedlocation" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListOperations.json -func ExampleCustomLocationsClient_NewListOperationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCustomLocationsClient().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.CustomLocationOperationsList = armextendedlocation.CustomLocationOperationsList{ - // Value: []*armextendedlocation.CustomLocationOperation{ - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/operations/read"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Gets list of Available Operations for Custom Locations"), - // Operation: to.Ptr("List Available Operations for Custom Locations"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Operations"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/register/action"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Registers the subscription for Custom Location resource provider and enables the creation of Custom Location."), - // Operation: to.Ptr("Registers the Custom Location Resource Provider"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Locations Resource Provider"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/unregister/action"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("UnRegisters the subscription for Custom Location resource provider and disables the creation of Custom Location."), - // Operation: to.Ptr("UnRegisters the Custom Location Resource Provider"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Locations Resource Provider"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/read"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Gets an Custom Location resource"), - // Operation: to.Ptr("Get Custom Location"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Locations"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/write"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Creates or Updates Custom Location resource"), - // Operation: to.Ptr("Create or Update Custom Location"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Locations"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/deploy/action"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Deploy permissions to a Custom Location resource"), - // Operation: to.Ptr("Deploy permissions to Custom Location"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Locations"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/delete"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Deletes Custom Location resource"), - // Operation: to.Ptr("Delete Custom Location"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Locations"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/enabledresourcetypes/read"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Gets EnabledResourceTypes for a Custom Location resource"), - // Operation: to.Ptr("Get EnabledResourceTypes for Custom Location"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Locations"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/locations/operationsstatus/read"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Get result of Custom Location operation"), - // Operation: to.Ptr("Get status of Custom Location operation"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Location Operation Status"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/locations/operationresults/read"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Get result of Custom Location operation"), - // Operation: to.Ptr("Get the status of Custom Location operation"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Custom Location Operation Result"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules/read"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Gets a Resource Sync Rule resource"), - // Operation: to.Ptr("Get Resource Sync Rule"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Resource Sync Rules"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules/write"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Creates or Updates a Resource Sync Rule resource"), - // Operation: to.Ptr("Create or Update Resource Sync Rule"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Resource Sync Rules"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules/delete"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Deletes Resource Sync Rule resource"), - // Operation: to.Ptr("Delete Resource Sync Rule"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Resource Sync Rules"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }, - // { - // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/findTargetResourceGroup/action"), - // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ - // Description: to.Ptr("Evaluate Labels Against Resource Sync Rules to Get Target Resource Group"), - // Operation: to.Ptr("Find Target Resource Group Action"), - // Provider: to.Ptr("Microsoft.ExtendedLocation"), - // Resource: to.Ptr("Resource Sync Rules"), - // }, - // IsDataAction: to.Ptr(false), - // Origin: to.Ptr("user,system"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListBySubscription.json -func ExampleCustomLocationsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCustomLocationsClient().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.CustomLocationListResult = armextendedlocation.CustomLocationListResult{ - // Value: []*armextendedlocation.CustomLocation{ - // { - // Name: to.Ptr("customLocation01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), - // Location: to.Ptr("West US"), - // Identity: &armextendedlocation.Identity{ - // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), - // }, - // Properties: &armextendedlocation.CustomLocationProperties{ - // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - // Type: to.Ptr("KubeConfig"), - // }, - // ClusterExtensionIDs: []*string{ - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - // DisplayName: to.Ptr("customLocationLocation01"), - // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - // Namespace: to.Ptr("namespace01"), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }, - // { - // Name: to.Ptr("customLocation02"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), - // Location: to.Ptr("West US"), - // Identity: &armextendedlocation.Identity{ - // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), - // }, - // Properties: &armextendedlocation.CustomLocationProperties{ - // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - // Type: to.Ptr("KubeConfig"), - // }, - // ClusterExtensionIDs: []*string{ - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - // DisplayName: to.Ptr("customLocationLocation02"), - // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02"), - // Namespace: to.Ptr("namespace02"), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListByResourceGroup.json -func ExampleCustomLocationsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCustomLocationsClient().NewListByResourceGroupPager("testresourcegroup", 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.CustomLocationListResult = armextendedlocation.CustomLocationListResult{ - // Value: []*armextendedlocation.CustomLocation{ - // { - // Name: to.Ptr("customLocation01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), - // Location: to.Ptr("West US"), - // Identity: &armextendedlocation.Identity{ - // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), - // }, - // Properties: &armextendedlocation.CustomLocationProperties{ - // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - // Type: to.Ptr("KubeConfig"), - // }, - // ClusterExtensionIDs: []*string{ - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - // DisplayName: to.Ptr("customLocationLocation01"), - // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - // Namespace: to.Ptr("namespace01"), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }, - // { - // Name: to.Ptr("customLocation02"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), - // Location: to.Ptr("West US"), - // Identity: &armextendedlocation.Identity{ - // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), - // }, - // Properties: &armextendedlocation.CustomLocationProperties{ - // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - // Type: to.Ptr("KubeConfig"), - // }, - // ClusterExtensionIDs: []*string{ - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - // DisplayName: to.Ptr("customLocationLocation02"), - // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02"), - // Namespace: to.Ptr("namespace02"), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsGet.json -func ExampleCustomLocationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCustomLocationsClient().Get(ctx, "testresourcegroup", "customLocation01", 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.CustomLocation = armextendedlocation.CustomLocation{ - // Name: to.Ptr("customLocation01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01"), - // Location: to.Ptr("West US"), - // Identity: &armextendedlocation.Identity{ - // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), - // }, - // Properties: &armextendedlocation.CustomLocationProperties{ - // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - // Type: to.Ptr("KubeConfig"), - // }, - // ClusterExtensionIDs: []*string{ - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - // DisplayName: to.Ptr("customLocationLocation01"), - // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - // Namespace: to.Ptr("namespace01"), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsCreate_Update.json -func ExampleCustomLocationsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCustomLocationsClient().BeginCreateOrUpdate(ctx, "testresourcegroup", "customLocation01", armextendedlocation.CustomLocation{ - Location: to.Ptr("West US"), - Identity: &armextendedlocation.Identity{ - Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armextendedlocation.CustomLocationProperties{ - Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - Type: to.Ptr("KubeConfig"), - Value: to.Ptr(""), - }, - ClusterExtensionIDs: []*string{ - to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedCluster/someCluster/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - DisplayName: to.Ptr("customLocationLocation01"), - HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - Namespace: to.Ptr("namespace01"), - }, - }, 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.CustomLocation = armextendedlocation.CustomLocation{ - // Name: to.Ptr("customLocation01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01"), - // Location: to.Ptr("West US"), - // Identity: &armextendedlocation.Identity{ - // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), - // }, - // Properties: &armextendedlocation.CustomLocationProperties{ - // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - // Type: to.Ptr("KubeConfig"), - // }, - // ClusterExtensionIDs: []*string{ - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - // DisplayName: to.Ptr("customLocationLocation01"), - // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - // Namespace: to.Ptr("namespace01"), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsDelete.json -func ExampleCustomLocationsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCustomLocationsClient().BeginDelete(ctx, "testresourcegroup", "customLocation01", 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/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsPatch.json -func ExampleCustomLocationsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCustomLocationsClient().Update(ctx, "testresourcegroup", "customLocation01", armextendedlocation.PatchableCustomLocations{ - Identity: &armextendedlocation.Identity{ - Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armextendedlocation.CustomLocationProperties{ - ClusterExtensionIDs: []*string{ - to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension"), - to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/barExtension")}, - }, - Tags: map[string]*string{ - "archv3": to.Ptr(""), - "tier": to.Ptr("testing"), - }, - }, 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.CustomLocation = armextendedlocation.CustomLocation{ - // Name: to.Ptr("customLocation01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01"), - // Location: to.Ptr("West US"), - // Tags: map[string]*string{ - // "archv3": to.Ptr(""), - // "tier": to.Ptr("testing"), - // }, - // Identity: &armextendedlocation.Identity{ - // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), - // }, - // Properties: &armextendedlocation.CustomLocationProperties{ - // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - // Type: to.Ptr("KubeConfig"), - // }, - // ClusterExtensionIDs: []*string{ - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension"), - // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/barExtension")}, - // DisplayName: to.Ptr("customLocationLocation01"), - // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - // Namespace: to.Ptr("namespace01"), - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListEnabledResourceTypes.json -func ExampleCustomLocationsClient_NewListEnabledResourceTypesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCustomLocationsClient().NewListEnabledResourceTypesPager("testresourcegroup", "customLocation01", 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.EnabledResourceTypesListResult = armextendedlocation.EnabledResourceTypesListResult{ - // Value: []*armextendedlocation.EnabledResourceType{ - // { - // Name: to.Ptr("d016ecf26dae90594806aca3c1a6326c668357037f68103587edf2e657824737"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/enabledResourceTypes"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/enabledResourceTypes/d016ecf26dae90594806aca3c1a6326c668357037f68103587edf2e657824737"), - // Properties: &armextendedlocation.EnabledResourceTypeProperties{ - // ClusterExtensionID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.Kubernetes/connectedClusters/cldfe2econnectedcluster/providers/Microsoft.KubernetesConfiguration/extensions/vmware-extension"), - // ExtensionType: to.Ptr("arc-vmware"), - // TypesMetadata: []*armextendedlocation.EnabledResourceTypePropertiesTypesMetadataItem{ - // { - // APIVersion: to.Ptr("2020-01-01-preview"), - // ResourceProviderNamespace: to.Ptr("Microsoft.VMware"), - // ResourceType: to.Ptr("virtualMachines"), - // }, - // { - // APIVersion: to.Ptr("2020-01-22-preview"), - // ResourceProviderNamespace: to.Ptr("Microsoft.VMware"), - // ResourceType: to.Ptr("virtualmachines"), - // }}, - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }, - // { - // Name: to.Ptr("266e9d31e5be6be1e919574e25780d5783586d502f0b2cc422e0a228a34e00a6"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/enabledResourceTypes"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/enabledResourceTypes/266e9d31e5be6be1e919574e25780d5783586d502f0b2cc422e0a228a34e00a6"), - // Properties: &armextendedlocation.EnabledResourceTypeProperties{ - // ClusterExtensionID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.Kubernetes/connectedClusters/cldfe2econnectedcluster/providers/Microsoft.KubernetesConfiguration/extensions/cassandra-extension"), - // ExtensionType: to.Ptr("cassandradatacentersoperator"), - // TypesMetadata: []*armextendedlocation.EnabledResourceTypePropertiesTypesMetadataItem{ - // { - // APIVersion: to.Ptr("2020-01-01-preview"), - // ResourceProviderNamespace: to.Ptr("Microsoft.Cassandra"), - // ResourceType: to.Ptr("cassandraDataCenters"), - // }, - // { - // APIVersion: to.Ptr("2020-01-22-preview"), - // ResourceProviderNamespace: to.Ptr("Microsoft.Cassandra"), - // ResourceType: to.Ptr("cassandrabackups"), - // }}, - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsFindTargetResourceGroup.json -func ExampleCustomLocationsClient_FindTargetResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCustomLocationsClient().FindTargetResourceGroup(ctx, "testresourcegroup", "customLocation01", armextendedlocation.CustomLocationFindTargetResourceGroupProperties{ - Labels: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, - }, 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.CustomLocationFindTargetResourceGroupResult = armextendedlocation.CustomLocationFindTargetResourceGroupResult{ - // MatchedResourceSyncRule: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/tesla-customlocation-1-chumpishness/resourceSyncRules/test-resource-sync-rule"), - // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/target-resource-group/"), - // } -} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/customlocations_server.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/customlocations_server.go index 9e18c6a23249..9ea47aad7b2d 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/customlocations_server.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/customlocations_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. @@ -29,7 +26,7 @@ type CustomLocationsServer struct { BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, resourceName string, parameters armextendedlocation.CustomLocation, options *armextendedlocation.CustomLocationsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armextendedlocation.CustomLocationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method CustomLocationsClient.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, resourceName string, options *armextendedlocation.CustomLocationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armextendedlocation.CustomLocationsClientDeleteResponse], errResp azfake.ErrorResponder) // FindTargetResourceGroup is the fake for method CustomLocationsClient.FindTargetResourceGroup @@ -52,10 +49,6 @@ type CustomLocationsServer struct { // HTTP status codes to indicate success: http.StatusOK NewListEnabledResourceTypesPager func(resourceGroupName string, resourceName string, options *armextendedlocation.CustomLocationsClientListEnabledResourceTypesOptions) (resp azfake.PagerResponder[armextendedlocation.CustomLocationsClientListEnabledResourceTypesResponse]) - // NewListOperationsPager is the fake for method CustomLocationsClient.NewListOperationsPager - // HTTP status codes to indicate success: http.StatusOK - NewListOperationsPager func(options *armextendedlocation.CustomLocationsClientListOperationsOptions) (resp azfake.PagerResponder[armextendedlocation.CustomLocationsClientListOperationsResponse]) - // Update is the fake for method CustomLocationsClient.Update // HTTP status codes to indicate success: http.StatusOK Update func(ctx context.Context, resourceGroupName string, resourceName string, parameters armextendedlocation.PatchableCustomLocations, options *armextendedlocation.CustomLocationsClientUpdateOptions) (resp azfake.Responder[armextendedlocation.CustomLocationsClientUpdateResponse], errResp azfake.ErrorResponder) @@ -72,7 +65,6 @@ func NewCustomLocationsServerTransport(srv *CustomLocationsServer) *CustomLocati newListByResourceGroupPager: newTracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListByResourceGroupResponse]](), newListBySubscriptionPager: newTracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListBySubscriptionResponse]](), newListEnabledResourceTypesPager: newTracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListEnabledResourceTypesResponse]](), - newListOperationsPager: newTracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListOperationsResponse]](), } } @@ -85,7 +77,6 @@ type CustomLocationsServerTransport struct { newListByResourceGroupPager *tracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListByResourceGroupResponse]] newListBySubscriptionPager *tracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListBySubscriptionResponse]] newListEnabledResourceTypesPager *tracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListEnabledResourceTypesResponse]] - newListOperationsPager *tracker[azfake.PagerResponder[armextendedlocation.CustomLocationsClientListOperationsResponse]] } // Do implements the policy.Transporter interface for CustomLocationsServerTransport. @@ -96,37 +87,54 @@ func (c *CustomLocationsServerTransport) 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 "CustomLocationsClient.BeginCreateOrUpdate": - resp, err = c.dispatchBeginCreateOrUpdate(req) - case "CustomLocationsClient.BeginDelete": - resp, err = c.dispatchBeginDelete(req) - case "CustomLocationsClient.FindTargetResourceGroup": - resp, err = c.dispatchFindTargetResourceGroup(req) - case "CustomLocationsClient.Get": - resp, err = c.dispatchGet(req) - case "CustomLocationsClient.NewListByResourceGroupPager": - resp, err = c.dispatchNewListByResourceGroupPager(req) - case "CustomLocationsClient.NewListBySubscriptionPager": - resp, err = c.dispatchNewListBySubscriptionPager(req) - case "CustomLocationsClient.NewListEnabledResourceTypesPager": - resp, err = c.dispatchNewListEnabledResourceTypesPager(req) - case "CustomLocationsClient.NewListOperationsPager": - resp, err = c.dispatchNewListOperationsPager(req) - case "CustomLocationsClient.Update": - resp, err = c.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return c.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (c *CustomLocationsServerTransport) 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 customLocationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = customLocationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CustomLocationsClient.BeginCreateOrUpdate": + res.resp, res.err = c.dispatchBeginCreateOrUpdate(req) + case "CustomLocationsClient.BeginDelete": + res.resp, res.err = c.dispatchBeginDelete(req) + case "CustomLocationsClient.FindTargetResourceGroup": + res.resp, res.err = c.dispatchFindTargetResourceGroup(req) + case "CustomLocationsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "CustomLocationsClient.NewListByResourceGroupPager": + res.resp, res.err = c.dispatchNewListByResourceGroupPager(req) + case "CustomLocationsClient.NewListBySubscriptionPager": + res.resp, res.err = c.dispatchNewListBySubscriptionPager(req) + case "CustomLocationsClient.NewListEnabledResourceTypesPager": + res.resp, res.err = c.dispatchNewListEnabledResourceTypesPager(req) + case "CustomLocationsClient.Update": + res.resp, res.err = c.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 (c *CustomLocationsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -210,9 +218,9 @@ func (c *CustomLocationsServerTransport) dispatchBeginDelete(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) { c.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) { c.beginDelete.remove(req) @@ -402,33 +410,6 @@ func (c *CustomLocationsServerTransport) dispatchNewListEnabledResourceTypesPage return resp, nil } -func (c *CustomLocationsServerTransport) dispatchNewListOperationsPager(req *http.Request) (*http.Response, error) { - if c.srv.NewListOperationsPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListOperationsPager not implemented")} - } - newListOperationsPager := c.newListOperationsPager.get(req) - if newListOperationsPager == nil { - resp := c.srv.NewListOperationsPager(nil) - newListOperationsPager = &resp - c.newListOperationsPager.add(req, newListOperationsPager) - server.PagerResponderInjectNextLinks(newListOperationsPager, req, func(page *armextendedlocation.CustomLocationsClientListOperationsResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListOperationsPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - c.newListOperationsPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListOperationsPager) { - c.newListOperationsPager.remove(req) - } - return resp, nil -} - func (c *CustomLocationsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { if c.srv.Update == nil { return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} @@ -465,3 +446,9 @@ func (c *CustomLocationsServerTransport) dispatchUpdate(req *http.Request) (*htt } return resp, nil } + +// set this to conditionally intercept incoming requests to CustomLocationsServerTransport +var customLocationsServerTransportInterceptor 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/extendedlocation/armextendedlocation/fake/internal.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/internal.go index 5f75802a569e..4b65adc76adb 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/internal.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/armextendedlocation/fake/operations_server.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/operations_server.go new file mode 100644 index 000000000000..027bf7b3cad0 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/armextendedlocation" + "net/http" +) + +// OperationsServer is a fake server for instances of the armextendedlocation.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armextendedlocation.OperationsClientListOptions) (resp azfake.PagerResponder[armextendedlocation.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armextendedlocation.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[armextendedlocation.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armextendedlocation.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armextendedlocation.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 *armextendedlocation.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/extendedlocation/armextendedlocation/fake/resourcesyncrules_server.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/resourcesyncrules_server.go index a8918c62f602..2381973049f1 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/resourcesyncrules_server.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/resourcesyncrules_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. @@ -40,9 +37,9 @@ type ResourceSyncRulesServer struct { // HTTP status codes to indicate success: http.StatusOK NewListByCustomLocationIDPager func(resourceGroupName string, resourceName string, options *armextendedlocation.ResourceSyncRulesClientListByCustomLocationIDOptions) (resp azfake.PagerResponder[armextendedlocation.ResourceSyncRulesClientListByCustomLocationIDResponse]) - // BeginUpdate is the fake for method ResourceSyncRulesClient.BeginUpdate + // Update is the fake for method ResourceSyncRulesClient.Update // HTTP status codes to indicate success: http.StatusOK - BeginUpdate func(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters armextendedlocation.PatchableResourceSyncRule, options *armextendedlocation.ResourceSyncRulesClientBeginUpdateOptions) (resp azfake.PollerResponder[armextendedlocation.ResourceSyncRulesClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters armextendedlocation.PatchableResourceSyncRule, options *armextendedlocation.ResourceSyncRulesClientUpdateOptions) (resp azfake.Responder[armextendedlocation.ResourceSyncRulesClientUpdateResponse], errResp azfake.ErrorResponder) } // NewResourceSyncRulesServerTransport creates a new instance of ResourceSyncRulesServerTransport with the provided implementation. @@ -53,7 +50,6 @@ func NewResourceSyncRulesServerTransport(srv *ResourceSyncRulesServer) *Resource srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armextendedlocation.ResourceSyncRulesClientCreateOrUpdateResponse]](), newListByCustomLocationIDPager: newTracker[azfake.PagerResponder[armextendedlocation.ResourceSyncRulesClientListByCustomLocationIDResponse]](), - beginUpdate: newTracker[azfake.PollerResponder[armextendedlocation.ResourceSyncRulesClientUpdateResponse]](), } } @@ -63,7 +59,6 @@ type ResourceSyncRulesServerTransport struct { srv *ResourceSyncRulesServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armextendedlocation.ResourceSyncRulesClientCreateOrUpdateResponse]] newListByCustomLocationIDPager *tracker[azfake.PagerResponder[armextendedlocation.ResourceSyncRulesClientListByCustomLocationIDResponse]] - beginUpdate *tracker[azfake.PollerResponder[armextendedlocation.ResourceSyncRulesClientUpdateResponse]] } // Do implements the policy.Transporter interface for ResourceSyncRulesServerTransport. @@ -74,29 +69,48 @@ func (r *ResourceSyncRulesServerTransport) 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 + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ResourceSyncRulesClient.BeginCreateOrUpdate": - resp, err = r.dispatchBeginCreateOrUpdate(req) - case "ResourceSyncRulesClient.Delete": - resp, err = r.dispatchDelete(req) - case "ResourceSyncRulesClient.Get": - resp, err = r.dispatchGet(req) - case "ResourceSyncRulesClient.NewListByCustomLocationIDPager": - resp, err = r.dispatchNewListByCustomLocationIDPager(req) - case "ResourceSyncRulesClient.BeginUpdate": - resp, err = r.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ResourceSyncRulesServerTransport) 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 resourceSyncRulesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = resourceSyncRulesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ResourceSyncRulesClient.BeginCreateOrUpdate": + res.resp, res.err = r.dispatchBeginCreateOrUpdate(req) + case "ResourceSyncRulesClient.Delete": + res.resp, res.err = r.dispatchDelete(req) + case "ResourceSyncRulesClient.Get": + res.resp, res.err = r.dispatchGet(req) + case "ResourceSyncRulesClient.NewListByCustomLocationIDPager": + res.resp, res.err = r.dispatchNewListByCustomLocationIDPager(req) + case "ResourceSyncRulesClient.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 *ResourceSyncRulesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -266,54 +280,49 @@ func (r *ResourceSyncRulesServerTransport) dispatchNewListByCustomLocationIDPage return resp, nil } -func (r *ResourceSyncRulesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { - if r.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} +func (r *ResourceSyncRulesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if r.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - beginUpdate := r.beginUpdate.get(req) - if beginUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ExtendedLocation/customLocations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceSyncRules/(?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[armextendedlocation.PatchableResourceSyncRule](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - childResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("childResourceName")]) - if err != nil { - return nil, err - } - respr, errRespr := r.srv.BeginUpdate(req.Context(), resourceGroupNameParam, resourceNameParam, childResourceNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginUpdate = &respr - r.beginUpdate.add(req, beginUpdate) + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ExtendedLocation/customLocations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceSyncRules/(?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) } - - resp, err := server.PollerResponderNext(beginUpdate, req) + body, err := server.UnmarshalRequestAsJSON[armextendedlocation.PatchableResourceSyncRule](req) if err != nil { return nil, err } - - if !contains([]int{http.StatusOK}, resp.StatusCode) { - r.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err } - if !server.PollerResponderMore(beginUpdate) { - r.beginUpdate.remove(req) + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + childResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("childResourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Update(req.Context(), resourceGroupNameParam, resourceNameParam, childResourceNameParam, 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).ResourceSyncRule, req) + if err != nil { + return nil, err } - return resp, nil } + +// set this to conditionally intercept incoming requests to ResourceSyncRulesServerTransport +var resourceSyncRulesServerTransportInterceptor 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/extendedlocation/armextendedlocation/fake/server_factory.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/server_factory.go index 1f9a18710c3f..c492a25c8453 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/server_factory.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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,13 @@ import ( // ServerFactory is a fake server for instances of the armextendedlocation.ClientFactory type. type ServerFactory struct { - CustomLocationsServer CustomLocationsServer + // CustomLocationsServer contains the fakes for client CustomLocationsClient + CustomLocationsServer CustomLocationsServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // ResourceSyncRulesServer contains the fakes for client ResourceSyncRulesClient ResourceSyncRulesServer ResourceSyncRulesServer } @@ -38,6 +41,7 @@ type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex trCustomLocationsServer *CustomLocationsServerTransport + trOperationsServer *OperationsServerTransport trResourceSyncRulesServer *ResourceSyncRulesServerTransport } @@ -59,6 +63,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewCustomLocationsServerTransport(&s.srv.CustomLocationsServer) }) resp, err = s.trCustomLocationsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) case "ResourceSyncRulesClient": initServer(s, &s.trResourceSyncRulesServer, func() *ResourceSyncRulesServerTransport { return NewResourceSyncRulesServerTransport(&s.srv.ResourceSyncRulesServer) diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/time_rfc3339.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/armextendedlocation/go.mod b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod index 3890bee24b26..6520a0804f8f 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/ar 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/extendedlocation/armextendedlocation/go.sum b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/armextendedlocation/models.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/models.go index a42e80178775..928757c77051 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/models.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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. @@ -30,7 +27,7 @@ type CustomLocation struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" @@ -56,51 +53,12 @@ type CustomLocationFindTargetResourceGroupResult struct { TargetResourceGroup *string } -// CustomLocationListResult - The List Custom Locations operation response. +// CustomLocationListResult - The response of a CustomLocation list operation. type CustomLocationListResult struct { - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string - - // READ-ONLY; The list of Custom Locations. + // REQUIRED; The CustomLocation items on this page Value []*CustomLocation -} - -// CustomLocationOperation - Custom Locations operation. -type CustomLocationOperation struct { - // Describes the properties of a Custom Locations Operation Value Display. - Display *CustomLocationOperationValueDisplay - - // READ-ONLY; Is this Operation a data plane operation - IsDataAction *bool - - // READ-ONLY; The name of the compute operation. - Name *string - - // READ-ONLY; The origin of the compute operation. - Origin *string -} - -// CustomLocationOperationValueDisplay - Describes the properties of a Custom Locations Operation Value Display. -type CustomLocationOperationValueDisplay struct { - // READ-ONLY; The description of the operation. - Description *string - - // READ-ONLY; The display name of the compute operation. - Operation *string - // READ-ONLY; The resource provider for the operation. - Provider *string - - // READ-ONLY; The display name of the resource the operation applies to. - Resource *string -} - -// CustomLocationOperationsList - Lists of Custom Locations operations. -type CustomLocationOperationsList struct { - // REQUIRED; Array of customLocationOperation - Value []*CustomLocationOperation - - // Next page of operations. + // The link to the next page of items NextLink *string } @@ -149,13 +107,22 @@ type EnabledResourceType struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } +// EnabledResourceTypeListResult - The response of a EnabledResourceType list operation. +type EnabledResourceTypeListResult struct { + // REQUIRED; The EnabledResourceType items on this page + Value []*EnabledResourceType + + // The link to the next page of items + NextLink *string +} + // EnabledResourceTypeProperties - Properties for EnabledResourceType of a custom location. type EnabledResourceTypeProperties struct { // Cluster Extension ID @@ -180,15 +147,6 @@ type EnabledResourceTypePropertiesTypesMetadataItem struct { ResourceType *string } -// EnabledResourceTypesListResult - List of EnabledResourceTypes definition. -type EnabledResourceTypesListResult struct { - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string - - // READ-ONLY; The list of EnabledResourceTypes available for a customLocation. - Value []*EnabledResourceType -} - // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. @@ -247,6 +205,55 @@ type MatchExpressionsProperties struct { Values []*string } +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + // PatchableCustomLocations - The Custom Locations patchable resource definition. type PatchableCustomLocations struct { // Identity for the resource. @@ -277,6 +284,9 @@ type ProxyResource struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -289,6 +299,9 @@ type Resource struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -310,20 +323,20 @@ type ResourceSyncRule struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// ResourceSyncRuleListResult - The List Resource Sync Rules operation response. +// ResourceSyncRuleListResult - The response of a ResourceSyncRule list operation. type ResourceSyncRuleListResult struct { - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string - - // READ-ONLY; The list of Resource Sync Rules. + // REQUIRED; The ResourceSyncRule items on this page Value []*ResourceSyncRule + + // The link to the next page of items + NextLink *string } // ResourceSyncRuleProperties - Properties for a resource sync rule. For an unmapped custom resource, its labels will be used @@ -409,6 +422,9 @@ type TrackedResource struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/models_serde.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/models_serde.go index 834654dc401b..2c6a7235299a 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/models_serde.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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. @@ -159,115 +156,6 @@ func (c *CustomLocationListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type CustomLocationOperation. -func (c CustomLocationOperation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "display", c.Display) - populate(objectMap, "isDataAction", c.IsDataAction) - populate(objectMap, "name", c.Name) - populate(objectMap, "origin", c.Origin) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomLocationOperation. -func (c *CustomLocationOperation) 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 "display": - err = unpopulate(val, "Display", &c.Display) - delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &c.IsDataAction) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - case "origin": - err = unpopulate(val, "Origin", &c.Origin) - 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 CustomLocationOperationValueDisplay. -func (c CustomLocationOperationValueDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "description", c.Description) - populate(objectMap, "operation", c.Operation) - populate(objectMap, "provider", c.Provider) - populate(objectMap, "resource", c.Resource) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomLocationOperationValueDisplay. -func (c *CustomLocationOperationValueDisplay) 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 "description": - err = unpopulate(val, "Description", &c.Description) - delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &c.Operation) - delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &c.Provider) - delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &c.Resource) - 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 CustomLocationOperationsList. -func (c CustomLocationOperationsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", c.NextLink) - populate(objectMap, "value", c.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CustomLocationOperationsList. -func (c *CustomLocationOperationsList) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &c.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &c.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type CustomLocationProperties. func (c CustomLocationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -393,6 +281,37 @@ func (e *EnabledResourceType) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type EnabledResourceTypeListResult. +func (e EnabledResourceTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnabledResourceTypeListResult. +func (e *EnabledResourceTypeListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + 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 EnabledResourceTypeProperties. func (e EnabledResourceTypeProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -463,37 +382,6 @@ func (e *EnabledResourceTypePropertiesTypesMetadataItem) UnmarshalJSON(data []by return nil } -// MarshalJSON implements the json.Marshaller interface for type EnabledResourceTypesListResult. -func (e EnabledResourceTypesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EnabledResourceTypesListResult. -func (e *EnabledResourceTypesListResult) 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 "nextLink": - err = unpopulate(val, "NextLink", &e.NextLink) - 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) @@ -665,6 +553,119 @@ func (m *MatchExpressionsProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + 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 "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + 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 PatchableCustomLocations. func (p PatchableCustomLocations) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -736,6 +737,7 @@ func (p ProxyResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } @@ -755,6 +757,9 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &p.Name) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) @@ -771,6 +776,7 @@ func (r Resource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) populate(objectMap, "type", r.Type) return json.Marshal(objectMap) } @@ -790,6 +796,9 @@ func (r *Resource) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &r.Name) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) delete(rawMsg, key) @@ -1006,6 +1015,7 @@ func (t TrackedResource) MarshalJSON() ([]byte, error) { populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) populate(objectMap, "tags", t.Tags) populate(objectMap, "type", t.Type) return json.Marshal(objectMap) @@ -1029,6 +1039,9 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { 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) @@ -1064,7 +1077,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/extendedlocation/armextendedlocation/operations_client.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/operations_client.go new file mode 100644 index 000000000000..8de0ffc7ef81 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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 armextendedlocation + +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 available Custom Locations operations. +// +// Generated from API version 2021-08-31-preview +// - 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.ExtendedLocation/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", "2021-08-31-preview") + 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/extendedlocation/armextendedlocation/options.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/options.go index 7e563a054585..cf750a9b38b7 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/options.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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. @@ -11,13 +8,13 @@ package armextendedlocation // CustomLocationsClientBeginCreateOrUpdateOptions contains the optional parameters for the CustomLocationsClient.BeginCreateOrUpdate // method. type CustomLocationsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // CustomLocationsClientBeginDeleteOptions contains the optional parameters for the CustomLocationsClient.BeginDelete method. type CustomLocationsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -50,28 +47,20 @@ type CustomLocationsClientListEnabledResourceTypesOptions struct { // placeholder for future optional parameters } -// CustomLocationsClientListOperationsOptions contains the optional parameters for the CustomLocationsClient.NewListOperationsPager -// method. -type CustomLocationsClientListOperationsOptions struct { +// CustomLocationsClientUpdateOptions contains the optional parameters for the CustomLocationsClient.Update method. +type CustomLocationsClientUpdateOptions struct { // placeholder for future optional parameters } -// CustomLocationsClientUpdateOptions contains the optional parameters for the CustomLocationsClient.Update method. -type CustomLocationsClientUpdateOptions struct { +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { // placeholder for future optional parameters } // ResourceSyncRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.BeginCreateOrUpdate // method. type ResourceSyncRulesClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ResourceSyncRulesClientBeginUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.BeginUpdate -// method. -type ResourceSyncRulesClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -90,3 +79,8 @@ type ResourceSyncRulesClientGetOptions struct { type ResourceSyncRulesClientListByCustomLocationIDOptions struct { // placeholder for future optional parameters } + +// ResourceSyncRulesClientUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.Update method. +type ResourceSyncRulesClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client.go index d08bfb383044..7b7b79bbfff2 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_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. @@ -98,7 +95,7 @@ func (client *ResourceSyncRulesClient) createOrUpdate(ctx context.Context, resou } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ResourceSyncRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters ResourceSyncRule, options *ResourceSyncRulesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ResourceSyncRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters ResourceSyncRule, _ *ResourceSyncRulesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -162,7 +159,7 @@ func (client *ResourceSyncRulesClient) Delete(ctx context.Context, resourceGroup } // deleteCreateRequest creates the Delete request. -func (client *ResourceSyncRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, options *ResourceSyncRulesClientDeleteOptions) (*policy.Request, error) { +func (client *ResourceSyncRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, _ *ResourceSyncRulesClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -223,7 +220,7 @@ func (client *ResourceSyncRulesClient) Get(ctx context.Context, resourceGroupNam } // getCreateRequest creates the Get request. -func (client *ResourceSyncRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, options *ResourceSyncRulesClientGetOptions) (*policy.Request, error) { +func (client *ResourceSyncRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, _ *ResourceSyncRulesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -293,7 +290,7 @@ func (client *ResourceSyncRulesClient) NewListByCustomLocationIDPager(resourceGr } // listByCustomLocationIDCreateRequest creates the ListByCustomLocationID request. -func (client *ResourceSyncRulesClient) listByCustomLocationIDCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ResourceSyncRulesClientListByCustomLocationIDOptions) (*policy.Request, error) { +func (client *ResourceSyncRulesClient) listByCustomLocationIDCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ResourceSyncRulesClientListByCustomLocationIDOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -327,8 +324,8 @@ func (client *ResourceSyncRulesClient) listByCustomLocationIDHandleResponse(resp return result, nil } -// BeginUpdate - Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, -// Subscription and Custom Location name. +// Update - Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, Subscription +// and Custom Location name. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2021-08-31-preview @@ -336,54 +333,32 @@ func (client *ResourceSyncRulesClient) listByCustomLocationIDHandleResponse(resp // - resourceName - Custom Locations name. // - childResourceName - Resource Sync Rule name. // - parameters - The updatable fields of an existing Resource Sync Rule. -// - options - ResourceSyncRulesClientBeginUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.BeginUpdate +// - options - ResourceSyncRulesClientUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.Update // method. -func (client *ResourceSyncRulesClient) BeginUpdate(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters PatchableResourceSyncRule, options *ResourceSyncRulesClientBeginUpdateOptions) (*runtime.Poller[ResourceSyncRulesClientUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, resourceName, childResourceName, parameters, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourceSyncRulesClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ResourceSyncRulesClientUpdateResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Update - Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, Subscription -// and Custom Location name. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-08-31-preview -func (client *ResourceSyncRulesClient) update(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters PatchableResourceSyncRule, options *ResourceSyncRulesClientBeginUpdateOptions) (*http.Response, error) { +func (client *ResourceSyncRulesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters PatchableResourceSyncRule, options *ResourceSyncRulesClientUpdateOptions) (ResourceSyncRulesClientUpdateResponse, error) { var err error - const operationName = "ResourceSyncRulesClient.BeginUpdate" + const operationName = "ResourceSyncRulesClient.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, resourceName, childResourceName, parameters, options) if err != nil { - return nil, err + return ResourceSyncRulesClientUpdateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return nil, err + return ResourceSyncRulesClientUpdateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return nil, err + return ResourceSyncRulesClientUpdateResponse{}, err } - return httpResp, nil + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. -func (client *ResourceSyncRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters PatchableResourceSyncRule, options *ResourceSyncRulesClientBeginUpdateOptions) (*policy.Request, error) { +func (client *ResourceSyncRulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters PatchableResourceSyncRule, _ *ResourceSyncRulesClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -414,3 +389,12 @@ func (client *ResourceSyncRulesClient) updateCreateRequest(ctx context.Context, } return req, nil } + +// updateHandleResponse handles the Update response. +func (client *ResourceSyncRulesClient) updateHandleResponse(resp *http.Response) (ResourceSyncRulesClientUpdateResponse, error) { + result := ResourceSyncRulesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceSyncRule); err != nil { + return ResourceSyncRulesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client_example_test.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client_example_test.go deleted file mode 100644 index 7ef0bf648cc3..000000000000 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client_example_test.go +++ /dev/null @@ -1,315 +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 armextendedlocation_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/extendedlocation/armextendedlocation" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesListByCustomLocationID.json -func ExampleResourceSyncRulesClient_NewListByCustomLocationIDPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceSyncRulesClient().NewListByCustomLocationIDPager("testresourcegroup", "customLocation01", 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.ResourceSyncRuleListResult = armextendedlocation.ResourceSyncRuleListResult{ - // Value: []*armextendedlocation.ResourceSyncRule{ - // { - // Name: to.Ptr("resourceSyncRule01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourcesyncrules"), - // Location: to.Ptr("West US"), - // Properties: &armextendedlocation.ResourceSyncRuleProperties{ - // Priority: to.Ptr[int32](999), - // ProvisioningState: to.Ptr("Succeeded"), - // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ - // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ - // { - // Key: to.Ptr("key4"), - // Operator: to.Ptr("In"), - // Values: []*string{ - // to.Ptr("value4")}, - // }}, - // MatchLabels: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }, - // { - // Name: to.Ptr("resourceSyncRule02"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), - // Location: to.Ptr("West US"), - // Properties: &armextendedlocation.ResourceSyncRuleProperties{ - // Priority: to.Ptr[int32](999), - // ProvisioningState: to.Ptr("Succeeded"), - // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ - // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ - // { - // Key: to.Ptr("key8"), - // Operator: to.Ptr("In"), - // Values: []*string{ - // to.Ptr("value8")}, - // }}, - // MatchLabels: map[string]*string{ - // "key5": to.Ptr("value5"), - // }, - // }, - // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/amalladi-df-test/"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesGet.json -func ExampleResourceSyncRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceSyncRulesClient().Get(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", 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.ResourceSyncRule = armextendedlocation.ResourceSyncRule{ - // Name: to.Ptr("resourceSyncRule01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourceSyncRules/resourceSyncRule01"), - // Location: to.Ptr("West US"), - // Properties: &armextendedlocation.ResourceSyncRuleProperties{ - // Priority: to.Ptr[int32](999), - // ProvisioningState: to.Ptr("Succeeded"), - // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ - // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ - // { - // Key: to.Ptr("key4"), - // Operator: to.Ptr("In"), - // Values: []*string{ - // to.Ptr("value4")}, - // }}, - // MatchLabels: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesCreate_Update.json -func ExampleResourceSyncRulesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceSyncRulesClient().BeginCreateOrUpdate(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", armextendedlocation.ResourceSyncRule{ - Location: to.Ptr("West US"), - Properties: &armextendedlocation.ResourceSyncRuleProperties{ - Priority: to.Ptr[int32](999), - Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ - MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ - { - Key: to.Ptr("key4"), - Operator: to.Ptr("In"), - Values: []*string{ - to.Ptr("value4")}, - }}, - MatchLabels: map[string]*string{ - "key1": to.Ptr("value1"), - }, - }, - TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup"), - }, - }, 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.ResourceSyncRule = armextendedlocation.ResourceSyncRule{ - // Name: to.Ptr("resourceSyncRule01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourcesyncrules/resourceSyncRule01"), - // Location: to.Ptr("West US"), - // Properties: &armextendedlocation.ResourceSyncRuleProperties{ - // Priority: to.Ptr[int32](999), - // ProvisioningState: to.Ptr("Succeeded"), - // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ - // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ - // { - // Key: to.Ptr("key4"), - // Operator: to.Ptr("In"), - // Values: []*string{ - // to.Ptr("value4")}, - // }}, - // MatchLabels: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-15T18:53:29.092Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-15T18:53:29.092Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesDelete.json -func ExampleResourceSyncRulesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewResourceSyncRulesClient().Delete(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", 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/fb9c8e2ca33e9723c2b2fc849f627329067feb54/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesPatch.json -func ExampleResourceSyncRulesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceSyncRulesClient().BeginUpdate(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", armextendedlocation.PatchableResourceSyncRule{ - Properties: &armextendedlocation.ResourceSyncRuleProperties{ - TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/"), - }, - Tags: map[string]*string{ - "tier": to.Ptr("testing"), - }, - }, 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.ResourceSyncRule = armextendedlocation.ResourceSyncRule{ - // Name: to.Ptr("resourceSyncRule01"), - // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourceSyncRules/resourceSyncRule01"), - // Location: to.Ptr("West US"), - // Tags: map[string]*string{ - // "tier": to.Ptr("testing"), - // }, - // Properties: &armextendedlocation.ResourceSyncRuleProperties{ - // Priority: to.Ptr[int32](999), - // ProvisioningState: to.Ptr("Succeeded"), - // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ - // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ - // { - // Key: to.Ptr("key4"), - // Operator: to.Ptr("In"), - // Values: []*string{ - // to.Ptr("value4")}, - // }}, - // MatchLabels: map[string]*string{ - // "key1": to.Ptr("value1"), - // }, - // }, - // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/"), - // }, - // SystemData: &armextendedlocation.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T23:17:11.735Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T23:28:00.587Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), - // }, - // } -} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/response_types.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/responses.go similarity index 84% rename from sdk/resourcemanager/extendedlocation/armextendedlocation/response_types.go rename to sdk/resourcemanager/extendedlocation/armextendedlocation/responses.go index 556c2bb4c18d..aa8abfef4e28 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/response_types.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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. @@ -33,26 +30,20 @@ type CustomLocationsClientGetResponse struct { // CustomLocationsClientListByResourceGroupResponse contains the response from method CustomLocationsClient.NewListByResourceGroupPager. type CustomLocationsClientListByResourceGroupResponse struct { - // The List Custom Locations operation response. + // The response of a CustomLocation list operation. CustomLocationListResult } // CustomLocationsClientListBySubscriptionResponse contains the response from method CustomLocationsClient.NewListBySubscriptionPager. type CustomLocationsClientListBySubscriptionResponse struct { - // The List Custom Locations operation response. + // The response of a CustomLocation list operation. CustomLocationListResult } // CustomLocationsClientListEnabledResourceTypesResponse contains the response from method CustomLocationsClient.NewListEnabledResourceTypesPager. type CustomLocationsClientListEnabledResourceTypesResponse struct { - // List of EnabledResourceTypes definition. - EnabledResourceTypesListResult -} - -// CustomLocationsClientListOperationsResponse contains the response from method CustomLocationsClient.NewListOperationsPager. -type CustomLocationsClientListOperationsResponse struct { - // Lists of Custom Locations operations. - CustomLocationOperationsList + // The response of a EnabledResourceType list operation. + EnabledResourceTypeListResult } // CustomLocationsClientUpdateResponse contains the response from method CustomLocationsClient.Update. @@ -61,6 +52,12 @@ type CustomLocationsClientUpdateResponse struct { CustomLocation } +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + // ResourceSyncRulesClientCreateOrUpdateResponse contains the response from method ResourceSyncRulesClient.BeginCreateOrUpdate. type ResourceSyncRulesClientCreateOrUpdateResponse struct { // Resource Sync Rules definition. @@ -80,11 +77,11 @@ type ResourceSyncRulesClientGetResponse struct { // ResourceSyncRulesClientListByCustomLocationIDResponse contains the response from method ResourceSyncRulesClient.NewListByCustomLocationIDPager. type ResourceSyncRulesClientListByCustomLocationIDResponse struct { - // The List Resource Sync Rules operation response. + // The response of a ResourceSyncRule list operation. ResourceSyncRuleListResult } -// ResourceSyncRulesClientUpdateResponse contains the response from method ResourceSyncRulesClient.BeginUpdate. +// ResourceSyncRulesClientUpdateResponse contains the response from method ResourceSyncRulesClient.Update. type ResourceSyncRulesClientUpdateResponse struct { // Resource Sync Rules definition. ResourceSyncRule diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/time_rfc3339.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/time_rfc3339.go index ac5061757ce4..efeff155140d 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/time_rfc3339.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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