diff --git a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md index 66d880b0bc91..356a659de020 100644 --- a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md +++ b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md @@ -1,5 +1,69 @@ # Release History +## 2.0.0 (2024-11-15) +### Breaking Changes + +- Function `*CapabilitiesClient.CreateOrUpdate` parameter(s) have been changed from `(context.Context, string, string, string, string, string, string, Capability, *CapabilitiesClientCreateOrUpdateOptions)` to `(context.Context, string, string, string, Capability, *CapabilitiesClientCreateOrUpdateOptions)` +- Function `*CapabilitiesClient.Delete` parameter(s) have been changed from `(context.Context, string, string, string, string, string, string, *CapabilitiesClientDeleteOptions)` to `(context.Context, string, string, string, *CapabilitiesClientDeleteOptions)` +- Function `*CapabilitiesClient.Get` parameter(s) have been changed from `(context.Context, string, string, string, string, string, string, *CapabilitiesClientGetOptions)` to `(context.Context, string, string, string, *CapabilitiesClientGetOptions)` +- Function `*CapabilitiesClient.NewListPager` parameter(s) have been changed from `(string, string, string, string, string, *CapabilitiesClientListOptions)` to `(string, string, *CapabilitiesClientListOptions)` +- Function `*ExperimentsClient.BeginCancel` parameter(s) have been changed from `(context.Context, string, string, *ExperimentsClientBeginCancelOptions)` to `(context.Context, *ExperimentsClientBeginCancelOptions)` +- Function `*ExperimentsClient.BeginStart` parameter(s) have been changed from `(context.Context, string, string, *ExperimentsClientBeginStartOptions)` to `(context.Context, *ExperimentsClientBeginStartOptions)` +- Function `*TargetsClient.CreateOrUpdate` parameter(s) have been changed from `(context.Context, string, string, string, string, string, Target, *TargetsClientCreateOrUpdateOptions)` to `(context.Context, string, string, Target, *TargetsClientCreateOrUpdateOptions)` +- Function `*TargetsClient.Delete` parameter(s) have been changed from `(context.Context, string, string, string, string, string, *TargetsClientDeleteOptions)` to `(context.Context, string, string, *TargetsClientDeleteOptions)` +- Function `*TargetsClient.Get` parameter(s) have been changed from `(context.Context, string, string, string, string, string, *TargetsClientGetOptions)` to `(context.Context, string, string, *TargetsClientGetOptions)` +- Function `*TargetsClient.NewListPager` parameter(s) have been changed from `(string, string, string, string, *TargetsClientListOptions)` to `(string, *TargetsClientListOptions)` +- Type of `ContinuousAction.Type` has been changed from `*string` to `*ExperimentActionType` +- Type of `DelayAction.Type` has been changed from `*string` to `*ExperimentActionType` +- Type of `DiscreteAction.Type` has been changed from `*string` to `*ExperimentActionType` +- Type of `Experiment.Identity` has been changed from `*ResourceIdentity` to `*ManagedServiceIdentity` +- Type of `ExperimentAction.Type` has been changed from `*string` to `*ExperimentActionType` +- Type of `ExperimentUpdate.Identity` has been changed from `*ResourceIdentity` to `*ManagedServiceIdentityUpdate` +- Enum `ResourceIdentityType` has been removed +- Function `*ClientFactory.NewOperationStatusesClient` has been removed +- Function `*ExperimentsClient.ExecutionDetails` has been removed +- Function `*ExperimentsClient.GetExecution` has been removed +- Function `*ExperimentsClient.NewListAllExecutionsPager` has been removed +- Function `*ExperimentsClient.NewListAllPager` has been removed +- Function `*ExperimentsClient.NewListPager` has been removed +- Function `NewOperationStatusesClient` has been removed +- Function `*OperationStatusesClient.Get` has been removed +- Function `*OperationsClient.NewListAllPager` has been removed +- Struct `OperationStatus` has been removed +- Struct `ResourceIdentity` has been removed +- Field `Location` of struct `CapabilityType` has been removed +- Field `Location` of struct `Target` has been removed +- Field `Location` of struct `TargetType` has been removed + +### Features Added + +- New enum type `ExperimentActionType` with values `ExperimentActionTypeContinuous`, `ExperimentActionTypeDelay`, `ExperimentActionTypeDiscrete` +- New enum type `ManagedServiceIdentityType` with values `ManagedServiceIdentityTypeNone`, `ManagedServiceIdentityTypeSystemAssigned`, `ManagedServiceIdentityTypeSystemAssignedUserAssigned`, `ManagedServiceIdentityTypeUserAssigned` +- New function `*ClientFactory.NewExperimentExecutionsClient() *ExperimentExecutionsClient` +- New function `NewExperimentExecutionsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ExperimentExecutionsClient, error)` +- New function `*ExperimentExecutionsClient.Details(context.Context, string, string, string, *ExperimentExecutionsClientDetailsOptions) (ExperimentExecutionsClientDetailsResponse, error)` +- New function `*ExperimentExecutionsClient.Get(context.Context, string, string, string, *ExperimentExecutionsClientGetOptions) (ExperimentExecutionsClientGetResponse, error)` +- New function `*ExperimentExecutionsClient.NewListPager(string, string, *ExperimentExecutionsClientListOptions) *runtime.Pager[ExperimentExecutionsClientListResponse]` +- New function `*ExperimentsClient.NewListByResourceGroupPager(string, *ExperimentsClientListByResourceGroupOptions) *runtime.Pager[ExperimentsClientListByResourceGroupResponse]` +- New function `*ExperimentsClient.NewListBySubscriptionPager(*ExperimentsClientListBySubscriptionOptions) *runtime.Pager[ExperimentsClientListBySubscriptionResponse]` +- New function `*OperationsClient.NewListPager(*OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]` +- New struct `ComponentsQjfoe3SchemasManagedserviceidentityupdatePropertiesUserassignedidentitiesAdditionalproperties` +- New struct `ManagedServiceIdentity` +- New struct `ManagedServiceIdentityUpdate` +- New struct `PostActionResponse` +- New struct `ProxyResource` +- New field `ProvisioningState` in struct `CapabilityProperties` +- New field `ProvisioningState` in struct `CapabilityTypeProperties` +- New field `SystemData` in struct `ExperimentExecution` +- New field `ProvisioningState` in struct `ExperimentExecutionDetailsProperties` +- New field `ProvisioningState` in struct `ExperimentExecutionProperties` +- New anonymous field `PostActionResponse` in struct `ExperimentsClientCancelResponse` +- New anonymous field `PostActionResponse` in struct `ExperimentsClientStartResponse` +- New field `SystemData` in struct `Resource` +- New field `ProvisioningState` in struct `TargetTypeProperties` +- New field `SystemData` in struct `TrackedResource` + + ## 1.1.0 (2024-03-22) ### Features Added diff --git a/sdk/resourcemanager/chaos/armchaos/README.md b/sdk/resourcemanager/chaos/armchaos/README.md index 61bda46c49a6..3dd6f71cd091 100644 --- a/sdk/resourcemanager/chaos/armchaos/README.md +++ b/sdk/resourcemanager/chaos/armchaos/README.md @@ -19,7 +19,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Chaos module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2 ``` ## Authorization diff --git a/sdk/resourcemanager/chaos/armchaos/autorest.md b/sdk/resourcemanager/chaos/armchaos/autorest.md index b9f219695dcc..7d1b91bb3d83 100644 --- a/sdk/resourcemanager/chaos/armchaos/autorest.md +++ b/sdk/resourcemanager/chaos/armchaos/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/chaos/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/chaos/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.0 -tag: package-2024-01 +module-version: 2.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/chaos/armchaos/capabilities_client.go b/sdk/resourcemanager/chaos/armchaos/capabilities_client.go index 74d548e166ec..fea7be1a5a41 100644 --- a/sdk/resourcemanager/chaos/armchaos/capabilities_client.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilities_client.go @@ -28,7 +28,7 @@ type CapabilitiesClient struct { } // NewCapabilitiesClient creates a new instance of CapabilitiesClient with the specified values. -// - subscriptionID - GUID that represents an Azure subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCapabilitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CapabilitiesClient, error) { @@ -46,23 +46,20 @@ func NewCapabilitiesClient(subscriptionID string, credential azcore.TokenCredent // CreateOrUpdate - Create or update a Capability resource that extends a Target resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - targetName - String that represents a Target resource name. // - capabilityName - String that represents a Capability resource name. -// - capability - Capability resource to be created or updated. +// - resource - Capability resource to be created or updated. // - options - CapabilitiesClientCreateOrUpdateOptions contains the optional parameters for the CapabilitiesClient.CreateOrUpdate // method. -func (client *CapabilitiesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, capability Capability, options *CapabilitiesClientCreateOrUpdateOptions) (CapabilitiesClientCreateOrUpdateResponse, error) { +func (client *CapabilitiesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, resource Capability, options *CapabilitiesClientCreateOrUpdateOptions) (CapabilitiesClientCreateOrUpdateResponse, error) { var err error const operationName = "CapabilitiesClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, capability, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, targetName, capabilityName, resource, options) if err != nil { return CapabilitiesClientCreateOrUpdateResponse{}, err } @@ -70,7 +67,7 @@ func (client *CapabilitiesClient) CreateOrUpdate(ctx context.Context, resourceGr if err != nil { return CapabilitiesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return CapabilitiesClientCreateOrUpdateResponse{}, err } @@ -79,8 +76,8 @@ func (client *CapabilitiesClient) CreateOrUpdate(ctx context.Context, resourceGr } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *CapabilitiesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, capability Capability, options *CapabilitiesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" +func (client *CapabilitiesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, resource Capability, options *CapabilitiesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -89,18 +86,6 @@ func (client *CapabilitiesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) if targetName == "" { return nil, errors.New("parameter targetName cannot be empty") } @@ -114,10 +99,10 @@ func (client *CapabilitiesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, capability); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -135,21 +120,18 @@ func (client *CapabilitiesClient) createOrUpdateHandleResponse(resp *http.Respon // Delete - Delete a Capability that extends a Target resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - targetName - String that represents a Target resource name. // - capabilityName - String that represents a Capability resource name. // - options - CapabilitiesClientDeleteOptions contains the optional parameters for the CapabilitiesClient.Delete method. -func (client *CapabilitiesClient) Delete(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesClientDeleteOptions) (CapabilitiesClientDeleteResponse, error) { +func (client *CapabilitiesClient) Delete(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, options *CapabilitiesClientDeleteOptions) (CapabilitiesClientDeleteResponse, error) { var err error const operationName = "CapabilitiesClient.Delete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, targetName, capabilityName, options) if err != nil { return CapabilitiesClientDeleteResponse{}, err } @@ -165,8 +147,8 @@ func (client *CapabilitiesClient) Delete(ctx context.Context, resourceGroupName } // deleteCreateRequest creates the Delete request. -func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" +func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, options *CapabilitiesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -175,18 +157,6 @@ func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) if targetName == "" { return nil, errors.New("parameter targetName cannot be empty") } @@ -200,7 +170,7 @@ func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -209,21 +179,18 @@ func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resou // Get - Get a Capability resource that extends a Target resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - targetName - String that represents a Target resource name. // - capabilityName - String that represents a Capability resource name. // - options - CapabilitiesClientGetOptions contains the optional parameters for the CapabilitiesClient.Get method. -func (client *CapabilitiesClient) Get(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesClientGetOptions) (CapabilitiesClientGetResponse, error) { +func (client *CapabilitiesClient) Get(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, options *CapabilitiesClientGetOptions) (CapabilitiesClientGetResponse, error) { var err error const operationName = "CapabilitiesClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, targetName, capabilityName, options) if err != nil { return CapabilitiesClientGetResponse{}, err } @@ -240,8 +207,8 @@ func (client *CapabilitiesClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *CapabilitiesClient) getCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *CapabilitiesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" +func (client *CapabilitiesClient) getCreateRequest(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, options *CapabilitiesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -250,18 +217,6 @@ func (client *CapabilitiesClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) if targetName == "" { return nil, errors.New("parameter targetName cannot be empty") } @@ -275,7 +230,7 @@ func (client *CapabilitiesClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -292,14 +247,11 @@ func (client *CapabilitiesClient) getHandleResponse(resp *http.Response) (Capabi // NewListPager - Get a list of Capability resources that extend a Target resource.. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - targetName - String that represents a Target resource name. // - options - CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.NewListPager method. -func (client *CapabilitiesClient) NewListPager(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *CapabilitiesClientListOptions) *runtime.Pager[CapabilitiesClientListResponse] { +func (client *CapabilitiesClient) NewListPager(resourceGroupName string, targetName string, options *CapabilitiesClientListOptions) *runtime.Pager[CapabilitiesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CapabilitiesClientListResponse]{ More: func(page CapabilitiesClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -311,7 +263,7 @@ func (client *CapabilitiesClient) NewListPager(resourceGroupName string, parentP nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) + return client.listCreateRequest(ctx, resourceGroupName, targetName, options) }, nil) if err != nil { return CapabilitiesClientListResponse{}, err @@ -323,8 +275,8 @@ func (client *CapabilitiesClient) NewListPager(resourceGroupName string, parentP } // listCreateRequest creates the List request. -func (client *CapabilitiesClient) listCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *CapabilitiesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities" +func (client *CapabilitiesClient) listCreateRequest(ctx context.Context, resourceGroupName string, targetName string, options *CapabilitiesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -333,18 +285,6 @@ func (client *CapabilitiesClient) listCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) if targetName == "" { return nil, errors.New("parameter targetName cannot be empty") } @@ -354,7 +294,7 @@ func (client *CapabilitiesClient) listCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/capabilities_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/capabilities_client_example_test.go deleted file mode 100644 index b4d2220e83e1..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/capabilities_client_example_test.go +++ /dev/null @@ -1,153 +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 armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListCapabilities.json -func ExampleCapabilitiesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCapabilitiesClient().NewListPager("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", &armchaos.CapabilitiesClientListOptions{ContinuationToken: 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.CapabilityListResult = armchaos.CapabilityListResult{ - // Value: []*armchaos.Capability{ - // { - // Name: to.Ptr("Shutdown-1.0"), - // Type: to.Ptr("Microsoft.Chaos/targets/capabilities"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0"), - // Properties: &armchaos.CapabilityProperties{ - // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), - // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), - // Publisher: to.Ptr("Microsoft"), - // TargetType: to.Ptr("VirtualMachine"), - // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.466Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.466Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetCapability.json -func ExampleCapabilitiesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCapabilitiesClient().Get(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", "Shutdown-1.0", 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.Capability = armchaos.Capability{ - // Name: to.Ptr("Shutdown-1.0"), - // Type: to.Ptr("Microsoft.Chaos/targets/capabilities"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0"), - // Properties: &armchaos.CapabilityProperties{ - // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), - // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), - // Publisher: to.Ptr("Microsoft"), - // TargetType: to.Ptr("VirtualMachine"), - // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.466Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.466Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/DeleteCapability.json -func ExampleCapabilitiesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewCapabilitiesClient().Delete(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", "Shutdown-1.0", 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/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateCapability.json -func ExampleCapabilitiesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCapabilitiesClient().CreateOrUpdate(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-VirtualMachine", "Shutdown-1.0", armchaos.Capability{ - Properties: &armchaos.CapabilityProperties{}, - }, 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.Capability = armchaos.Capability{ - // Name: to.Ptr("Shutdown-1.0"), - // Type: to.Ptr("Microsoft.Chaos/targets/capabilities"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0"), - // Properties: &armchaos.CapabilityProperties{ - // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), - // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), - // Publisher: to.Ptr("Microsoft"), - // TargetType: to.Ptr("VirtualMachine"), - // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.466Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-14T05:08:38.466Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/chaos/armchaos/capabilities_live_test.go b/sdk/resourcemanager/chaos/armchaos/capabilities_live_test.go index a81b322e53d5..d29576907918 100644 --- a/sdk/resourcemanager/chaos/armchaos/capabilities_live_test.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilities_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" diff --git a/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go index e5573ac5209b..f09b85cd1815 100644 --- a/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go @@ -28,7 +28,7 @@ type CapabilityTypesClient struct { } // NewCapabilityTypesClient creates a new instance of CapabilityTypesClient with the specified values. -// - subscriptionID - GUID that represents an Azure subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCapabilityTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CapabilityTypesClient, error) { @@ -46,18 +46,18 @@ func NewCapabilityTypesClient(subscriptionID string, credential azcore.TokenCred // Get - Get a Capability Type resource for given Target Type and location. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - locationName - String that represents a Location resource name. +// Generated from API version 2025-01-01 +// - location - The name of the Azure region. // - targetTypeName - String that represents a Target Type resource name. // - capabilityTypeName - String that represents a Capability Type resource name. // - options - CapabilityTypesClientGetOptions contains the optional parameters for the CapabilityTypesClient.Get method. -func (client *CapabilityTypesClient) Get(ctx context.Context, locationName string, targetTypeName string, capabilityTypeName string, options *CapabilityTypesClientGetOptions) (CapabilityTypesClientGetResponse, error) { +func (client *CapabilityTypesClient) Get(ctx context.Context, location string, targetTypeName string, capabilityTypeName string, options *CapabilityTypesClientGetOptions) (CapabilityTypesClientGetResponse, error) { var err error const operationName = "CapabilityTypesClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, locationName, targetTypeName, capabilityTypeName, options) + req, err := client.getCreateRequest(ctx, location, targetTypeName, capabilityTypeName, options) if err != nil { return CapabilityTypesClientGetResponse{}, err } @@ -74,16 +74,16 @@ func (client *CapabilityTypesClient) Get(ctx context.Context, locationName strin } // getCreateRequest creates the Get request. -func (client *CapabilityTypesClient) getCreateRequest(ctx context.Context, locationName string, targetTypeName string, capabilityTypeName string, options *CapabilityTypesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}" +func (client *CapabilityTypesClient) getCreateRequest(ctx context.Context, location string, targetTypeName string, capabilityTypeName string, options *CapabilityTypesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if locationName == "" { - return nil, errors.New("parameter locationName cannot be empty") + if location == "" { + return nil, errors.New("parameter location cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) if targetTypeName == "" { return nil, errors.New("parameter targetTypeName cannot be empty") } @@ -97,7 +97,7 @@ func (client *CapabilityTypesClient) getCreateRequest(ctx context.Context, locat return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -114,12 +114,12 @@ func (client *CapabilityTypesClient) getHandleResponse(resp *http.Response) (Cap // NewListPager - Get a list of Capability Type resources for given Target Type and location. // -// Generated from API version 2024-01-01 -// - locationName - String that represents a Location resource name. +// Generated from API version 2025-01-01 +// - location - The name of the Azure region. // - targetTypeName - String that represents a Target Type resource name. // - options - CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.NewListPager // method. -func (client *CapabilityTypesClient) NewListPager(locationName string, targetTypeName string, options *CapabilityTypesClientListOptions) *runtime.Pager[CapabilityTypesClientListResponse] { +func (client *CapabilityTypesClient) NewListPager(location string, targetTypeName string, options *CapabilityTypesClientListOptions) *runtime.Pager[CapabilityTypesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CapabilityTypesClientListResponse]{ More: func(page CapabilityTypesClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -131,7 +131,7 @@ func (client *CapabilityTypesClient) NewListPager(locationName string, targetTyp nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, locationName, targetTypeName, options) + return client.listCreateRequest(ctx, location, targetTypeName, options) }, nil) if err != nil { return CapabilityTypesClientListResponse{}, err @@ -143,16 +143,16 @@ func (client *CapabilityTypesClient) NewListPager(locationName string, targetTyp } // listCreateRequest creates the List request. -func (client *CapabilityTypesClient) listCreateRequest(ctx context.Context, locationName string, targetTypeName string, options *CapabilityTypesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes" +func (client *CapabilityTypesClient) listCreateRequest(ctx context.Context, location string, targetTypeName string, options *CapabilityTypesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}/capabilityTypes" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if locationName == "" { - return nil, errors.New("parameter locationName cannot be empty") + if location == "" { + return nil, errors.New("parameter location cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) if targetTypeName == "" { return nil, errors.New("parameter targetTypeName cannot be empty") } @@ -162,7 +162,7 @@ func (client *CapabilityTypesClient) listCreateRequest(ctx context.Context, loca return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client_example_test.go deleted file mode 100644 index 8c3ecedd0c1a..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client_example_test.go +++ /dev/null @@ -1,100 +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 armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListCapabilityTypes.json -func ExampleCapabilityTypesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCapabilityTypesClient().NewListPager("westus2", "Microsoft-VirtualMachine", &armchaos.CapabilityTypesClientListOptions{ContinuationToken: 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.CapabilityTypeListResult = armchaos.CapabilityTypeListResult{ - // Value: []*armchaos.CapabilityType{ - // { - // Name: to.Ptr("Shutdown-1.0"), - // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes/capabilityTypes"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/providers/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-VirtualMachine/capabilityTypes/Shutdown-1.0"), - // Properties: &armchaos.CapabilityTypeProperties{ - // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), - // DisplayName: to.Ptr("Shutdown VM"), - // Kind: to.Ptr("fault"), - // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), - // Publisher: to.Ptr("Microsoft"), - // RuntimeProperties: &armchaos.CapabilityTypePropertiesRuntimeProperties{ - // Kind: to.Ptr("continuous"), - // }, - // TargetType: to.Ptr("VirtualMachine"), - // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetCapabilityType.json -func ExampleCapabilityTypesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCapabilityTypesClient().Get(ctx, "westus2", "Microsoft-VirtualMachine", "Shutdown-1.0", 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.CapabilityType = armchaos.CapabilityType{ - // Name: to.Ptr("Shutdown-1.0"), - // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes/capabilityTypes"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-VirtualMachine/capabilityTypes/Shutdown-1.0"), - // Properties: &armchaos.CapabilityTypeProperties{ - // Description: to.Ptr("Shutdown an Azure Virtual Machine for a defined period of time."), - // DisplayName: to.Ptr("Shutdown VM"), - // Kind: to.Ptr("fault"), - // ParametersSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine/capabilities/Shutdown-1.0.json"), - // Publisher: to.Ptr("Microsoft"), - // RuntimeProperties: &armchaos.CapabilityTypePropertiesRuntimeProperties{ - // Kind: to.Ptr("continuous"), - // }, - // TargetType: to.Ptr("VirtualMachine"), - // Urn: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), - // }, - // } -} diff --git a/sdk/resourcemanager/chaos/armchaos/capabilitytypes_live_test.go b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_live_test.go index 645111fd6af6..8f9d703db531 100644 --- a/sdk/resourcemanager/chaos/armchaos/capabilitytypes_live_test.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_live_test.go @@ -14,7 +14,7 @@ import ( "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/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/chaos/armchaos/client_factory.go b/sdk/resourcemanager/chaos/armchaos/client_factory.go index 6f27987f337c..33b2145d0386 100644 --- a/sdk/resourcemanager/chaos/armchaos/client_factory.go +++ b/sdk/resourcemanager/chaos/armchaos/client_factory.go @@ -22,7 +22,7 @@ type ClientFactory struct { // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - GUID that represents an Azure subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { @@ -52,17 +52,17 @@ func (c *ClientFactory) NewCapabilityTypesClient() *CapabilityTypesClient { } } -// NewExperimentsClient creates a new instance of ExperimentsClient. -func (c *ClientFactory) NewExperimentsClient() *ExperimentsClient { - return &ExperimentsClient{ +// NewExperimentExecutionsClient creates a new instance of ExperimentExecutionsClient. +func (c *ClientFactory) NewExperimentExecutionsClient() *ExperimentExecutionsClient { + return &ExperimentExecutionsClient{ subscriptionID: c.subscriptionID, internal: c.internal, } } -// NewOperationStatusesClient creates a new instance of OperationStatusesClient. -func (c *ClientFactory) NewOperationStatusesClient() *OperationStatusesClient { - return &OperationStatusesClient{ +// NewExperimentsClient creates a new instance of ExperimentsClient. +func (c *ClientFactory) NewExperimentsClient() *ExperimentsClient { + return &ExperimentsClient{ subscriptionID: c.subscriptionID, internal: c.internal, } diff --git a/sdk/resourcemanager/chaos/armchaos/constants.go b/sdk/resourcemanager/chaos/armchaos/constants.go index c3bb6f1fd184..a357454a7587 100644 --- a/sdk/resourcemanager/chaos/armchaos/constants.go +++ b/sdk/resourcemanager/chaos/armchaos/constants.go @@ -10,7 +10,7 @@ package armchaos const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" - moduleVersion = "v1.1.0" + moduleVersion = "v2.0.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -47,6 +47,24 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// ExperimentActionType - Enum union of Chaos experiment action types. +type ExperimentActionType string + +const ( + ExperimentActionTypeContinuous ExperimentActionType = "continuous" + ExperimentActionTypeDelay ExperimentActionType = "delay" + ExperimentActionTypeDiscrete ExperimentActionType = "discrete" +) + +// PossibleExperimentActionTypeValues returns the possible values for the ExperimentActionType const type. +func PossibleExperimentActionTypeValues() []ExperimentActionType { + return []ExperimentActionType{ + ExperimentActionTypeContinuous, + ExperimentActionTypeDelay, + ExperimentActionTypeDiscrete, + } +} + // FilterType - Enum that discriminates between filter types. Currently only Simple type is supported. type FilterType string @@ -61,6 +79,26 @@ func PossibleFilterTypeValues() []FilterType { } } +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + // 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 @@ -84,12 +122,18 @@ func PossibleOriginValues() []Origin { type ProvisioningState string const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating - Initial creation in progress. + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting - Deletion in progress. + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded - Resource has been created. ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateUpdating - Update in progress. + ProvisioningStateUpdating ProvisioningState = "Updating" ) // PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. @@ -104,24 +148,6 @@ func PossibleProvisioningStateValues() []ProvisioningState { } } -// ResourceIdentityType - String of the resource identity type. -type ResourceIdentityType string - -const ( - ResourceIdentityTypeNone ResourceIdentityType = "None" - ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" - ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" -) - -// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. -func PossibleResourceIdentityTypeValues() []ResourceIdentityType { - return []ResourceIdentityType{ - ResourceIdentityTypeNone, - ResourceIdentityTypeSystemAssigned, - ResourceIdentityTypeUserAssigned, - } -} - // SelectorType - Enum of the selector type. type SelectorType string @@ -142,6 +168,7 @@ func PossibleSelectorTypeValues() []SelectorType { type TargetReferenceType string const ( + // TargetReferenceTypeChaosTarget - Chaos target reference type. TargetReferenceTypeChaosTarget TargetReferenceType = "ChaosTarget" ) diff --git a/sdk/resourcemanager/chaos/armchaos/experimentexecutions_client.go b/sdk/resourcemanager/chaos/armchaos/experimentexecutions_client.go new file mode 100644 index 000000000000..9958a18650b4 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/experimentexecutions_client.go @@ -0,0 +1,249 @@ +//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 armchaos + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ExperimentExecutionsClient contains the methods for the ExperimentExecutions group. +// Don't use this type directly, use NewExperimentExecutionsClient() instead. +type ExperimentExecutionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewExperimentExecutionsClient creates a new instance of ExperimentExecutionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewExperimentExecutionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExperimentExecutionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ExperimentExecutionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Details - Execution details of an experiment resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - experimentName - String that represents a Experiment resource name. +// - executionID - GUID that represents a Experiment execution detail. +// - options - ExperimentExecutionsClientDetailsOptions contains the optional parameters for the ExperimentExecutionsClient.Details +// method. +func (client *ExperimentExecutionsClient) Details(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentExecutionsClientDetailsOptions) (ExperimentExecutionsClientDetailsResponse, error) { + var err error + const operationName = "ExperimentExecutionsClient.Details" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.detailsCreateRequest(ctx, resourceGroupName, experimentName, executionID, options) + if err != nil { + return ExperimentExecutionsClientDetailsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ExperimentExecutionsClientDetailsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExperimentExecutionsClientDetailsResponse{}, err + } + resp, err := client.detailsHandleResponse(httpResp) + return resp, err +} + +// detailsCreateRequest creates the Details request. +func (client *ExperimentExecutionsClient) detailsCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentExecutionsClientDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/details" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + if executionID == "" { + return nil, errors.New("parameter executionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{executionId}", url.PathEscape(executionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-01-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// detailsHandleResponse handles the Details response. +func (client *ExperimentExecutionsClient) detailsHandleResponse(resp *http.Response) (ExperimentExecutionsClientDetailsResponse, error) { + result := ExperimentExecutionsClientDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecutionDetails); err != nil { + return ExperimentExecutionsClientDetailsResponse{}, err + } + return result, nil +} + +// Get - Get an execution of an Experiment resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - experimentName - String that represents a Experiment resource name. +// - executionID - GUID that represents a Experiment execution detail. +// - options - ExperimentExecutionsClientGetOptions contains the optional parameters for the ExperimentExecutionsClient.Get +// method. +func (client *ExperimentExecutionsClient) Get(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentExecutionsClientGetOptions) (ExperimentExecutionsClientGetResponse, error) { + var err error + const operationName = "ExperimentExecutionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, experimentName, executionID, options) + if err != nil { + return ExperimentExecutionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ExperimentExecutionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExperimentExecutionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ExperimentExecutionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentExecutionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + if executionID == "" { + return nil, errors.New("parameter executionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{executionId}", url.PathEscape(executionID)) + 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", "2025-01-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ExperimentExecutionsClient) getHandleResponse(resp *http.Response) (ExperimentExecutionsClientGetResponse, error) { + result := ExperimentExecutionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecution); err != nil { + return ExperimentExecutionsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get a list of executions of an Experiment resource. +// +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentExecutionsClientListOptions contains the optional parameters for the ExperimentExecutionsClient.NewListPager +// method. +func (client *ExperimentExecutionsClient) NewListPager(resourceGroupName string, experimentName string, options *ExperimentExecutionsClientListOptions) *runtime.Pager[ExperimentExecutionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ExperimentExecutionsClientListResponse]{ + More: func(page ExperimentExecutionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ExperimentExecutionsClientListResponse) (ExperimentExecutionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExperimentExecutionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, experimentName, options) + }, nil) + if err != nil { + return ExperimentExecutionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ExperimentExecutionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentExecutionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if experimentName == "" { + return nil, errors.New("parameter experimentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) + 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", "2025-01-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ExperimentExecutionsClient) listHandleResponse(resp *http.Response) (ExperimentExecutionsClientListResponse, error) { + result := ExperimentExecutionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecutionListResult); err != nil { + return ExperimentExecutionsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/chaos/armchaos/experiments_client.go b/sdk/resourcemanager/chaos/armchaos/experiments_client.go index 404257553384..fe3cf15db118 100644 --- a/sdk/resourcemanager/chaos/armchaos/experiments_client.go +++ b/sdk/resourcemanager/chaos/armchaos/experiments_client.go @@ -29,7 +29,7 @@ type ExperimentsClient struct { } // NewExperimentsClient creates a new instance of ExperimentsClient with the specified values. -// - subscriptionID - GUID that represents an Azure subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExperimentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExperimentsClient, error) { @@ -47,13 +47,11 @@ func NewExperimentsClient(subscriptionID string, credential azcore.TokenCredenti // BeginCancel - Cancel a running Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - experimentName - String that represents a Experiment resource name. +// Generated from API version 2025-01-01 // - options - ExperimentsClientBeginCancelOptions contains the optional parameters for the ExperimentsClient.BeginCancel method. -func (client *ExperimentsClient) BeginCancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginCancelOptions) (*runtime.Poller[ExperimentsClientCancelResponse], error) { +func (client *ExperimentsClient) BeginCancel(ctx context.Context, options *ExperimentsClientBeginCancelOptions) (*runtime.Poller[ExperimentsClientCancelResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.cancel(ctx, resourceGroupName, experimentName, options) + resp, err := client.cancel(ctx, options) if err != nil { return nil, err } @@ -72,14 +70,14 @@ func (client *ExperimentsClient) BeginCancel(ctx context.Context, resourceGroupN // Cancel - Cancel a running Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -func (client *ExperimentsClient) cancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginCancelOptions) (*http.Response, error) { +// Generated from API version 2025-01-01 +func (client *ExperimentsClient) cancel(ctx context.Context, options *ExperimentsClientBeginCancelOptions) (*http.Response, error) { var err error const operationName = "ExperimentsClient.BeginCancel" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.cancelCreateRequest(ctx, resourceGroupName, experimentName, options) + req, err := client.cancelCreateRequest(ctx, options) if err != nil { return nil, err } @@ -87,7 +85,7 @@ func (client *ExperimentsClient) cancel(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -95,26 +93,14 @@ func (client *ExperimentsClient) cancel(ctx context.Context, resourceGroupName s } // cancelCreateRequest creates the Cancel request. -func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginCancelOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if experimentName == "" { - return nil, errors.New("parameter experimentName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) +func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, options *ExperimentsClientBeginCancelOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Chaos/cancel" req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -123,15 +109,15 @@ func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resour // BeginCreateOrUpdate - Create or update a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - experimentName - String that represents a Experiment resource name. -// - experiment - Experiment resource to be created or updated. +// - resource - Experiment resource to be created or updated. // - options - ExperimentsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.BeginCreateOrUpdate // method. -func (client *ExperimentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExperimentsClientCreateOrUpdateResponse], error) { +func (client *ExperimentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, resource Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExperimentsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, experimentName, experiment, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, experimentName, resource, options) if err != nil { return nil, err } @@ -150,14 +136,14 @@ func (client *ExperimentsClient) BeginCreateOrUpdate(ctx context.Context, resour // CreateOrUpdate - Create or update a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -func (client *ExperimentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2025-01-01 +func (client *ExperimentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, resource Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "ExperimentsClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, experimentName, experiment, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, experimentName, resource, options) if err != nil { return nil, err } @@ -173,7 +159,7 @@ func (client *ExperimentsClient) createOrUpdate(ctx context.Context, resourceGro } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, resource Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -192,10 +178,10 @@ func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, experiment); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -204,8 +190,8 @@ func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context // BeginDelete - Delete a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - experimentName - String that represents a Experiment resource name. // - options - ExperimentsClientBeginDeleteOptions contains the optional parameters for the ExperimentsClient.BeginDelete method. func (client *ExperimentsClient) BeginDelete(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginDeleteOptions) (*runtime.Poller[ExperimentsClientDeleteResponse], error) { @@ -229,7 +215,7 @@ func (client *ExperimentsClient) BeginDelete(ctx context.Context, resourceGroupN // Delete - Delete a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 +// Generated from API version 2025-01-01 func (client *ExperimentsClient) deleteOperation(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ExperimentsClient.BeginDelete" @@ -244,7 +230,7 @@ func (client *ExperimentsClient) deleteOperation(ctx context.Context, resourceGr if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -271,87 +257,17 @@ func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// ExecutionDetails - Execution details of an experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - experimentName - String that represents a Experiment resource name. -// - executionID - GUID that represents a Experiment execution detail. -// - options - ExperimentsClientExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.ExecutionDetails -// method. -func (client *ExperimentsClient) ExecutionDetails(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentsClientExecutionDetailsOptions) (ExperimentsClientExecutionDetailsResponse, error) { - var err error - const operationName = "ExperimentsClient.ExecutionDetails" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.executionDetailsCreateRequest(ctx, resourceGroupName, experimentName, executionID, options) - if err != nil { - return ExperimentsClientExecutionDetailsResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExperimentsClientExecutionDetailsResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExperimentsClientExecutionDetailsResponse{}, err - } - resp, err := client.executionDetailsHandleResponse(httpResp) - return resp, err -} - -// executionDetailsCreateRequest creates the ExecutionDetails request. -func (client *ExperimentsClient) executionDetailsCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentsClientExecutionDetailsOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/getExecutionDetails" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if experimentName == "" { - return nil, errors.New("parameter experimentName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - if executionID == "" { - return nil, errors.New("parameter executionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{executionId}", url.PathEscape(executionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// executionDetailsHandleResponse handles the ExecutionDetails response. -func (client *ExperimentsClient) executionDetailsHandleResponse(resp *http.Response) (ExperimentsClientExecutionDetailsResponse, error) { - result := ExperimentsClientExecutionDetailsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecutionDetails); err != nil { - return ExperimentsClientExecutionDetailsResponse{}, err - } - return result, nil -} - // Get - Get a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - experimentName - String that represents a Experiment resource name. // - options - ExperimentsClientGetOptions contains the optional parameters for the ExperimentsClient.Get method. func (client *ExperimentsClient) Get(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientGetOptions) (ExperimentsClientGetResponse, error) { @@ -396,7 +312,7 @@ func (client *ExperimentsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -411,106 +327,37 @@ func (client *ExperimentsClient) getHandleResponse(resp *http.Response) (Experim return result, nil } -// GetExecution - Get an execution of an Experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListByResourceGroupPager - Get a list of Experiment resources in a resource group. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - experimentName - String that represents a Experiment resource name. -// - executionID - GUID that represents a Experiment execution detail. -// - options - ExperimentsClientGetExecutionOptions contains the optional parameters for the ExperimentsClient.GetExecution +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ExperimentsClientListByResourceGroupOptions contains the optional parameters for the ExperimentsClient.NewListByResourceGroupPager // method. -func (client *ExperimentsClient) GetExecution(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentsClientGetExecutionOptions) (ExperimentsClientGetExecutionResponse, error) { - var err error - const operationName = "ExperimentsClient.GetExecution" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getExecutionCreateRequest(ctx, resourceGroupName, experimentName, executionID, options) - if err != nil { - return ExperimentsClientGetExecutionResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExperimentsClientGetExecutionResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExperimentsClientGetExecutionResponse{}, err - } - resp, err := client.getExecutionHandleResponse(httpResp) - return resp, err -} - -// getExecutionCreateRequest creates the GetExecution request. -func (client *ExperimentsClient) getExecutionCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *ExperimentsClientGetExecutionOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if experimentName == "" { - return nil, errors.New("parameter experimentName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - if executionID == "" { - return nil, errors.New("parameter executionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{executionId}", url.PathEscape(executionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getExecutionHandleResponse handles the GetExecution response. -func (client *ExperimentsClient) getExecutionHandleResponse(resp *http.Response) (ExperimentsClientGetExecutionResponse, error) { - result := ExperimentsClientGetExecutionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecution); err != nil { - return ExperimentsClientGetExecutionResponse{}, err - } - return result, nil -} - -// NewListPager - Get a list of Experiment resources in a resource group. -// -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - options - ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.NewListPager method. -func (client *ExperimentsClient) NewListPager(resourceGroupName string, options *ExperimentsClientListOptions) *runtime.Pager[ExperimentsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListResponse]{ - More: func(page ExperimentsClientListResponse) bool { +func (client *ExperimentsClient) NewListByResourceGroupPager(resourceGroupName string, options *ExperimentsClientListByResourceGroupOptions) *runtime.Pager[ExperimentsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListByResourceGroupResponse]{ + More: func(page ExperimentsClientListByResourceGroupResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *ExperimentsClientListResponse) (ExperimentsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExperimentsClient.NewListPager") + Fetcher: func(ctx context.Context, page *ExperimentsClientListByResourceGroupResponse) (ExperimentsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExperimentsClient.NewListByResourceGroupPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, options) + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) }, nil) if err != nil { - return ExperimentsClientListResponse{}, err + return ExperimentsClientListByResourceGroupResponse{}, err } - return client.listHandleResponse(resp) + return client.listByResourceGroupHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listCreateRequest creates the List request. -func (client *ExperimentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *ExperimentsClientListOptions) (*policy.Request, error) { +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ExperimentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ExperimentsClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -525,7 +372,7 @@ func (client *ExperimentsClient) listCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } @@ -537,44 +384,45 @@ func (client *ExperimentsClient) listCreateRequest(ctx context.Context, resource return req, nil } -// listHandleResponse handles the List response. -func (client *ExperimentsClient) listHandleResponse(resp *http.Response) (ExperimentsClientListResponse, error) { - result := ExperimentsClientListResponse{} +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ExperimentsClient) listByResourceGroupHandleResponse(resp *http.Response) (ExperimentsClientListByResourceGroupResponse, error) { + result := ExperimentsClientListByResourceGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentListResult); err != nil { - return ExperimentsClientListResponse{}, err + return ExperimentsClientListByResourceGroupResponse{}, err } return result, nil } -// NewListAllPager - Get a list of Experiment resources in a subscription. +// NewListBySubscriptionPager - Get a list of Experiment resources in a subscription. // -// Generated from API version 2024-01-01 -// - options - ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.NewListAllPager method. -func (client *ExperimentsClient) NewListAllPager(options *ExperimentsClientListAllOptions) *runtime.Pager[ExperimentsClientListAllResponse] { - return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListAllResponse]{ - More: func(page ExperimentsClientListAllResponse) bool { +// Generated from API version 2025-01-01 +// - options - ExperimentsClientListBySubscriptionOptions contains the optional parameters for the ExperimentsClient.NewListBySubscriptionPager +// method. +func (client *ExperimentsClient) NewListBySubscriptionPager(options *ExperimentsClientListBySubscriptionOptions) *runtime.Pager[ExperimentsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListBySubscriptionResponse]{ + More: func(page ExperimentsClientListBySubscriptionResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *ExperimentsClientListAllResponse) (ExperimentsClientListAllResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExperimentsClient.NewListAllPager") + Fetcher: func(ctx context.Context, page *ExperimentsClientListBySubscriptionResponse) (ExperimentsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExperimentsClient.NewListBySubscriptionPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listAllCreateRequest(ctx, options) + return client.listBySubscriptionCreateRequest(ctx, options) }, nil) if err != nil { - return ExperimentsClientListAllResponse{}, err + return ExperimentsClientListBySubscriptionResponse{}, err } - return client.listAllHandleResponse(resp) + return client.listBySubscriptionHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listAllCreateRequest creates the ListAll request. -func (client *ExperimentsClient) listAllCreateRequest(ctx context.Context, options *ExperimentsClientListAllOptions) (*policy.Request, error) { +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ExperimentsClient) listBySubscriptionCreateRequest(ctx context.Context, options *ExperimentsClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/experiments" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -585,7 +433,7 @@ func (client *ExperimentsClient) listAllCreateRequest(ctx context.Context, optio return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } @@ -597,76 +445,11 @@ func (client *ExperimentsClient) listAllCreateRequest(ctx context.Context, optio return req, nil } -// listAllHandleResponse handles the ListAll response. -func (client *ExperimentsClient) listAllHandleResponse(resp *http.Response) (ExperimentsClientListAllResponse, error) { - result := ExperimentsClientListAllResponse{} +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ExperimentsClient) listBySubscriptionHandleResponse(resp *http.Response) (ExperimentsClientListBySubscriptionResponse, error) { + result := ExperimentsClientListBySubscriptionResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentListResult); err != nil { - return ExperimentsClientListAllResponse{}, err - } - return result, nil -} - -// NewListAllExecutionsPager - Get a list of executions of an Experiment resource. -// -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - experimentName - String that represents a Experiment resource name. -// - options - ExperimentsClientListAllExecutionsOptions contains the optional parameters for the ExperimentsClient.NewListAllExecutionsPager -// method. -func (client *ExperimentsClient) NewListAllExecutionsPager(resourceGroupName string, experimentName string, options *ExperimentsClientListAllExecutionsOptions) *runtime.Pager[ExperimentsClientListAllExecutionsResponse] { - return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListAllExecutionsResponse]{ - More: func(page ExperimentsClientListAllExecutionsResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExperimentsClientListAllExecutionsResponse) (ExperimentsClientListAllExecutionsResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExperimentsClient.NewListAllExecutionsPager") - 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.listAllExecutionsCreateRequest(ctx, resourceGroupName, experimentName, options) - }, nil) - if err != nil { - return ExperimentsClientListAllExecutionsResponse{}, err - } - return client.listAllExecutionsHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listAllExecutionsCreateRequest creates the ListAllExecutions request. -func (client *ExperimentsClient) listAllExecutionsCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientListAllExecutionsOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if experimentName == "" { - return nil, errors.New("parameter experimentName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listAllExecutionsHandleResponse handles the ListAllExecutions response. -func (client *ExperimentsClient) listAllExecutionsHandleResponse(resp *http.Response) (ExperimentsClientListAllExecutionsResponse, error) { - result := ExperimentsClientListAllExecutionsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentExecutionListResult); err != nil { - return ExperimentsClientListAllExecutionsResponse{}, err + return ExperimentsClientListBySubscriptionResponse{}, err } return result, nil } @@ -674,13 +457,11 @@ func (client *ExperimentsClient) listAllExecutionsHandleResponse(resp *http.Resp // BeginStart - Start a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - experimentName - String that represents a Experiment resource name. +// Generated from API version 2025-01-01 // - options - ExperimentsClientBeginStartOptions contains the optional parameters for the ExperimentsClient.BeginStart method. -func (client *ExperimentsClient) BeginStart(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginStartOptions) (*runtime.Poller[ExperimentsClientStartResponse], error) { +func (client *ExperimentsClient) BeginStart(ctx context.Context, options *ExperimentsClientBeginStartOptions) (*runtime.Poller[ExperimentsClientStartResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.start(ctx, resourceGroupName, experimentName, options) + resp, err := client.start(ctx, options) if err != nil { return nil, err } @@ -699,14 +480,14 @@ func (client *ExperimentsClient) BeginStart(ctx context.Context, resourceGroupNa // Start - Start a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -func (client *ExperimentsClient) start(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginStartOptions) (*http.Response, error) { +// Generated from API version 2025-01-01 +func (client *ExperimentsClient) start(ctx context.Context, options *ExperimentsClientBeginStartOptions) (*http.Response, error) { var err error const operationName = "ExperimentsClient.BeginStart" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.startCreateRequest(ctx, resourceGroupName, experimentName, options) + req, err := client.startCreateRequest(ctx, options) if err != nil { return nil, err } @@ -714,7 +495,7 @@ func (client *ExperimentsClient) start(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -722,26 +503,14 @@ func (client *ExperimentsClient) start(ctx context.Context, resourceGroupName st } // startCreateRequest creates the Start request. -func (client *ExperimentsClient) startCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginStartOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if experimentName == "" { - return nil, errors.New("parameter experimentName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) +func (client *ExperimentsClient) startCreateRequest(ctx context.Context, options *ExperimentsClientBeginStartOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Chaos/start" req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -750,14 +519,14 @@ func (client *ExperimentsClient) startCreateRequest(ctx context.Context, resourc // BeginUpdate - The operation to update an experiment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - experimentName - String that represents a Experiment resource name. -// - experiment - Parameters supplied to the Update experiment operation. +// - properties - Parameters supplied to the Update experiment operation. // - options - ExperimentsClientBeginUpdateOptions contains the optional parameters for the ExperimentsClient.BeginUpdate method. -func (client *ExperimentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment ExperimentUpdate, options *ExperimentsClientBeginUpdateOptions) (*runtime.Poller[ExperimentsClientUpdateResponse], error) { +func (client *ExperimentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, experimentName string, properties ExperimentUpdate, options *ExperimentsClientBeginUpdateOptions) (*runtime.Poller[ExperimentsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, experimentName, experiment, options) + resp, err := client.update(ctx, resourceGroupName, experimentName, properties, options) if err != nil { return nil, err } @@ -776,14 +545,14 @@ func (client *ExperimentsClient) BeginUpdate(ctx context.Context, resourceGroupN // Update - The operation to update an experiment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -func (client *ExperimentsClient) update(ctx context.Context, resourceGroupName string, experimentName string, experiment ExperimentUpdate, options *ExperimentsClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2025-01-01 +func (client *ExperimentsClient) update(ctx context.Context, resourceGroupName string, experimentName string, properties ExperimentUpdate, options *ExperimentsClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "ExperimentsClient.BeginUpdate" 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, experimentName, experiment, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, experimentName, properties, options) if err != nil { return nil, err } @@ -791,7 +560,7 @@ func (client *ExperimentsClient) update(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -799,7 +568,7 @@ func (client *ExperimentsClient) update(ctx context.Context, resourceGroupName s } // updateCreateRequest creates the Update request. -func (client *ExperimentsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, experiment ExperimentUpdate, options *ExperimentsClientBeginUpdateOptions) (*policy.Request, error) { +func (client *ExperimentsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, properties ExperimentUpdate, options *ExperimentsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -818,10 +587,10 @@ func (client *ExperimentsClient) updateCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, experiment); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/chaos/armchaos/experiments_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/experiments_client_example_test.go deleted file mode 100644 index fb537dbc74ef..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/experiments_client_example_test.go +++ /dev/null @@ -1,605 +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 armchaos_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/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentsInASubscription.json -func ExampleExperimentsClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExperimentsClient().NewListAllPager(&armchaos.ExperimentsClientListAllOptions{Running: nil, - ContinuationToken: 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.ExperimentListResult = armchaos.ExperimentListResult{ - // Value: []*armchaos.Experiment{ - // { - // Name: to.Ptr("exampleExperiment"), - // Type: to.Ptr("Microsoft.Chaos/experiments"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), - // Location: to.Ptr("centraluseuap"), - // Identity: &armchaos.ResourceIdentity{ - // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), - // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), - // }, - // Properties: &armchaos.ExperimentProperties{ - // Selectors: []armchaos.TargetSelectorClassification{ - // &armchaos.TargetListSelector{ - // Type: to.Ptr(armchaos.SelectorTypeList), - // ID: to.Ptr("selector1"), - // Targets: []*armchaos.TargetReference{ - // { - // Type: to.Ptr(armchaos.TargetReferenceTypeChaosTarget), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), - // }}, - // }}, - // Steps: []*armchaos.ExperimentStep{ - // { - // Name: to.Ptr("step1"), - // Branches: []*armchaos.ExperimentBranch{ - // { - // Name: to.Ptr("branch1"), - // Actions: []armchaos.ExperimentActionClassification{ - // &armchaos.ContinuousAction{ - // Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), - // Type: to.Ptr("continuous"), - // Duration: to.Ptr("PT10M"), - // Parameters: []*armchaos.KeyValuePair{ - // { - // Key: to.Ptr("abruptShutdown"), - // Value: to.Ptr("false"), - // }}, - // SelectorID: to.Ptr("selector1"), - // }}, - // }}, - // }}, - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // CreatedBy: to.Ptr("User"), - // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // LastModifiedBy: to.Ptr("User"), - // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentsInAResourceGroup.json -func ExampleExperimentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExperimentsClient().NewListPager("exampleRG", &armchaos.ExperimentsClientListOptions{Running: nil, - ContinuationToken: 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.ExperimentListResult = armchaos.ExperimentListResult{ - // Value: []*armchaos.Experiment{ - // { - // Name: to.Ptr("exampleExperiment"), - // Type: to.Ptr("Microsoft.Chaos/experiments"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), - // Location: to.Ptr("centraluseuap"), - // Identity: &armchaos.ResourceIdentity{ - // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), - // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), - // }, - // Properties: &armchaos.ExperimentProperties{ - // Selectors: []armchaos.TargetSelectorClassification{ - // &armchaos.TargetListSelector{ - // Type: to.Ptr(armchaos.SelectorTypeList), - // ID: to.Ptr("selector1"), - // Targets: []*armchaos.TargetReference{ - // { - // Type: to.Ptr(armchaos.TargetReferenceTypeChaosTarget), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), - // }}, - // }}, - // Steps: []*armchaos.ExperimentStep{ - // { - // Name: to.Ptr("step1"), - // Branches: []*armchaos.ExperimentBranch{ - // { - // Name: to.Ptr("branch1"), - // Actions: []armchaos.ExperimentActionClassification{ - // &armchaos.ContinuousAction{ - // Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), - // Type: to.Ptr("continuous"), - // Duration: to.Ptr("PT10M"), - // Parameters: []*armchaos.KeyValuePair{ - // { - // Key: to.Ptr("abruptShutdown"), - // Value: to.Ptr("false"), - // }}, - // SelectorID: to.Ptr("selector1"), - // }}, - // }}, - // }}, - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // CreatedBy: to.Ptr("User"), - // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // LastModifiedBy: to.Ptr("User"), - // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/DeleteExperiment.json -func ExampleExperimentsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewExperimentsClient().BeginDelete(ctx, "exampleRG", "exampleExperiment", 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/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperiment.json -func ExampleExperimentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExperimentsClient().Get(ctx, "exampleRG", "exampleExperiment", 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.Experiment = armchaos.Experiment{ - // Name: to.Ptr("exampleExperiment"), - // Type: to.Ptr("Microsoft.Chaos/experiments"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), - // Location: to.Ptr("centraluseuap"), - // Identity: &armchaos.ResourceIdentity{ - // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), - // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), - // }, - // Properties: &armchaos.ExperimentProperties{ - // Selectors: []armchaos.TargetSelectorClassification{ - // &armchaos.TargetListSelector{ - // Type: to.Ptr(armchaos.SelectorTypeList), - // ID: to.Ptr("selector1"), - // Targets: []*armchaos.TargetReference{ - // { - // Type: to.Ptr(armchaos.TargetReferenceTypeChaosTarget), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), - // }}, - // }}, - // Steps: []*armchaos.ExperimentStep{ - // { - // Name: to.Ptr("step1"), - // Branches: []*armchaos.ExperimentBranch{ - // { - // Name: to.Ptr("branch1"), - // Actions: []armchaos.ExperimentActionClassification{ - // &armchaos.ContinuousAction{ - // Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), - // Type: to.Ptr("continuous"), - // Duration: to.Ptr("PT10M"), - // Parameters: []*armchaos.KeyValuePair{ - // { - // Key: to.Ptr("abruptShutdown"), - // Value: to.Ptr("false"), - // }}, - // SelectorID: to.Ptr("selector1"), - // }}, - // }}, - // }}, - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // CreatedBy: to.Ptr("User"), - // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // LastModifiedBy: to.Ptr("User"), - // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateExperiment.json -func ExampleExperimentsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewExperimentsClient().BeginCreateOrUpdate(ctx, "exampleRG", "exampleExperiment", armchaos.Experiment{ - Location: to.Ptr("eastus2euap"), - Identity: &armchaos.ResourceIdentity{ - Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armchaos.ExperimentProperties{ - Selectors: []armchaos.TargetSelectorClassification{ - &armchaos.TargetListSelector{ - Type: to.Ptr(armchaos.SelectorTypeList), - ID: to.Ptr("selector1"), - Targets: []*armchaos.TargetReference{ - { - Type: to.Ptr(armchaos.TargetReferenceTypeChaosTarget), - ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), - }}, - }}, - Steps: []*armchaos.ExperimentStep{ - { - Name: to.Ptr("step1"), - Branches: []*armchaos.ExperimentBranch{ - { - Name: to.Ptr("branch1"), - Actions: []armchaos.ExperimentActionClassification{ - &armchaos.ContinuousAction{ - Name: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), - Type: to.Ptr("continuous"), - Duration: to.Ptr("PT10M"), - Parameters: []*armchaos.KeyValuePair{ - { - Key: to.Ptr("abruptShutdown"), - Value: to.Ptr("false"), - }}, - SelectorID: to.Ptr("selector1"), - }}, - }}, - }}, - }, - }, 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.Experiment = armchaos.Experiment{ - // Name: to.Ptr("exampleExperiment"), - // Type: to.Ptr("Microsoft.Chaos/experiments"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment"), - // Location: to.Ptr("eastus2euap"), - // Identity: &armchaos.ResourceIdentity{ - // Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("d04ab567-2c07-43ef-a7f4-4527626b7f56"), - // TenantID: to.Ptr("8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"), - // }, - // Properties: &armchaos.ExperimentProperties{ - // ProvisioningState: to.Ptr(armchaos.ProvisioningStateSucceeded), - // Selectors: []armchaos.TargetSelectorClassification{ - // &armchaos.TargetListSelector{ - // Type: to.Ptr(armchaos.SelectorTypeList), - // ID: to.Ptr("selector1"), - // Targets: []*armchaos.TargetReference{ - // { - // Type: to.Ptr(armchaos.TargetReferenceTypeChaosTarget), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), - // }}, - // }}, - // Steps: []*armchaos.ExperimentStep{ - // { - // Name: to.Ptr("step1"), - // Branches: []*armchaos.ExperimentBranch{ - // { - // Name: to.Ptr("branch1"), - // Actions: []armchaos.ExperimentActionClassification{ - // &armchaos.ContinuousAction{ - // Name: to.Ptr("urn:csci:microsoft:virtualMachine:shutdown/1.0"), - // Type: to.Ptr("continuous"), - // Duration: to.Ptr("PT10M"), - // Parameters: []*armchaos.KeyValuePair{ - // { - // Key: to.Ptr("abruptShutdown"), - // Value: to.Ptr("false"), - // }}, - // SelectorID: to.Ptr("selector1"), - // }}, - // }}, - // }}, - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // CreatedBy: to.Ptr("User"), - // CreatedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // LastModifiedBy: to.Ptr("User"), - // LastModifiedByType: to.Ptr(armchaos.CreatedByType("b3a41dba-4415-4d36-9ee8-e5eaa86db976")), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/UpdateExperiment.json -func ExampleExperimentsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewExperimentsClient().BeginUpdate(ctx, "exampleRG", "exampleExperiment", armchaos.ExperimentUpdate{ - Identity: &armchaos.ResourceIdentity{ - Type: to.Ptr(armchaos.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armchaos.UserAssignedIdentity{ - "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.ManagedIdentity/userAssignedIdentity/exampleUMI": {}, - }, - }, - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, - }, 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/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CancelExperiment.json -func ExampleExperimentsClient_BeginCancel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewExperimentsClient().BeginCancel(ctx, "exampleRG", "exampleExperiment", 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/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/StartExperiment.json -func ExampleExperimentsClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewExperimentsClient().BeginStart(ctx, "exampleRG", "exampleExperiment", 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/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentExecutions.json -func ExampleExperimentsClient_NewListAllExecutionsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExperimentsClient().NewListAllExecutionsPager("exampleRG", "exampleExperiment", 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.ExperimentExecutionListResult = armchaos.ExperimentExecutionListResult{ - // Value: []*armchaos.ExperimentExecution{ - // { - // Name: to.Ptr("f24500ad-744e-4a26-864b-b76199eac333"), - // Type: to.Ptr("Microsoft.Chaos/experiments/executions"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/executions/"), - // Properties: &armchaos.ExperimentExecutionProperties{ - // StartedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.255Z"); return t}()), - // Status: to.Ptr("failed"), - // StoppedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:18.928Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("14d98367-52ef-4596-be4f-53fc81bbfc33"), - // Type: to.Ptr("Microsoft.Chaos/experiments/executions"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/executionDetails/14d98367-52ef-4596-be4f-53fc81bbfc33"), - // Properties: &armchaos.ExperimentExecutionProperties{ - // StartedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.255Z"); return t}()), - // Status: to.Ptr("success"), - // StoppedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:18.928Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperimentExecution.json -func ExampleExperimentsClient_GetExecution() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExperimentsClient().GetExecution(ctx, "exampleRG", "exampleExperiment", "f24500ad-744e-4a26-864b-b76199eac333", 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.ExperimentExecution = armchaos.ExperimentExecution{ - // Name: to.Ptr("f24500ad-744e-4a26-864b-b76199eac333"), - // Type: to.Ptr("Microsoft.Chaos/experiments/executions"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/executions/f24500ad-744e-4a26-864b-b76199eac333"), - // Properties: &armchaos.ExperimentExecutionProperties{ - // StartedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.255Z"); return t}()), - // Status: to.Ptr("failed"), - // StoppedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:18.928Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/DetailsExperiment.json -func ExampleExperimentsClient_ExecutionDetails() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExperimentsClient().ExecutionDetails(ctx, "exampleRG", "exampleExperiment", "f24500ad-744e-4a26-864b-b76199eac333", 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.ExperimentExecutionDetails = armchaos.ExperimentExecutionDetails{ - // Name: to.Ptr("f24500ad-744e-4a26-864b-b76199eac333"), - // Type: to.Ptr("Microsoft.Chaos/experiments/executions/getExecutionDetails"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment/executions/f24500ad-744e-4a26-864b-b76199eac333/getExecutionDetails"), - // Properties: &armchaos.ExperimentExecutionDetailsProperties{ - // StartedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.255Z"); return t}()), - // Status: to.Ptr("failed"), - // StoppedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:18.928Z"); return t}()), - // FailureReason: to.Ptr("Dependency failure"), - // LastActionAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:52:52.255Z"); return t}()), - // RunInformation: &armchaos.ExperimentExecutionDetailsPropertiesRunInformation{ - // Steps: []*armchaos.StepStatus{ - // { - // Branches: []*armchaos.BranchStatus{ - // { - // Actions: []*armchaos.ActionStatus{ - // { - // ActionID: to.Ptr("59499d33-6751-4b6e-a1f6-58f4d56a040a"), - // ActionName: to.Ptr("urn:provider:agent-v2:Microsoft.Azure.Chaos.Fault.CPUPressureAllProcessors"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:13.627Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-14T21:56:13.627Z"); return t}()), - // Status: to.Ptr("failed"), - // Targets: []*armchaos.ExperimentExecutionActionTargetDetailsProperties{ - // { - // Status: to.Ptr("succeeded"), - // Target: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/VM1"), - // TargetCompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T17:30:55.000Z"); return t}()), - // TargetFailedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T16:30:55.000Z"); return t}()), - // }, - // { - // Status: to.Ptr("failed"), - // Target: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/VM1"), - // TargetCompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T17:30:55.000Z"); return t}()), - // TargetFailedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-02T16:30:55.000Z"); return t}()), - // }}, - // }}, - // BranchID: to.Ptr("FirstBranch"), - // BranchName: to.Ptr("FirstBranch"), - // Status: to.Ptr("failed"), - // }}, - // Status: to.Ptr("failed"), - // StepID: to.Ptr("FirstStep"), - // StepName: to.Ptr("FirstStep"), - // }}, - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/chaos/armchaos/experiments_live_test.go b/sdk/resourcemanager/chaos/armchaos/experiments_live_test.go index 8d7d1dd2ff2c..365482e238c0 100644 --- a/sdk/resourcemanager/chaos/armchaos/experiments_live_test.go +++ b/sdk/resourcemanager/chaos/armchaos/experiments_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" diff --git a/sdk/resourcemanager/chaos/armchaos/fake/capabilities_server.go b/sdk/resourcemanager/chaos/armchaos/fake/capabilities_server.go index 859cfec668df..d94ac4897e65 100644 --- a/sdk/resourcemanager/chaos/armchaos/fake/capabilities_server.go +++ b/sdk/resourcemanager/chaos/armchaos/fake/capabilities_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "net/http" "net/url" "regexp" @@ -25,20 +25,20 @@ import ( // CapabilitiesServer is a fake server for instances of the armchaos.CapabilitiesClient type. type CapabilitiesServer struct { // CreateOrUpdate is the fake for method CapabilitiesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK - CreateOrUpdate func(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, capability armchaos.Capability, options *armchaos.CapabilitiesClientCreateOrUpdateOptions) (resp azfake.Responder[armchaos.CapabilitiesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, resource armchaos.Capability, options *armchaos.CapabilitiesClientCreateOrUpdateOptions) (resp azfake.Responder[armchaos.CapabilitiesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method CapabilitiesClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *armchaos.CapabilitiesClientDeleteOptions) (resp azfake.Responder[armchaos.CapabilitiesClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, options *armchaos.CapabilitiesClientDeleteOptions) (resp azfake.Responder[armchaos.CapabilitiesClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method CapabilitiesClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, capabilityName string, options *armchaos.CapabilitiesClientGetOptions) (resp azfake.Responder[armchaos.CapabilitiesClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, targetName string, capabilityName string, options *armchaos.CapabilitiesClientGetOptions) (resp azfake.Responder[armchaos.CapabilitiesClientGetResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method CapabilitiesClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *armchaos.CapabilitiesClientListOptions) (resp azfake.PagerResponder[armchaos.CapabilitiesClientListResponse]) + NewListPager func(resourceGroupName string, targetName string, options *armchaos.CapabilitiesClientListOptions) (resp azfake.PagerResponder[armchaos.CapabilitiesClientListResponse]) } // NewCapabilitiesServerTransport creates a new instance of CapabilitiesServerTransport with the provided implementation. @@ -93,10 +93,10 @@ func (c *CapabilitiesServerTransport) dispatchCreateOrUpdate(req *http.Request) if c.srv.CreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 7 { + if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armchaos.Capability](req) @@ -107,18 +107,6 @@ func (c *CapabilitiesServerTransport) dispatchCreateOrUpdate(req *http.Request) if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } targetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("targetName")]) if err != nil { return nil, err @@ -127,13 +115,13 @@ func (c *CapabilitiesServerTransport) dispatchCreateOrUpdate(req *http.Request) if err != nil { return nil, err } - respr, errRespr := c.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, targetNameParam, capabilityNameParam, body, nil) + respr, errRespr := c.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, targetNameParam, capabilityNameParam, 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)} + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Capability, req) if err != nil { @@ -146,28 +134,16 @@ func (c *CapabilitiesServerTransport) dispatchDelete(req *http.Request) (*http.R if c.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 7 { + if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } targetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("targetName")]) if err != nil { return nil, err @@ -176,7 +152,7 @@ func (c *CapabilitiesServerTransport) dispatchDelete(req *http.Request) (*http.R if err != nil { return nil, err } - respr, errRespr := c.srv.Delete(req.Context(), resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, targetNameParam, capabilityNameParam, nil) + respr, errRespr := c.srv.Delete(req.Context(), resourceGroupNameParam, targetNameParam, capabilityNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -195,28 +171,16 @@ func (c *CapabilitiesServerTransport) dispatchGet(req *http.Request) (*http.Resp if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 7 { + if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } targetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("targetName")]) if err != nil { return nil, err @@ -225,7 +189,7 @@ func (c *CapabilitiesServerTransport) dispatchGet(req *http.Request) (*http.Resp if err != nil { return nil, err } - respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, targetNameParam, capabilityNameParam, nil) + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, targetNameParam, capabilityNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -246,10 +210,10 @@ func (c *CapabilitiesServerTransport) dispatchNewListPager(req *http.Request) (* } newListPager := c.newListPager.get(req) if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilities` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { + if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -257,18 +221,6 @@ func (c *CapabilitiesServerTransport) dispatchNewListPager(req *http.Request) (* if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } targetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("targetName")]) if err != nil { return nil, err @@ -284,7 +236,7 @@ func (c *CapabilitiesServerTransport) dispatchNewListPager(req *http.Request) (* ContinuationToken: continuationTokenParam, } } - resp := c.srv.NewListPager(resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, targetNameParam, options) + resp := c.srv.NewListPager(resourceGroupNameParam, targetNameParam, options) newListPager = &resp c.newListPager.add(req, newListPager) server.PagerResponderInjectNextLinks(newListPager, req, func(page *armchaos.CapabilitiesClientListResponse, createLink func() string) { diff --git a/sdk/resourcemanager/chaos/armchaos/fake/capabilitytypes_server.go b/sdk/resourcemanager/chaos/armchaos/fake/capabilitytypes_server.go index 4ab582c9e43f..2545319f1a6f 100644 --- a/sdk/resourcemanager/chaos/armchaos/fake/capabilitytypes_server.go +++ b/sdk/resourcemanager/chaos/armchaos/fake/capabilitytypes_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "net/http" "net/url" "regexp" @@ -26,11 +26,11 @@ import ( type CapabilityTypesServer struct { // Get is the fake for method CapabilityTypesClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, locationName string, targetTypeName string, capabilityTypeName string, options *armchaos.CapabilityTypesClientGetOptions) (resp azfake.Responder[armchaos.CapabilityTypesClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, location string, targetTypeName string, capabilityTypeName string, options *armchaos.CapabilityTypesClientGetOptions) (resp azfake.Responder[armchaos.CapabilityTypesClientGetResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method CapabilityTypesClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(locationName string, targetTypeName string, options *armchaos.CapabilityTypesClientListOptions) (resp azfake.PagerResponder[armchaos.CapabilityTypesClientListResponse]) + NewListPager func(location string, targetTypeName string, options *armchaos.CapabilityTypesClientListOptions) (resp azfake.PagerResponder[armchaos.CapabilityTypesClientListResponse]) } // NewCapabilityTypesServerTransport creates a new instance of CapabilityTypesServerTransport with the provided implementation. @@ -81,13 +81,13 @@ func (c *CapabilityTypesServerTransport) dispatchGet(req *http.Request) (*http.R if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilityTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilityTypes/(?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) } - locationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationName")]) + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) if err != nil { return nil, err } @@ -99,7 +99,7 @@ func (c *CapabilityTypesServerTransport) dispatchGet(req *http.Request) (*http.R if err != nil { return nil, err } - respr, errRespr := c.srv.Get(req.Context(), locationNameParam, targetTypeNameParam, capabilityTypeNameParam, nil) + respr, errRespr := c.srv.Get(req.Context(), locationParam, targetTypeNameParam, capabilityTypeNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -120,14 +120,14 @@ func (c *CapabilityTypesServerTransport) dispatchNewListPager(req *http.Request) } newListPager := c.newListPager.get(req) if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilityTypes` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/capabilityTypes` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() - locationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationName")]) + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) if err != nil { return nil, err } @@ -146,7 +146,7 @@ func (c *CapabilityTypesServerTransport) dispatchNewListPager(req *http.Request) ContinuationToken: continuationTokenParam, } } - resp := c.srv.NewListPager(locationNameParam, targetTypeNameParam, options) + resp := c.srv.NewListPager(locationParam, targetTypeNameParam, options) newListPager = &resp c.newListPager.add(req, newListPager) server.PagerResponderInjectNextLinks(newListPager, req, func(page *armchaos.CapabilityTypesClientListResponse, createLink func() string) { diff --git a/sdk/resourcemanager/chaos/armchaos/fake/experimentexecutions_server.go b/sdk/resourcemanager/chaos/armchaos/fake/experimentexecutions_server.go new file mode 100644 index 000000000000..6f0b5ea421b7 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/fake/experimentexecutions_server.go @@ -0,0 +1,199 @@ +//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 ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" + "net/http" + "net/url" + "regexp" +) + +// ExperimentExecutionsServer is a fake server for instances of the armchaos.ExperimentExecutionsClient type. +type ExperimentExecutionsServer struct { + // Details is the fake for method ExperimentExecutionsClient.Details + // HTTP status codes to indicate success: http.StatusOK + Details func(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *armchaos.ExperimentExecutionsClientDetailsOptions) (resp azfake.Responder[armchaos.ExperimentExecutionsClientDetailsResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ExperimentExecutionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *armchaos.ExperimentExecutionsClientGetOptions) (resp azfake.Responder[armchaos.ExperimentExecutionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ExperimentExecutionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, experimentName string, options *armchaos.ExperimentExecutionsClientListOptions) (resp azfake.PagerResponder[armchaos.ExperimentExecutionsClientListResponse]) +} + +// NewExperimentExecutionsServerTransport creates a new instance of ExperimentExecutionsServerTransport with the provided implementation. +// The returned ExperimentExecutionsServerTransport instance is connected to an instance of armchaos.ExperimentExecutionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewExperimentExecutionsServerTransport(srv *ExperimentExecutionsServer) *ExperimentExecutionsServerTransport { + return &ExperimentExecutionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armchaos.ExperimentExecutionsClientListResponse]](), + } +} + +// ExperimentExecutionsServerTransport connects instances of armchaos.ExperimentExecutionsClient to instances of ExperimentExecutionsServer. +// Don't use this type directly, use NewExperimentExecutionsServerTransport instead. +type ExperimentExecutionsServerTransport struct { + srv *ExperimentExecutionsServer + newListPager *tracker[azfake.PagerResponder[armchaos.ExperimentExecutionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for ExperimentExecutionsServerTransport. +func (e *ExperimentExecutionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ExperimentExecutionsClient.Details": + resp, err = e.dispatchDetails(req) + case "ExperimentExecutionsClient.Get": + resp, err = e.dispatchGet(req) + case "ExperimentExecutionsClient.NewListPager": + resp, err = e.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *ExperimentExecutionsServerTransport) dispatchDetails(req *http.Request) (*http.Response, error) { + if e.srv.Details == nil { + return nil, &nonRetriableError{errors.New("fake for method Details not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/details` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) + if err != nil { + return nil, err + } + executionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionId")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Details(req.Context(), resourceGroupNameParam, experimentNameParam, executionIDParam, 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).ExperimentExecutionDetails, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *ExperimentExecutionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) + if err != nil { + return nil, err + } + executionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionId")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, experimentNameParam, executionIDParam, 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).ExperimentExecution, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *ExperimentExecutionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := e.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListPager(resourceGroupNameParam, experimentNameParam, nil) + newListPager = &resp + e.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armchaos.ExperimentExecutionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + e.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/chaos/armchaos/fake/experiments_server.go b/sdk/resourcemanager/chaos/armchaos/fake/experiments_server.go index 110967111c7d..a18fe93af1a5 100644 --- a/sdk/resourcemanager/chaos/armchaos/fake/experiments_server.go +++ b/sdk/resourcemanager/chaos/armchaos/fake/experiments_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "net/http" "net/url" "regexp" @@ -26,48 +26,36 @@ import ( // ExperimentsServer is a fake server for instances of the armchaos.ExperimentsClient type. type ExperimentsServer struct { // BeginCancel is the fake for method ExperimentsClient.BeginCancel - // HTTP status codes to indicate success: http.StatusAccepted - BeginCancel func(ctx context.Context, resourceGroupName string, experimentName string, options *armchaos.ExperimentsClientBeginCancelOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientCancelResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCancel func(ctx context.Context, options *armchaos.ExperimentsClientBeginCancelOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientCancelResponse], errResp azfake.ErrorResponder) // BeginCreateOrUpdate is the fake for method ExperimentsClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, experimentName string, experiment armchaos.Experiment, options *armchaos.ExperimentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, experimentName string, resource armchaos.Experiment, options *armchaos.ExperimentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method ExperimentsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusAccepted + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, experimentName string, options *armchaos.ExperimentsClientBeginDeleteOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientDeleteResponse], errResp azfake.ErrorResponder) - // ExecutionDetails is the fake for method ExperimentsClient.ExecutionDetails - // HTTP status codes to indicate success: http.StatusOK - ExecutionDetails func(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *armchaos.ExperimentsClientExecutionDetailsOptions) (resp azfake.Responder[armchaos.ExperimentsClientExecutionDetailsResponse], errResp azfake.ErrorResponder) - // Get is the fake for method ExperimentsClient.Get // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, experimentName string, options *armchaos.ExperimentsClientGetOptions) (resp azfake.Responder[armchaos.ExperimentsClientGetResponse], errResp azfake.ErrorResponder) - // GetExecution is the fake for method ExperimentsClient.GetExecution - // HTTP status codes to indicate success: http.StatusOK - GetExecution func(ctx context.Context, resourceGroupName string, experimentName string, executionID string, options *armchaos.ExperimentsClientGetExecutionOptions) (resp azfake.Responder[armchaos.ExperimentsClientGetExecutionResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method ExperimentsClient.NewListPager + // NewListByResourceGroupPager is the fake for method ExperimentsClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(resourceGroupName string, options *armchaos.ExperimentsClientListOptions) (resp azfake.PagerResponder[armchaos.ExperimentsClientListResponse]) + NewListByResourceGroupPager func(resourceGroupName string, options *armchaos.ExperimentsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armchaos.ExperimentsClientListByResourceGroupResponse]) - // NewListAllPager is the fake for method ExperimentsClient.NewListAllPager + // NewListBySubscriptionPager is the fake for method ExperimentsClient.NewListBySubscriptionPager // HTTP status codes to indicate success: http.StatusOK - NewListAllPager func(options *armchaos.ExperimentsClientListAllOptions) (resp azfake.PagerResponder[armchaos.ExperimentsClientListAllResponse]) - - // NewListAllExecutionsPager is the fake for method ExperimentsClient.NewListAllExecutionsPager - // HTTP status codes to indicate success: http.StatusOK - NewListAllExecutionsPager func(resourceGroupName string, experimentName string, options *armchaos.ExperimentsClientListAllExecutionsOptions) (resp azfake.PagerResponder[armchaos.ExperimentsClientListAllExecutionsResponse]) + NewListBySubscriptionPager func(options *armchaos.ExperimentsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armchaos.ExperimentsClientListBySubscriptionResponse]) // BeginStart is the fake for method ExperimentsClient.BeginStart - // HTTP status codes to indicate success: http.StatusAccepted - BeginStart func(ctx context.Context, resourceGroupName string, experimentName string, options *armchaos.ExperimentsClientBeginStartOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientStartResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginStart func(ctx context.Context, options *armchaos.ExperimentsClientBeginStartOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientStartResponse], errResp azfake.ErrorResponder) // BeginUpdate is the fake for method ExperimentsClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, experimentName string, experiment armchaos.ExperimentUpdate, options *armchaos.ExperimentsClientBeginUpdateOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, experimentName string, properties armchaos.ExperimentUpdate, options *armchaos.ExperimentsClientBeginUpdateOptions) (resp azfake.PollerResponder[armchaos.ExperimentsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewExperimentsServerTransport creates a new instance of ExperimentsServerTransport with the provided implementation. @@ -75,30 +63,28 @@ type ExperimentsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewExperimentsServerTransport(srv *ExperimentsServer) *ExperimentsServerTransport { return &ExperimentsServerTransport{ - srv: srv, - beginCancel: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientCancelResponse]](), - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientCreateOrUpdateResponse]](), - beginDelete: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientDeleteResponse]](), - newListPager: newTracker[azfake.PagerResponder[armchaos.ExperimentsClientListResponse]](), - newListAllPager: newTracker[azfake.PagerResponder[armchaos.ExperimentsClientListAllResponse]](), - newListAllExecutionsPager: newTracker[azfake.PagerResponder[armchaos.ExperimentsClientListAllExecutionsResponse]](), - beginStart: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientStartResponse]](), - beginUpdate: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientUpdateResponse]](), + srv: srv, + beginCancel: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientCancelResponse]](), + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armchaos.ExperimentsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armchaos.ExperimentsClientListBySubscriptionResponse]](), + beginStart: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientStartResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armchaos.ExperimentsClientUpdateResponse]](), } } // ExperimentsServerTransport connects instances of armchaos.ExperimentsClient to instances of ExperimentsServer. // Don't use this type directly, use NewExperimentsServerTransport instead. type ExperimentsServerTransport struct { - srv *ExperimentsServer - beginCancel *tracker[azfake.PollerResponder[armchaos.ExperimentsClientCancelResponse]] - beginCreateOrUpdate *tracker[azfake.PollerResponder[armchaos.ExperimentsClientCreateOrUpdateResponse]] - beginDelete *tracker[azfake.PollerResponder[armchaos.ExperimentsClientDeleteResponse]] - newListPager *tracker[azfake.PagerResponder[armchaos.ExperimentsClientListResponse]] - newListAllPager *tracker[azfake.PagerResponder[armchaos.ExperimentsClientListAllResponse]] - newListAllExecutionsPager *tracker[azfake.PagerResponder[armchaos.ExperimentsClientListAllExecutionsResponse]] - beginStart *tracker[azfake.PollerResponder[armchaos.ExperimentsClientStartResponse]] - beginUpdate *tracker[azfake.PollerResponder[armchaos.ExperimentsClientUpdateResponse]] + srv *ExperimentsServer + beginCancel *tracker[azfake.PollerResponder[armchaos.ExperimentsClientCancelResponse]] + beginCreateOrUpdate *tracker[azfake.PollerResponder[armchaos.ExperimentsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armchaos.ExperimentsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armchaos.ExperimentsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armchaos.ExperimentsClientListBySubscriptionResponse]] + beginStart *tracker[azfake.PollerResponder[armchaos.ExperimentsClientStartResponse]] + beginUpdate *tracker[azfake.PollerResponder[armchaos.ExperimentsClientUpdateResponse]] } // Do implements the policy.Transporter interface for ExperimentsServerTransport. @@ -119,18 +105,12 @@ func (e *ExperimentsServerTransport) Do(req *http.Request) (*http.Response, erro resp, err = e.dispatchBeginCreateOrUpdate(req) case "ExperimentsClient.BeginDelete": resp, err = e.dispatchBeginDelete(req) - case "ExperimentsClient.ExecutionDetails": - resp, err = e.dispatchExecutionDetails(req) case "ExperimentsClient.Get": resp, err = e.dispatchGet(req) - case "ExperimentsClient.GetExecution": - resp, err = e.dispatchGetExecution(req) - case "ExperimentsClient.NewListPager": - resp, err = e.dispatchNewListPager(req) - case "ExperimentsClient.NewListAllPager": - resp, err = e.dispatchNewListAllPager(req) - case "ExperimentsClient.NewListAllExecutionsPager": - resp, err = e.dispatchNewListAllExecutionsPager(req) + case "ExperimentsClient.NewListByResourceGroupPager": + resp, err = e.dispatchNewListByResourceGroupPager(req) + case "ExperimentsClient.NewListBySubscriptionPager": + resp, err = e.dispatchNewListBySubscriptionPager(req) case "ExperimentsClient.BeginStart": resp, err = e.dispatchBeginStart(req) case "ExperimentsClient.BeginUpdate": @@ -152,21 +132,7 @@ func (e *ExperimentsServerTransport) dispatchBeginCancel(req *http.Request) (*ht } beginCancel := e.beginCancel.get(req) if beginCancel == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.BeginCancel(req.Context(), resourceGroupNameParam, experimentNameParam, nil) + respr, errRespr := e.srv.BeginCancel(req.Context(), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -179,9 +145,9 @@ func (e *ExperimentsServerTransport) dispatchBeginCancel(req *http.Request) (*ht return nil, err } - if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { e.beginCancel.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginCancel) { e.beginCancel.remove(req) @@ -271,9 +237,9 @@ func (e *ExperimentsServerTransport) dispatchBeginDelete(req *http.Request) (*ht return nil, err } - if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { e.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { e.beginDelete.remove(req) @@ -282,43 +248,6 @@ func (e *ExperimentsServerTransport) dispatchBeginDelete(req *http.Request) (*ht return resp, nil } -func (e *ExperimentsServerTransport) dispatchExecutionDetails(req *http.Request) (*http.Response, error) { - if e.srv.ExecutionDetails == nil { - return nil, &nonRetriableError{errors.New("fake for method ExecutionDetails not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getExecutionDetails` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) - if err != nil { - return nil, err - } - executionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionId")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.ExecutionDetails(req.Context(), resourceGroupNameParam, experimentNameParam, executionIDParam, 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).ExperimentExecutionDetails, req) - if err != nil { - return nil, err - } - return resp, nil -} - func (e *ExperimentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if e.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} @@ -352,49 +281,12 @@ func (e *ExperimentsServerTransport) dispatchGet(req *http.Request) (*http.Respo return resp, nil } -func (e *ExperimentsServerTransport) dispatchGetExecution(req *http.Request) (*http.Response, error) { - if e.srv.GetExecution == nil { - return nil, &nonRetriableError{errors.New("fake for method GetExecution not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executions/(?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) +func (e *ExperimentsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) - if err != nil { - return nil, err - } - executionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionId")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.GetExecution(req.Context(), resourceGroupNameParam, experimentNameParam, executionIDParam, 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).ExperimentExecution, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExperimentsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := e.newListPager.get(req) - if newListPager == nil { + newListByResourceGroupPager := e.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) @@ -419,40 +311,40 @@ func (e *ExperimentsServerTransport) dispatchNewListPager(req *http.Request) (*h return nil, err } continuationTokenParam := getOptional(continuationTokenUnescaped) - var options *armchaos.ExperimentsClientListOptions + var options *armchaos.ExperimentsClientListByResourceGroupOptions if runningParam != nil || continuationTokenParam != nil { - options = &armchaos.ExperimentsClientListOptions{ + options = &armchaos.ExperimentsClientListByResourceGroupOptions{ Running: runningParam, ContinuationToken: continuationTokenParam, } } - resp := e.srv.NewListPager(resourceGroupNameParam, options) - newListPager = &resp - e.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armchaos.ExperimentsClientListResponse, createLink func() string) { + resp := e.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + newListByResourceGroupPager = &resp + e.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armchaos.ExperimentsClientListByResourceGroupResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListPager, req) + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListPager.remove(req) + e.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListPager) { - e.newListPager.remove(req) + if !server.PagerResponderMore(newListByResourceGroupPager) { + e.newListByResourceGroupPager.remove(req) } return resp, nil } -func (e *ExperimentsServerTransport) dispatchNewListAllPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListAllPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListAllPager not implemented")} +func (e *ExperimentsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} } - newListAllPager := e.newListAllPager.get(req) - if newListAllPager == nil { + newListBySubscriptionPager := e.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) @@ -473,71 +365,30 @@ func (e *ExperimentsServerTransport) dispatchNewListAllPager(req *http.Request) return nil, err } continuationTokenParam := getOptional(continuationTokenUnescaped) - var options *armchaos.ExperimentsClientListAllOptions + var options *armchaos.ExperimentsClientListBySubscriptionOptions if runningParam != nil || continuationTokenParam != nil { - options = &armchaos.ExperimentsClientListAllOptions{ + options = &armchaos.ExperimentsClientListBySubscriptionOptions{ Running: runningParam, ContinuationToken: continuationTokenParam, } } - resp := e.srv.NewListAllPager(options) - newListAllPager = &resp - e.newListAllPager.add(req, newListAllPager) - server.PagerResponderInjectNextLinks(newListAllPager, req, func(page *armchaos.ExperimentsClientListAllResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListAllPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListAllPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListAllPager) { - e.newListAllPager.remove(req) - } - return resp, nil -} - -func (e *ExperimentsServerTransport) dispatchNewListAllExecutionsPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListAllExecutionsPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListAllExecutionsPager not implemented")} - } - newListAllExecutionsPager := e.newListAllExecutionsPager.get(req) - if newListAllExecutionsPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) - if err != nil { - return nil, err - } - resp := e.srv.NewListAllExecutionsPager(resourceGroupNameParam, experimentNameParam, nil) - newListAllExecutionsPager = &resp - e.newListAllExecutionsPager.add(req, newListAllExecutionsPager) - server.PagerResponderInjectNextLinks(newListAllExecutionsPager, req, func(page *armchaos.ExperimentsClientListAllExecutionsResponse, createLink func() string) { + resp := e.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + e.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armchaos.ExperimentsClientListBySubscriptionResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListAllExecutionsPager, req) + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListAllExecutionsPager.remove(req) + e.newListBySubscriptionPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListAllExecutionsPager) { - e.newListAllExecutionsPager.remove(req) + if !server.PagerResponderMore(newListBySubscriptionPager) { + e.newListBySubscriptionPager.remove(req) } return resp, nil } @@ -548,21 +399,7 @@ func (e *ExperimentsServerTransport) dispatchBeginStart(req *http.Request) (*htt } beginStart := e.beginStart.get(req) if beginStart == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/experiments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/start` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - experimentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("experimentName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.BeginStart(req.Context(), resourceGroupNameParam, experimentNameParam, nil) + respr, errRespr := e.srv.BeginStart(req.Context(), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -575,9 +412,9 @@ func (e *ExperimentsServerTransport) dispatchBeginStart(req *http.Request) (*htt return nil, err } - if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { e.beginStart.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginStart) { e.beginStart.remove(req) @@ -623,9 +460,9 @@ func (e *ExperimentsServerTransport) dispatchBeginUpdate(req *http.Request) (*ht return nil, err } - if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { e.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { e.beginUpdate.remove(req) diff --git a/sdk/resourcemanager/chaos/armchaos/fake/operations_server.go b/sdk/resourcemanager/chaos/armchaos/fake/operations_server.go index fa65ac87d409..14f85f9b8d73 100644 --- a/sdk/resourcemanager/chaos/armchaos/fake/operations_server.go +++ b/sdk/resourcemanager/chaos/armchaos/fake/operations_server.go @@ -15,15 +15,15 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "net/http" ) // OperationsServer is a fake server for instances of the armchaos.OperationsClient type. type OperationsServer struct { - // NewListAllPager is the fake for method OperationsClient.NewListAllPager + // NewListPager is the fake for method OperationsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListAllPager func(options *armchaos.OperationsClientListAllOptions) (resp azfake.PagerResponder[armchaos.OperationsClientListAllResponse]) + NewListPager func(options *armchaos.OperationsClientListOptions) (resp azfake.PagerResponder[armchaos.OperationsClientListResponse]) } // NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. @@ -31,16 +31,16 @@ type OperationsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { return &OperationsServerTransport{ - srv: srv, - newListAllPager: newTracker[azfake.PagerResponder[armchaos.OperationsClientListAllResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armchaos.OperationsClientListResponse]](), } } // OperationsServerTransport connects instances of armchaos.OperationsClient to instances of OperationsServer. // Don't use this type directly, use NewOperationsServerTransport instead. type OperationsServerTransport struct { - srv *OperationsServer - newListAllPager *tracker[azfake.PagerResponder[armchaos.OperationsClientListAllResponse]] + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armchaos.OperationsClientListResponse]] } // Do implements the policy.Transporter interface for OperationsServerTransport. @@ -55,8 +55,8 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error var err error switch method { - case "OperationsClient.NewListAllPager": - resp, err = o.dispatchNewListAllPager(req) + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -68,29 +68,29 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return resp, nil } -func (o *OperationsServerTransport) dispatchNewListAllPager(req *http.Request) (*http.Response, error) { - if o.srv.NewListAllPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListAllPager not implemented")} +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")} } - newListAllPager := o.newListAllPager.get(req) - if newListAllPager == nil { - resp := o.srv.NewListAllPager(nil) - newListAllPager = &resp - o.newListAllPager.add(req, newListAllPager) - server.PagerResponderInjectNextLinks(newListAllPager, req, func(page *armchaos.OperationsClientListAllResponse, createLink func() string) { + 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 *armchaos.OperationsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListAllPager, req) + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - o.newListAllPager.remove(req) + o.newListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListAllPager) { - o.newListAllPager.remove(req) + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/chaos/armchaos/fake/operationstatuses_server.go b/sdk/resourcemanager/chaos/armchaos/fake/operationstatuses_server.go deleted file mode 100644 index 86d938265b0b..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/fake/operationstatuses_server.go +++ /dev/null @@ -1,100 +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 ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" - "net/http" - "net/url" - "regexp" -) - -// OperationStatusesServer is a fake server for instances of the armchaos.OperationStatusesClient type. -type OperationStatusesServer struct { - // Get is the fake for method OperationStatusesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, location string, asyncOperationID string, options *armchaos.OperationStatusesClientGetOptions) (resp azfake.Responder[armchaos.OperationStatusesClientGetResponse], errResp azfake.ErrorResponder) -} - -// NewOperationStatusesServerTransport creates a new instance of OperationStatusesServerTransport with the provided implementation. -// The returned OperationStatusesServerTransport instance is connected to an instance of armchaos.OperationStatusesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewOperationStatusesServerTransport(srv *OperationStatusesServer) *OperationStatusesServerTransport { - return &OperationStatusesServerTransport{srv: srv} -} - -// OperationStatusesServerTransport connects instances of armchaos.OperationStatusesClient to instances of OperationStatusesServer. -// Don't use this type directly, use NewOperationStatusesServerTransport instead. -type OperationStatusesServerTransport struct { - srv *OperationStatusesServer -} - -// Do implements the policy.Transporter interface for OperationStatusesServerTransport. -func (o *OperationStatusesServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "OperationStatusesClient.Get": - resp, err = o.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (o *OperationStatusesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if o.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationStatuses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) - if err != nil { - return nil, err - } - asyncOperationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("asyncOperationId")]) - if err != nil { - return nil, err - } - respr, errRespr := o.srv.Get(req.Context(), locationParam, asyncOperationIDParam, 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).OperationStatus, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/sdk/resourcemanager/chaos/armchaos/fake/server_factory.go b/sdk/resourcemanager/chaos/armchaos/fake/server_factory.go index b2c30adf1bb3..af761e4106cc 100644 --- a/sdk/resourcemanager/chaos/armchaos/fake/server_factory.go +++ b/sdk/resourcemanager/chaos/armchaos/fake/server_factory.go @@ -19,13 +19,13 @@ import ( // ServerFactory is a fake server for instances of the armchaos.ClientFactory type. type ServerFactory struct { - CapabilitiesServer CapabilitiesServer - CapabilityTypesServer CapabilityTypesServer - ExperimentsServer ExperimentsServer - OperationStatusesServer OperationStatusesServer - OperationsServer OperationsServer - TargetTypesServer TargetTypesServer - TargetsServer TargetsServer + CapabilitiesServer CapabilitiesServer + CapabilityTypesServer CapabilityTypesServer + ExperimentExecutionsServer ExperimentExecutionsServer + ExperimentsServer ExperimentsServer + OperationsServer OperationsServer + TargetTypesServer TargetTypesServer + TargetsServer TargetsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -40,15 +40,15 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armchaos.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trCapabilitiesServer *CapabilitiesServerTransport - trCapabilityTypesServer *CapabilityTypesServerTransport - trExperimentsServer *ExperimentsServerTransport - trOperationStatusesServer *OperationStatusesServerTransport - trOperationsServer *OperationsServerTransport - trTargetTypesServer *TargetTypesServerTransport - trTargetsServer *TargetsServerTransport + srv *ServerFactory + trMu sync.Mutex + trCapabilitiesServer *CapabilitiesServerTransport + trCapabilityTypesServer *CapabilityTypesServerTransport + trExperimentExecutionsServer *ExperimentExecutionsServerTransport + trExperimentsServer *ExperimentsServerTransport + trOperationsServer *OperationsServerTransport + trTargetTypesServer *TargetTypesServerTransport + trTargetsServer *TargetsServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -72,14 +72,14 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewCapabilityTypesServerTransport(&s.srv.CapabilityTypesServer) }) resp, err = s.trCapabilityTypesServer.Do(req) + case "ExperimentExecutionsClient": + initServer(s, &s.trExperimentExecutionsServer, func() *ExperimentExecutionsServerTransport { + return NewExperimentExecutionsServerTransport(&s.srv.ExperimentExecutionsServer) + }) + resp, err = s.trExperimentExecutionsServer.Do(req) case "ExperimentsClient": initServer(s, &s.trExperimentsServer, func() *ExperimentsServerTransport { return NewExperimentsServerTransport(&s.srv.ExperimentsServer) }) resp, err = s.trExperimentsServer.Do(req) - case "OperationStatusesClient": - initServer(s, &s.trOperationStatusesServer, func() *OperationStatusesServerTransport { - return NewOperationStatusesServerTransport(&s.srv.OperationStatusesServer) - }) - resp, err = s.trOperationStatusesServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) diff --git a/sdk/resourcemanager/chaos/armchaos/fake/targets_server.go b/sdk/resourcemanager/chaos/armchaos/fake/targets_server.go index d2045d013f23..1797cf2428d6 100644 --- a/sdk/resourcemanager/chaos/armchaos/fake/targets_server.go +++ b/sdk/resourcemanager/chaos/armchaos/fake/targets_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "net/http" "net/url" "regexp" @@ -25,20 +25,20 @@ import ( // TargetsServer is a fake server for instances of the armchaos.TargetsClient type. type TargetsServer struct { // CreateOrUpdate is the fake for method TargetsClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK - CreateOrUpdate func(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, target armchaos.Target, options *armchaos.TargetsClientCreateOrUpdateOptions) (resp azfake.Responder[armchaos.TargetsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, targetName string, resource armchaos.Target, options *armchaos.TargetsClientCreateOrUpdateOptions) (resp azfake.Responder[armchaos.TargetsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method TargetsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *armchaos.TargetsClientDeleteOptions) (resp azfake.Responder[armchaos.TargetsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, targetName string, options *armchaos.TargetsClientDeleteOptions) (resp azfake.Responder[armchaos.TargetsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method TargetsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *armchaos.TargetsClientGetOptions) (resp azfake.Responder[armchaos.TargetsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, targetName string, options *armchaos.TargetsClientGetOptions) (resp azfake.Responder[armchaos.TargetsClientGetResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method TargetsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, options *armchaos.TargetsClientListOptions) (resp azfake.PagerResponder[armchaos.TargetsClientListResponse]) + NewListPager func(resourceGroupName string, options *armchaos.TargetsClientListOptions) (resp azfake.PagerResponder[armchaos.TargetsClientListResponse]) } // NewTargetsServerTransport creates a new instance of TargetsServerTransport with the provided implementation. @@ -93,10 +93,10 @@ func (t *TargetsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*htt if t.srv.CreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { + if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armchaos.Target](req) @@ -107,29 +107,17 @@ func (t *TargetsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*htt if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } targetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("targetName")]) if err != nil { return nil, err } - respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, targetNameParam, body, nil) + respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, targetNameParam, 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)} + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Target, req) if err != nil { @@ -142,33 +130,21 @@ func (t *TargetsServerTransport) dispatchDelete(req *http.Request) (*http.Respon if t.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { + if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } targetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("targetName")]) if err != nil { return nil, err } - respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, targetNameParam, nil) + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, targetNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -187,33 +163,21 @@ func (t *TargetsServerTransport) dispatchGet(req *http.Request) (*http.Response, if t.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { + if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } targetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("targetName")]) if err != nil { return nil, err } - respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, targetNameParam, nil) + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, targetNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -234,10 +198,10 @@ func (t *TargetsServerTransport) dispatchNewListPager(req *http.Request) (*http. } newListPager := t.newListPager.get(req) if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/targets` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 5 { + if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -245,18 +209,6 @@ func (t *TargetsServerTransport) dispatchNewListPager(req *http.Request) (*http. if err != nil { return nil, err } - parentProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceType")]) - if err != nil { - return nil, err - } - parentResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourceName")]) - if err != nil { - return nil, err - } continuationTokenUnescaped, err := url.QueryUnescape(qp.Get("continuationToken")) if err != nil { return nil, err @@ -268,7 +220,7 @@ func (t *TargetsServerTransport) dispatchNewListPager(req *http.Request) (*http. ContinuationToken: continuationTokenParam, } } - resp := t.srv.NewListPager(resourceGroupNameParam, parentProviderNamespaceParam, parentResourceTypeParam, parentResourceNameParam, options) + resp := t.srv.NewListPager(resourceGroupNameParam, options) newListPager = &resp t.newListPager.add(req, newListPager) server.PagerResponderInjectNextLinks(newListPager, req, func(page *armchaos.TargetsClientListResponse, createLink func() string) { diff --git a/sdk/resourcemanager/chaos/armchaos/fake/targettypes_server.go b/sdk/resourcemanager/chaos/armchaos/fake/targettypes_server.go index d3a7428a0477..234264479b79 100644 --- a/sdk/resourcemanager/chaos/armchaos/fake/targettypes_server.go +++ b/sdk/resourcemanager/chaos/armchaos/fake/targettypes_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "net/http" "net/url" "regexp" @@ -26,11 +26,11 @@ import ( type TargetTypesServer struct { // Get is the fake for method TargetTypesClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, locationName string, targetTypeName string, options *armchaos.TargetTypesClientGetOptions) (resp azfake.Responder[armchaos.TargetTypesClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, location string, targetTypeName string, options *armchaos.TargetTypesClientGetOptions) (resp azfake.Responder[armchaos.TargetTypesClientGetResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method TargetTypesClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(locationName string, options *armchaos.TargetTypesClientListOptions) (resp azfake.PagerResponder[armchaos.TargetTypesClientListResponse]) + NewListPager func(location string, options *armchaos.TargetTypesClientListOptions) (resp azfake.PagerResponder[armchaos.TargetTypesClientListResponse]) } // NewTargetTypesServerTransport creates a new instance of TargetTypesServerTransport with the provided implementation. @@ -81,13 +81,13 @@ func (t *TargetTypesServerTransport) dispatchGet(req *http.Request) (*http.Respo if t.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - locationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationName")]) + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) if err != nil { return nil, err } @@ -95,7 +95,7 @@ func (t *TargetTypesServerTransport) dispatchGet(req *http.Request) (*http.Respo if err != nil { return nil, err } - respr, errRespr := t.srv.Get(req.Context(), locationNameParam, targetTypeNameParam, nil) + respr, errRespr := t.srv.Get(req.Context(), locationParam, targetTypeNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -116,14 +116,14 @@ func (t *TargetTypesServerTransport) dispatchNewListPager(req *http.Request) (*h } newListPager := t.newListPager.get(req) if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Chaos/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/targetTypes` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() - locationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationName")]) + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) if err != nil { return nil, err } @@ -138,7 +138,7 @@ func (t *TargetTypesServerTransport) dispatchNewListPager(req *http.Request) (*h ContinuationToken: continuationTokenParam, } } - resp := t.srv.NewListPager(locationNameParam, options) + resp := t.srv.NewListPager(locationParam, options) newListPager = &resp t.newListPager.add(req, newListPager) server.PagerResponderInjectNextLinks(newListPager, req, func(page *armchaos.TargetTypesClientListResponse, createLink func() string) { diff --git a/sdk/resourcemanager/chaos/armchaos/go.mod b/sdk/resourcemanager/chaos/armchaos/go.mod index c83da6aaf694..6eb6561a6a46 100644 --- a/sdk/resourcemanager/chaos/armchaos/go.mod +++ b/sdk/resourcemanager/chaos/armchaos/go.mod @@ -1,10 +1,9 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2 go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 @@ -12,6 +11,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect diff --git a/sdk/resourcemanager/chaos/armchaos/models.go b/sdk/resourcemanager/chaos/armchaos/models.go index 20da634461d9..7c6333b23fac 100644 --- a/sdk/resourcemanager/chaos/armchaos/models.go +++ b/sdk/resourcemanager/chaos/armchaos/models.go @@ -48,16 +48,16 @@ type BranchStatus struct { // Capability - Model that represents a Capability resource. type Capability struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // The properties of a capability resource. + Properties *CapabilityProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The properties of a capability resource. - Properties *CapabilityProperties - - // READ-ONLY; The standard system metadata of a resource type. + // 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" @@ -66,11 +66,11 @@ type Capability struct { // CapabilityListResult - Model that represents a list of Capability resources and a link for pagination. type CapabilityListResult struct { - // READ-ONLY; URL to retrieve the next page of Capability resources. - NextLink *string - - // READ-ONLY; List of Capability resources. + // REQUIRED; The Capability items on this page Value []*Capability + + // The link to the next page of items + NextLink *string } // CapabilityProperties - Model that represents the Capability properties model. @@ -81,6 +81,9 @@ type CapabilityProperties struct { // READ-ONLY; URL to retrieve JSON schema of the Capability parameters. ParametersSchema *string + // READ-ONLY; Capability resource provisioning state. Not currently implemented. + ProvisioningState *ProvisioningState + // READ-ONLY; String of the Publisher that this Capability extends. Publisher *string @@ -93,19 +96,16 @@ type CapabilityProperties struct { // CapabilityType - Model that represents a Capability Type resource. type CapabilityType struct { - // Location of the Capability Type resource. - Location *string + // The properties of the capability type resource. + Properties *CapabilityTypeProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The properties of the capability type resource. - Properties *CapabilityTypeProperties - - // READ-ONLY; The system metadata properties of the capability type 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" @@ -114,24 +114,21 @@ type CapabilityType struct { // CapabilityTypeListResult - Model that represents a list of Capability Type resources and a link for pagination. type CapabilityTypeListResult struct { - // READ-ONLY; URL to retrieve the next page of Capability Type resources. - NextLink *string - - // READ-ONLY; List of Capability Type resources. + // REQUIRED; The CapabilityType items on this page Value []*CapabilityType + + // The link to the next page of items + NextLink *string } // CapabilityTypeProperties - Model that represents the Capability Type properties model. type CapabilityTypeProperties struct { - // Control plane actions necessary to execute capability type. + // READ-ONLY; Control plane actions necessary to execute capability type. AzureRbacActions []*string - // Data plane actions necessary to execute capability type. + // READ-ONLY; Data plane actions necessary to execute capability type. AzureRbacDataActions []*string - // Runtime properties of this Capability Type. - RuntimeProperties *CapabilityTypePropertiesRuntimeProperties - // READ-ONLY; Localized string of the description. Description *string @@ -144,9 +141,15 @@ type CapabilityTypeProperties struct { // READ-ONLY; URL to retrieve JSON schema of the Capability Type parameters. ParametersSchema *string + // READ-ONLY; Capability type resource provisioning state. Not currently implemented. + ProvisioningState *ProvisioningState + // READ-ONLY; String of the Publisher that this Capability Type extends. Publisher *string + // READ-ONLY; Runtime properties of this Capability Type. + RuntimeProperties *CapabilityTypePropertiesRuntimeProperties + // READ-ONLY; String of the Target Type that this Capability Type extends. TargetType *string @@ -160,6 +163,14 @@ type CapabilityTypePropertiesRuntimeProperties struct { Kind *string } +type ComponentsQjfoe3SchemasManagedserviceidentityupdatePropertiesUserassignedidentitiesAdditionalproperties struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string +} + // ContinuousAction - Model that represents a continuous action. type ContinuousAction struct { // REQUIRED; ISO8601 formatted string that represents a duration. @@ -174,8 +185,8 @@ type ContinuousAction struct { // REQUIRED; String that represents a selector. SelectorID *string - // REQUIRED; Enum that discriminates between action models. - Type *string + // REQUIRED; Chaos experiment action discriminator type + Type *ExperimentActionType } // GetExperimentAction implements the ExperimentActionClassification interface for type ContinuousAction. @@ -194,8 +205,8 @@ type DelayAction struct { // REQUIRED; String that represents a Capability URN. Name *string - // REQUIRED; Enum that discriminates between action models. - Type *string + // REQUIRED; Chaos experiment action discriminator type + Type *ExperimentActionType } // GetExperimentAction implements the ExperimentActionClassification interface for type DelayAction. @@ -217,8 +228,8 @@ type DiscreteAction struct { // REQUIRED; String that represents a selector. SelectorID *string - // REQUIRED; Enum that discriminates between action models. - Type *string + // REQUIRED; Chaos experiment action discriminator type + Type *ExperimentActionType } // GetExperimentAction implements the ExperimentActionClassification interface for type DiscreteAction. @@ -271,19 +282,19 @@ type Experiment struct { // REQUIRED; The properties of the experiment resource. Properties *ExperimentProperties - // The identity of the experiment resource. - Identity *ResourceIdentity + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata of the experiment 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" @@ -295,8 +306,8 @@ type ExperimentAction struct { // REQUIRED; String that represents a Capability URN. Name *string - // REQUIRED; Enum that discriminates between action models. - Type *string + // REQUIRED; Chaos experiment action discriminator type + Type *ExperimentActionType } // GetExperimentAction implements the ExperimentActionClassification interface for type ExperimentAction. @@ -311,18 +322,21 @@ type ExperimentBranch struct { Name *string } -// ExperimentExecution - Model that represents the execution of a Experiment. +// ExperimentExecution - Model that represents the execution of an Experiment. type ExperimentExecution struct { // The properties of experiment execution status. Properties *ExperimentExecutionProperties - // READ-ONLY; String of the fully qualified resource ID. + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; String of the resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; String of the resource type. + // 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 } @@ -377,6 +391,9 @@ type ExperimentExecutionDetailsProperties struct { // READ-ONLY; String that represents the last action date time. LastActionAt *time.Time + // READ-ONLY; Experiment execution resource provisioning state. Not currently implemented. + ProvisioningState *ProvisioningState + // READ-ONLY; The information of the experiment run. RunInformation *ExperimentExecutionDetailsPropertiesRunInformation @@ -398,15 +415,18 @@ type ExperimentExecutionDetailsPropertiesRunInformation struct { // ExperimentExecutionListResult - Model that represents a list of Experiment executions and a link for pagination. type ExperimentExecutionListResult struct { - // READ-ONLY; URL to retrieve the next page of Experiment executions. - NextLink *string - - // READ-ONLY; List of Experiment executions. + // REQUIRED; The ExperimentExecution items on this page Value []*ExperimentExecution + + // The link to the next page of items + NextLink *string } // ExperimentExecutionProperties - Model that represents the execution properties of an Experiment. type ExperimentExecutionProperties struct { + // READ-ONLY; Experiment execution resource provisioning state. Not currently implemented. + ProvisioningState *ProvisioningState + // READ-ONLY; String that represents the start date time. StartedAt *time.Time @@ -419,11 +439,11 @@ type ExperimentExecutionProperties struct { // ExperimentListResult - Model that represents a list of Experiment resources and a link for pagination. type ExperimentListResult struct { - // READ-ONLY; URL to retrieve the next page of Experiment resources. - NextLink *string - - // READ-ONLY; List of Experiment resources. + // REQUIRED; The Experiment items on this page Value []*Experiment + + // The link to the next page of items + NextLink *string } // ExperimentProperties - Model that represents the Experiment properties model. @@ -449,10 +469,10 @@ type ExperimentStep struct { // ExperimentUpdate - Describes an experiment update. type ExperimentUpdate struct { - // The identity of the experiment resource. - Identity *ResourceIdentity + // Updatable managed service identity + Identity *ManagedServiceIdentityUpdate - // The tags of the experiment resource. + // Resource tags. Tags map[string]*string } @@ -465,6 +485,35 @@ type KeyValuePair struct { Value *string } +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + +// ManagedServiceIdentityUpdate - The template for adding optional properties. +type ManagedServiceIdentityUpdate struct { + // The type of managed identity assigned to this resource. + Type *ManagedServiceIdentityType + + // The identities assigned to this resource by the user. + UserAssignedIdentities map[string]*ComponentsQjfoe3SchemasManagedserviceidentityupdatePropertiesUserassignedidentitiesAdditionalproperties +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -514,56 +563,46 @@ type OperationListResult struct { Value []*Operation } -// OperationStatus - The status of operation. -type OperationStatus struct { - // The end time of the operation. - EndTime *string +// PostActionResponse - Model that represents the post action response. +type PostActionResponse struct { + // READ-ONLY; The name of the resource. + Name *string - // The error object. - Error *ErrorDetail + // READ-ONLY; The statusUrl of the post action. + StatusURL *string +} - // The operation Id. +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // The operation name. + // READ-ONLY; The name of the resource Name *string - // The start time of the operation. - StartTime *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // The status of the operation. - Status *string + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // 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 } -// ResourceIdentity - The identity of a resource. -type ResourceIdentity struct { - // REQUIRED; String of the resource identity type. - Type *ResourceIdentityType - - // The list of user identities associated with the Experiment. The user identity dictionary key references will be ARM resource - // ids in the form: - // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - UserAssignedIdentities map[string]*UserAssignedIdentity - - // READ-ONLY; GUID that represents the principal ID of this resource identity. - PrincipalID *string - - // READ-ONLY; GUID that represents the tenant ID of this resource identity. - TenantID *string -} - // StepStatus - Model that represents the a list of branches and branch statuses. type StepStatus struct { // READ-ONLY; The array of branches. @@ -602,19 +641,16 @@ type SystemData struct { // Target - Model that represents a Target resource. type Target struct { - // REQUIRED; The properties of the target resource. + // The properties of the target resource. Properties map[string]any - // Location of the target resource. - Location *string - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata of the target 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" @@ -623,7 +659,7 @@ type Target struct { // TargetFilter - Model that represents available filter types that can be applied to a targets list. type TargetFilter struct { - // REQUIRED; Enum that discriminates between filter types. Currently only Simple type is supported. + // REQUIRED; Chaos target filter discriminator type Type *FilterType } @@ -632,11 +668,11 @@ func (t *TargetFilter) GetTargetFilter() *TargetFilter { return t } // TargetListResult - Model that represents a list of Target resources and a link for pagination. type TargetListResult struct { - // READ-ONLY; URL to retrieve the next page of Target resources. - NextLink *string - - // READ-ONLY; List of Target resources. + // REQUIRED; The Target items on this page Value []*Target + + // The link to the next page of items + NextLink *string } // TargetListSelector - Model that represents a list selector. @@ -647,7 +683,7 @@ type TargetListSelector struct { // REQUIRED; List of Target references. Targets []*TargetReference - // REQUIRED; Enum of the selector type. + // REQUIRED; Chaos target selector discriminator type Type *SelectorType // OPTIONAL; Contains additional key/value pairs not defined in the schema. @@ -678,7 +714,7 @@ type TargetQuerySelector struct { // REQUIRED; Subscription id list to scope resource query. SubscriptionIDs []*string - // REQUIRED; Enum of the selector type. + // REQUIRED; Chaos target selector discriminator type Type *SelectorType // OPTIONAL; Contains additional key/value pairs not defined in the schema. @@ -712,7 +748,7 @@ type TargetSelector struct { // REQUIRED; String of the selector ID. ID *string - // REQUIRED; Enum of the selector type. + // REQUIRED; Chaos target selector discriminator type Type *SelectorType // OPTIONAL; Contains additional key/value pairs not defined in the schema. @@ -727,7 +763,7 @@ func (t *TargetSelector) GetTargetSelector() *TargetSelector { return t } // TargetSimpleFilter - Model that represents a simple target filter. type TargetSimpleFilter struct { - // REQUIRED; Enum that discriminates between filter types. Currently only Simple type is supported. + // REQUIRED; Chaos target filter discriminator type Type *FilterType // Model that represents the Simple filter parameters. @@ -752,16 +788,13 @@ type TargetType struct { // REQUIRED; The properties of the target type resource. Properties *TargetTypeProperties - // Location of the Target Type resource. - Location *string - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system metadata properties of the target type 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" @@ -770,11 +803,11 @@ type TargetType struct { // TargetTypeListResult - Model that represents a list of Target Type resources and a link for pagination. type TargetTypeListResult struct { - // READ-ONLY; URL to retrieve the next page of Target Type resources. - NextLink *string - - // READ-ONLY; List of Target Type resources. + // REQUIRED; The TargetType items on this page Value []*TargetType + + // The link to the next page of items + NextLink *string } // TargetTypeProperties - Model that represents the base Target Type properties model. @@ -788,6 +821,9 @@ type TargetTypeProperties struct { // READ-ONLY; URL to retrieve JSON schema of the Target Type properties. PropertiesSchema *string + // READ-ONLY; Target type resource provisioning state. Not currently implemented. + ProvisioningState *ProvisioningState + // READ-ONLY; List of resource types this Target Type can extend. ResourceTypes []*string } @@ -801,12 +837,15 @@ type TrackedResource struct { // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // 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/chaos/armchaos/models_serde.go b/sdk/resourcemanager/chaos/armchaos/models_serde.go index 81388afb9ed1..a2fc5dd62da1 100644 --- a/sdk/resourcemanager/chaos/armchaos/models_serde.go +++ b/sdk/resourcemanager/chaos/armchaos/models_serde.go @@ -180,6 +180,7 @@ func (c CapabilityProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", c.Description) populate(objectMap, "parametersSchema", c.ParametersSchema) + populate(objectMap, "provisioningState", c.ProvisioningState) populate(objectMap, "publisher", c.Publisher) populate(objectMap, "targetType", c.TargetType) populate(objectMap, "urn", c.Urn) @@ -201,6 +202,9 @@ func (c *CapabilityProperties) UnmarshalJSON(data []byte) error { case "parametersSchema": err = unpopulate(val, "ParametersSchema", &c.ParametersSchema) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) case "publisher": err = unpopulate(val, "Publisher", &c.Publisher) delete(rawMsg, key) @@ -222,7 +226,6 @@ func (c *CapabilityProperties) UnmarshalJSON(data []byte) error { func (c CapabilityType) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", c.ID) - populate(objectMap, "location", c.Location) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) populate(objectMap, "systemData", c.SystemData) @@ -242,9 +245,6 @@ func (c *CapabilityType) UnmarshalJSON(data []byte) error { case "id": err = unpopulate(val, "ID", &c.ID) delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &c.Location) - delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &c.Name) delete(rawMsg, key) @@ -305,6 +305,7 @@ func (c CapabilityTypeProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "displayName", c.DisplayName) populate(objectMap, "kind", c.Kind) populate(objectMap, "parametersSchema", c.ParametersSchema) + populate(objectMap, "provisioningState", c.ProvisioningState) populate(objectMap, "publisher", c.Publisher) populate(objectMap, "runtimeProperties", c.RuntimeProperties) populate(objectMap, "targetType", c.TargetType) @@ -339,6 +340,9 @@ func (c *CapabilityTypeProperties) UnmarshalJSON(data []byte) error { case "parametersSchema": err = unpopulate(val, "ParametersSchema", &c.ParametersSchema) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) case "publisher": err = unpopulate(val, "Publisher", &c.Publisher) delete(rawMsg, key) @@ -386,6 +390,37 @@ func (c *CapabilityTypePropertiesRuntimeProperties) UnmarshalJSON(data []byte) e return nil } +// MarshalJSON implements the json.Marshaller interface for type ComponentsQjfoe3SchemasManagedserviceidentityupdatePropertiesUserassignedidentitiesAdditionalproperties. +func (c ComponentsQjfoe3SchemasManagedserviceidentityupdatePropertiesUserassignedidentitiesAdditionalproperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", c.ClientID) + populate(objectMap, "principalId", c.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentsQjfoe3SchemasManagedserviceidentityupdatePropertiesUserassignedidentitiesAdditionalproperties. +func (c *ComponentsQjfoe3SchemasManagedserviceidentityupdatePropertiesUserassignedidentitiesAdditionalproperties) 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 "clientId": + err = unpopulate(val, "ClientID", &c.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &c.PrincipalID) + 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 ContinuousAction. func (c ContinuousAction) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -393,7 +428,7 @@ func (c ContinuousAction) MarshalJSON() ([]byte, error) { populate(objectMap, "name", c.Name) populate(objectMap, "parameters", c.Parameters) populate(objectMap, "selectorId", c.SelectorID) - objectMap["type"] = "continuous" + objectMap["type"] = ExperimentActionTypeContinuous return json.Marshal(objectMap) } @@ -434,7 +469,7 @@ func (d DelayAction) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "duration", d.Duration) populate(objectMap, "name", d.Name) - objectMap["type"] = "delay" + objectMap["type"] = ExperimentActionTypeDelay return json.Marshal(objectMap) } @@ -470,7 +505,7 @@ func (d DiscreteAction) MarshalJSON() ([]byte, error) { populate(objectMap, "name", d.Name) populate(objectMap, "parameters", d.Parameters) populate(objectMap, "selectorId", d.SelectorID) - objectMap["type"] = "discrete" + objectMap["type"] = ExperimentActionTypeDiscrete return json.Marshal(objectMap) } @@ -727,6 +762,7 @@ func (e ExperimentExecution) MarshalJSON() ([]byte, error) { populate(objectMap, "id", e.ID) populate(objectMap, "name", e.Name) populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } @@ -749,6 +785,9 @@ func (e *ExperimentExecution) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &e.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) @@ -878,6 +917,7 @@ func (e ExperimentExecutionDetailsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "failureReason", e.FailureReason) populateDateTimeRFC3339(objectMap, "lastActionAt", e.LastActionAt) + populate(objectMap, "provisioningState", e.ProvisioningState) populate(objectMap, "runInformation", e.RunInformation) populateDateTimeRFC3339(objectMap, "startedAt", e.StartedAt) populate(objectMap, "status", e.Status) @@ -900,6 +940,9 @@ func (e *ExperimentExecutionDetailsProperties) UnmarshalJSON(data []byte) error case "lastActionAt": err = unpopulateDateTimeRFC3339(val, "LastActionAt", &e.LastActionAt) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) case "runInformation": err = unpopulate(val, "RunInformation", &e.RunInformation) delete(rawMsg, key) @@ -981,6 +1024,7 @@ func (e *ExperimentExecutionListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionProperties. func (e ExperimentExecutionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "provisioningState", e.ProvisioningState) populateDateTimeRFC3339(objectMap, "startedAt", e.StartedAt) populate(objectMap, "status", e.Status) populateDateTimeRFC3339(objectMap, "stoppedAt", e.StoppedAt) @@ -996,6 +1040,9 @@ func (e *ExperimentExecutionProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) case "startedAt": err = unpopulateDateTimeRFC3339(val, "StartedAt", &e.StartedAt) delete(rawMsg, key) @@ -1172,6 +1219,76 @@ func (k *KeyValuePair) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentityUpdate. +func (m ManagedServiceIdentityUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentityUpdate. +func (m *ManagedServiceIdentityUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1285,100 +1402,88 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationStatus. -func (o OperationStatus) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PostActionResponse. +func (p PostActionResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "endTime", o.EndTime) - populate(objectMap, "error", o.Error) - populate(objectMap, "id", o.ID) - populate(objectMap, "name", o.Name) - populate(objectMap, "startTime", o.StartTime) - populate(objectMap, "status", o.Status) + populate(objectMap, "name", p.Name) + populate(objectMap, "statusUrl", p.StatusURL) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatus. -func (o *OperationStatus) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PostActionResponse. +func (p *PostActionResponse) 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) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "endTime": - err = unpopulate(val, "EndTime", &o.EndTime) - delete(rawMsg, key) - case "error": - err = unpopulate(val, "Error", &o.Error) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &o.ID) - delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "startTime": - err = unpopulate(val, "StartTime", &o.StartTime) + err = unpopulate(val, "Name", &p.Name) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &o.Status) + case "statusUrl": + err = unpopulate(val, "StatusURL", &p.StatusURL) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { case "id": - err = unpopulate(val, "ID", &r.ID) + err = unpopulate(val, "ID", &p.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &r.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", &r.Type) + err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceIdentity. -func (r ResourceIdentity) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "principalId", r.PrincipalID) - populate(objectMap, "tenantId", r.TenantID) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) populate(objectMap, "type", r.Type) - populate(objectMap, "userAssignedIdentities", r.UserAssignedIdentities) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceIdentity. -func (r *ResourceIdentity) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -1386,18 +1491,18 @@ func (r *ResourceIdentity) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "principalId": - err = unpopulate(val, "PrincipalID", &r.PrincipalID) + case "id": + err = unpopulate(val, "ID", &r.ID) delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &r.TenantID) + 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) - case "userAssignedIdentities": - err = unpopulate(val, "UserAssignedIdentities", &r.UserAssignedIdentities) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -1496,7 +1601,6 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { func (t Target) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) populate(objectMap, "properties", t.Properties) populate(objectMap, "systemData", t.SystemData) @@ -1516,9 +1620,6 @@ func (t *Target) UnmarshalJSON(data []byte) error { case "id": err = unpopulate(val, "ID", &t.ID) delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) delete(rawMsg, key) @@ -1852,7 +1953,6 @@ func (t *TargetSimpleFilterParameters) UnmarshalJSON(data []byte) error { func (t TargetType) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) populate(objectMap, "properties", t.Properties) populate(objectMap, "systemData", t.SystemData) @@ -1872,9 +1972,6 @@ func (t *TargetType) UnmarshalJSON(data []byte) error { case "id": err = unpopulate(val, "ID", &t.ID) delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) delete(rawMsg, key) @@ -1932,6 +2029,7 @@ func (t TargetTypeProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "description", t.Description) populate(objectMap, "displayName", t.DisplayName) populate(objectMap, "propertiesSchema", t.PropertiesSchema) + populate(objectMap, "provisioningState", t.ProvisioningState) populate(objectMap, "resourceTypes", t.ResourceTypes) return json.Marshal(objectMap) } @@ -1954,6 +2052,9 @@ func (t *TargetTypeProperties) UnmarshalJSON(data []byte) error { case "propertiesSchema": err = unpopulate(val, "PropertiesSchema", &t.PropertiesSchema) delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) + delete(rawMsg, key) case "resourceTypes": err = unpopulate(val, "ResourceTypes", &t.ResourceTypes) delete(rawMsg, key) @@ -1971,6 +2072,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) @@ -1994,6 +2096,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) diff --git a/sdk/resourcemanager/chaos/armchaos/operations_client.go b/sdk/resourcemanager/chaos/armchaos/operations_client.go index 09f52bccdddc..017c4485266f 100644 --- a/sdk/resourcemanager/chaos/armchaos/operations_client.go +++ b/sdk/resourcemanager/chaos/armchaos/operations_client.go @@ -37,52 +37,52 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListAllPager - Get a list all available Operations. +// NewListPager - List the operations for the provider // -// Generated from API version 2024-01-01 -// - options - OperationsClientListAllOptions contains the optional parameters for the OperationsClient.NewListAllPager method. -func (client *OperationsClient) NewListAllPager(options *OperationsClientListAllOptions) *runtime.Pager[OperationsClientListAllResponse] { - return runtime.NewPager(runtime.PagingHandler[OperationsClientListAllResponse]{ - More: func(page OperationsClientListAllResponse) bool { +// Generated from API version 2025-01-01 +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *OperationsClientListAllResponse) (OperationsClientListAllResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListAllPager") + 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.listAllCreateRequest(ctx, options) + return client.listCreateRequest(ctx, options) }, nil) if err != nil { - return OperationsClientListAllResponse{}, err + return OperationsClientListResponse{}, err } - return client.listAllHandleResponse(resp) + return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listAllCreateRequest creates the ListAll request. -func (client *OperationsClient) listAllCreateRequest(ctx context.Context, options *OperationsClientListAllOptions) (*policy.Request, error) { +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Chaos/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listAllHandleResponse handles the ListAll response. -func (client *OperationsClient) listAllHandleResponse(resp *http.Response) (OperationsClientListAllResponse, error) { - result := OperationsClientListAllResponse{} +// 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 OperationsClientListAllResponse{}, err + return OperationsClientListResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/chaos/armchaos/operations_live_test.go b/sdk/resourcemanager/chaos/armchaos/operations_live_test.go index bfdd647bf766..cc9420d59ea5 100644 --- a/sdk/resourcemanager/chaos/armchaos/operations_live_test.go +++ b/sdk/resourcemanager/chaos/armchaos/operations_live_test.go @@ -14,7 +14,7 @@ import ( "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/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/chaos/armchaos/operationstatuses_client.go b/sdk/resourcemanager/chaos/armchaos/operationstatuses_client.go deleted file mode 100644 index f5e384736644..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/operationstatuses_client.go +++ /dev/null @@ -1,108 +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 armchaos - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// OperationStatusesClient contains the methods for the OperationStatuses group. -// Don't use this type directly, use NewOperationStatusesClient() instead. -type OperationStatusesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewOperationStatusesClient creates a new instance of OperationStatusesClient with the specified values. -// - subscriptionID - GUID that represents an Azure subscription ID. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusesClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &OperationStatusesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// Get - Get the status of a long running azure asynchronous operation. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2024-01-01 -// - location - The name of the Azure region. -// - asyncOperationID - The operation Id. -// - options - OperationStatusesClientGetOptions contains the optional parameters for the OperationStatusesClient.Get method. -func (client *OperationStatusesClient) Get(ctx context.Context, location string, asyncOperationID string, options *OperationStatusesClientGetOptions) (OperationStatusesClientGetResponse, error) { - var err error - const operationName = "OperationStatusesClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, location, asyncOperationID, options) - if err != nil { - return OperationStatusesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationStatusesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return OperationStatusesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *OperationStatusesClient) getCreateRequest(ctx context.Context, location string, asyncOperationID string, options *OperationStatusesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/operationStatuses/{asyncOperationId}" - if location == "" { - return nil, errors.New("parameter location cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - if asyncOperationID == "" { - return nil, errors.New("parameter asyncOperationID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{asyncOperationId}", url.PathEscape(asyncOperationID)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *OperationStatusesClient) getHandleResponse(resp *http.Response) (OperationStatusesClientGetResponse, error) { - result := OperationStatusesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { - return OperationStatusesClientGetResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/chaos/armchaos/operationstatuses_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/operationstatuses_client_example_test.go deleted file mode 100644 index e72b29a01520..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/operationstatuses_client_example_test.go +++ /dev/null @@ -1,45 +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 armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetOperationStatus.json -func ExampleOperationStatusesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOperationStatusesClient().Get(ctx, "West US", "713192d7-503f-477a-9cfe-4efc3ee2bd11", 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.OperationStatus = armchaos.OperationStatus{ - // Name: to.Ptr("713192d7-503f-477a-9cfe-4efc3ee2bd11"), - // EndTime: to.Ptr("2017-01-01T16:13:13.933Z"), - // ID: to.Ptr("/subscriptions/613192d7-503f-477a-9cfe-4efc3ee2bd60/locations/westus/operationStatuses/713192d7-503f-477a-9cfe-4efc3ee2bd11"), - // StartTime: to.Ptr("2017-01-01T13:13:13.933Z"), - // Status: to.Ptr("Succeeded"), - // } -} diff --git a/sdk/resourcemanager/chaos/armchaos/options.go b/sdk/resourcemanager/chaos/armchaos/options.go index 088c8b736b47..6f24f79d2462 100644 --- a/sdk/resourcemanager/chaos/armchaos/options.go +++ b/sdk/resourcemanager/chaos/armchaos/options.go @@ -40,6 +40,22 @@ type CapabilityTypesClientListOptions struct { ContinuationToken *string } +// ExperimentExecutionsClientDetailsOptions contains the optional parameters for the ExperimentExecutionsClient.Details method. +type ExperimentExecutionsClientDetailsOptions struct { + // placeholder for future optional parameters +} + +// ExperimentExecutionsClientGetOptions contains the optional parameters for the ExperimentExecutionsClient.Get method. +type ExperimentExecutionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ExperimentExecutionsClientListOptions contains the optional parameters for the ExperimentExecutionsClient.NewListPager +// method. +type ExperimentExecutionsClientListOptions struct { + // placeholder for future optional parameters +} + // ExperimentsClientBeginCancelOptions contains the optional parameters for the ExperimentsClient.BeginCancel method. type ExperimentsClientBeginCancelOptions struct { // Resumes the LRO from the provided token. @@ -71,29 +87,14 @@ type ExperimentsClientBeginUpdateOptions struct { ResumeToken string } -// ExperimentsClientExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.ExecutionDetails method. -type ExperimentsClientExecutionDetailsOptions struct { - // placeholder for future optional parameters -} - -// ExperimentsClientGetExecutionOptions contains the optional parameters for the ExperimentsClient.GetExecution method. -type ExperimentsClientGetExecutionOptions struct { - // placeholder for future optional parameters -} - // ExperimentsClientGetOptions contains the optional parameters for the ExperimentsClient.Get method. type ExperimentsClientGetOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListAllExecutionsOptions contains the optional parameters for the ExperimentsClient.NewListAllExecutionsPager +// ExperimentsClientListByResourceGroupOptions contains the optional parameters for the ExperimentsClient.NewListByResourceGroupPager // method. -type ExperimentsClientListAllExecutionsOptions struct { - // placeholder for future optional parameters -} - -// ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.NewListAllPager method. -type ExperimentsClientListAllOptions struct { +type ExperimentsClientListByResourceGroupOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -102,8 +103,9 @@ type ExperimentsClientListAllOptions struct { Running *bool } -// ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.NewListPager method. -type ExperimentsClientListOptions struct { +// ExperimentsClientListBySubscriptionOptions contains the optional parameters for the ExperimentsClient.NewListBySubscriptionPager +// method. +type ExperimentsClientListBySubscriptionOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -112,13 +114,8 @@ type ExperimentsClientListOptions struct { Running *bool } -// OperationStatusesClientGetOptions contains the optional parameters for the OperationStatusesClient.Get method. -type OperationStatusesClientGetOptions struct { - // placeholder for future optional parameters -} - -// OperationsClientListAllOptions contains the optional parameters for the OperationsClient.NewListAllPager method. -type OperationsClientListAllOptions struct { +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go b/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go index ebf835864e47..17d79a248482 100644 --- a/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go +++ b/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go @@ -20,11 +20,11 @@ func unmarshalExperimentActionClassification(rawMsg json.RawMessage) (Experiment } var b ExperimentActionClassification switch m["type"] { - case "continuous": + case string(ExperimentActionTypeContinuous): b = &ContinuousAction{} - case "delay": + case string(ExperimentActionTypeDelay): b = &DelayAction{} - case "discrete": + case string(ExperimentActionTypeDiscrete): b = &DiscreteAction{} default: b = &ExperimentAction{} diff --git a/sdk/resourcemanager/chaos/armchaos/responses.go b/sdk/resourcemanager/chaos/armchaos/responses.go index 7f27a717922c..8fbce17d0b4f 100644 --- a/sdk/resourcemanager/chaos/armchaos/responses.go +++ b/sdk/resourcemanager/chaos/armchaos/responses.go @@ -43,9 +43,28 @@ type CapabilityTypesClientListResponse struct { CapabilityTypeListResult } +// ExperimentExecutionsClientDetailsResponse contains the response from method ExperimentExecutionsClient.Details. +type ExperimentExecutionsClientDetailsResponse struct { + // Model that represents the execution details of an Experiment. + ExperimentExecutionDetails +} + +// ExperimentExecutionsClientGetResponse contains the response from method ExperimentExecutionsClient.Get. +type ExperimentExecutionsClientGetResponse struct { + // Model that represents the execution of an Experiment. + ExperimentExecution +} + +// ExperimentExecutionsClientListResponse contains the response from method ExperimentExecutionsClient.NewListPager. +type ExperimentExecutionsClientListResponse struct { + // Model that represents a list of Experiment executions and a link for pagination. + ExperimentExecutionListResult +} + // ExperimentsClientCancelResponse contains the response from method ExperimentsClient.BeginCancel. type ExperimentsClientCancelResponse struct { - // placeholder for future response values + // Model that represents the post action response. + PostActionResponse } // ExperimentsClientCreateOrUpdateResponse contains the response from method ExperimentsClient.BeginCreateOrUpdate. @@ -59,45 +78,28 @@ type ExperimentsClientDeleteResponse struct { // placeholder for future response values } -// ExperimentsClientExecutionDetailsResponse contains the response from method ExperimentsClient.ExecutionDetails. -type ExperimentsClientExecutionDetailsResponse struct { - // Model that represents the execution details of an Experiment. - ExperimentExecutionDetails -} - -// ExperimentsClientGetExecutionResponse contains the response from method ExperimentsClient.GetExecution. -type ExperimentsClientGetExecutionResponse struct { - // Model that represents the execution of a Experiment. - ExperimentExecution -} - // ExperimentsClientGetResponse contains the response from method ExperimentsClient.Get. type ExperimentsClientGetResponse struct { // Model that represents a Experiment resource. Experiment } -// ExperimentsClientListAllExecutionsResponse contains the response from method ExperimentsClient.NewListAllExecutionsPager. -type ExperimentsClientListAllExecutionsResponse struct { - // Model that represents a list of Experiment executions and a link for pagination. - ExperimentExecutionListResult -} - -// ExperimentsClientListAllResponse contains the response from method ExperimentsClient.NewListAllPager. -type ExperimentsClientListAllResponse struct { +// ExperimentsClientListByResourceGroupResponse contains the response from method ExperimentsClient.NewListByResourceGroupPager. +type ExperimentsClientListByResourceGroupResponse struct { // Model that represents a list of Experiment resources and a link for pagination. ExperimentListResult } -// ExperimentsClientListResponse contains the response from method ExperimentsClient.NewListPager. -type ExperimentsClientListResponse struct { +// ExperimentsClientListBySubscriptionResponse contains the response from method ExperimentsClient.NewListBySubscriptionPager. +type ExperimentsClientListBySubscriptionResponse struct { // Model that represents a list of Experiment resources and a link for pagination. ExperimentListResult } // ExperimentsClientStartResponse contains the response from method ExperimentsClient.BeginStart. type ExperimentsClientStartResponse struct { - // placeholder for future response values + // Model that represents the post action response. + PostActionResponse } // ExperimentsClientUpdateResponse contains the response from method ExperimentsClient.BeginUpdate. @@ -106,14 +108,8 @@ type ExperimentsClientUpdateResponse struct { Experiment } -// OperationStatusesClientGetResponse contains the response from method OperationStatusesClient.Get. -type OperationStatusesClientGetResponse struct { - // The status of operation. - OperationStatus -} - -// OperationsClientListAllResponse contains the response from method OperationsClient.NewListAllPager. -type OperationsClientListAllResponse struct { +// 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 } diff --git a/sdk/resourcemanager/chaos/armchaos/targets_client.go b/sdk/resourcemanager/chaos/armchaos/targets_client.go index 9254b1b2c863..20fc407f0ae5 100644 --- a/sdk/resourcemanager/chaos/armchaos/targets_client.go +++ b/sdk/resourcemanager/chaos/armchaos/targets_client.go @@ -28,7 +28,7 @@ type TargetsClient struct { } // NewTargetsClient creates a new instance of TargetsClient with the specified values. -// - subscriptionID - GUID that represents an Azure subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewTargetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TargetsClient, error) { @@ -46,21 +46,18 @@ func NewTargetsClient(subscriptionID string, credential azcore.TokenCredential, // CreateOrUpdate - Create or update a Target resource that extends a tracked regional resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - targetName - String that represents a Target resource name. -// - target - Target resource to be created or updated. +// - resource - Target resource to be created or updated. // - options - TargetsClientCreateOrUpdateOptions contains the optional parameters for the TargetsClient.CreateOrUpdate method. -func (client *TargetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, target Target, options *TargetsClientCreateOrUpdateOptions) (TargetsClientCreateOrUpdateResponse, error) { +func (client *TargetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, targetName string, resource Target, options *TargetsClientCreateOrUpdateOptions) (TargetsClientCreateOrUpdateResponse, error) { var err error const operationName = "TargetsClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, target, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, targetName, resource, options) if err != nil { return TargetsClientCreateOrUpdateResponse{}, err } @@ -68,7 +65,7 @@ func (client *TargetsClient) CreateOrUpdate(ctx context.Context, resourceGroupNa if err != nil { return TargetsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return TargetsClientCreateOrUpdateResponse{}, err } @@ -77,8 +74,8 @@ func (client *TargetsClient) CreateOrUpdate(ctx context.Context, resourceGroupNa } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *TargetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, target Target, options *TargetsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" +func (client *TargetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, targetName string, resource Target, options *TargetsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets/{targetName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -87,18 +84,6 @@ func (client *TargetsClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) if targetName == "" { return nil, errors.New("parameter targetName cannot be empty") } @@ -108,10 +93,10 @@ func (client *TargetsClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, target); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -129,20 +114,17 @@ func (client *TargetsClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Delete a Target resource that extends a tracked regional resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - targetName - String that represents a Target resource name. // - options - TargetsClientDeleteOptions contains the optional parameters for the TargetsClient.Delete method. -func (client *TargetsClient) Delete(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsClientDeleteOptions) (TargetsClientDeleteResponse, error) { +func (client *TargetsClient) Delete(ctx context.Context, resourceGroupName string, targetName string, options *TargetsClientDeleteOptions) (TargetsClientDeleteResponse, error) { var err error const operationName = "TargetsClient.Delete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, targetName, options) if err != nil { return TargetsClientDeleteResponse{}, err } @@ -158,8 +140,8 @@ func (client *TargetsClient) Delete(ctx context.Context, resourceGroupName strin } // deleteCreateRequest creates the Delete request. -func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" +func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, targetName string, options *TargetsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets/{targetName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -168,18 +150,6 @@ func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) if targetName == "" { return nil, errors.New("parameter targetName cannot be empty") } @@ -189,7 +159,7 @@ func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -198,20 +168,17 @@ func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Get a Target resource that extends a tracked regional resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - targetName - String that represents a Target resource name. // - options - TargetsClientGetOptions contains the optional parameters for the TargetsClient.Get method. -func (client *TargetsClient) Get(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsClientGetOptions) (TargetsClientGetResponse, error) { +func (client *TargetsClient) Get(ctx context.Context, resourceGroupName string, targetName string, options *TargetsClientGetOptions) (TargetsClientGetResponse, error) { var err error const operationName = "TargetsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, targetName, options) if err != nil { return TargetsClientGetResponse{}, err } @@ -228,8 +195,8 @@ func (client *TargetsClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *TargetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, targetName string, options *TargetsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}" +func (client *TargetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, targetName string, options *TargetsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets/{targetName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -238,18 +205,6 @@ func (client *TargetsClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) if targetName == "" { return nil, errors.New("parameter targetName cannot be empty") } @@ -259,7 +214,7 @@ func (client *TargetsClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -276,13 +231,10 @@ func (client *TargetsClient) getHandleResponse(resp *http.Response) (TargetsClie // NewListPager - Get a list of Target resources that extend a tracked regional resource. // -// Generated from API version 2024-01-01 -// - resourceGroupName - String that represents an Azure resource group. -// - parentProviderNamespace - String that represents a resource provider namespace. -// - parentResourceType - String that represents a resource type. -// - parentResourceName - String that represents a resource name. +// Generated from API version 2025-01-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - TargetsClientListOptions contains the optional parameters for the TargetsClient.NewListPager method. -func (client *TargetsClient) NewListPager(resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, options *TargetsClientListOptions) *runtime.Pager[TargetsClientListResponse] { +func (client *TargetsClient) NewListPager(resourceGroupName string, options *TargetsClientListOptions) *runtime.Pager[TargetsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TargetsClientListResponse]{ More: func(page TargetsClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -294,7 +246,7 @@ func (client *TargetsClient) NewListPager(resourceGroupName string, parentProvid nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, options) + return client.listCreateRequest(ctx, resourceGroupName, options) }, nil) if err != nil { return TargetsClientListResponse{}, err @@ -306,8 +258,8 @@ func (client *TargetsClient) NewListPager(resourceGroupName string, parentProvid } // listCreateRequest creates the List request. -func (client *TargetsClient) listCreateRequest(ctx context.Context, resourceGroupName string, parentProviderNamespace string, parentResourceType string, parentResourceName string, options *TargetsClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets" +func (client *TargetsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *TargetsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/targets" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -316,24 +268,12 @@ func (client *TargetsClient) listCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if parentProviderNamespace == "" { - return nil, errors.New("parameter parentProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentProviderNamespace}", url.PathEscape(parentProviderNamespace)) - if parentResourceType == "" { - return nil, errors.New("parameter parentResourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceType}", url.PathEscape(parentResourceType)) - if parentResourceName == "" { - return nil, errors.New("parameter parentResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{parentResourceName}", url.PathEscape(parentResourceName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/targets_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/targets_client_example_test.go deleted file mode 100644 index 3e8729e5b735..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/targets_client_example_test.go +++ /dev/null @@ -1,169 +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 armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListTargets.json -func ExampleTargetsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTargetsClient().NewListPager("exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", &armchaos.TargetsClientListOptions{ContinuationToken: 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.TargetListResult = armchaos.TargetListResult{ - // Value: []*armchaos.Target{ - // { - // Name: to.Ptr("Microsoft-Agent"), - // Type: to.Ptr("Microsoft.Chaos/targets"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-Agent"), - // Location: to.Ptr("centraluseuap"), - // Properties: map[string]any{ - // "agentProfileId": "ac4e8251-fdc9-4277-8e87-dc57fe5794cf", - // "identities": []any{ - // map[string]any{ - // "type": "CertificateSubjectIssuer", - // "subject": "CN=example.subject", - // }, - // }, - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetTarget.json -func ExampleTargetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTargetsClient().Get(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent", 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.Target = armchaos.Target{ - // Name: to.Ptr("Microsoft-Agent"), - // Type: to.Ptr("Microsoft.Chaos/targets"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-Agent"), - // Location: to.Ptr("centraluseuap"), - // Properties: map[string]any{ - // "agentProfileId": "ac4e8251-fdc9-4277-8e87-dc57fe5794cf", - // "identities": []any{ - // map[string]any{ - // "type": "CertificateSubjectIssuer", - // "subject": "CN=example.subject", - // }, - // }, - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/DeleteTarget.json -func ExampleTargetsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTargetsClient().Delete(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent", 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/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateTarget.json -func ExampleTargetsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTargetsClient().CreateOrUpdate(ctx, "exampleRG", "Microsoft.Compute", "virtualMachines", "exampleVM", "Microsoft-Agent", armchaos.Target{ - Properties: map[string]any{ - "identities": []any{ - map[string]any{ - "type": "CertificateSubjectIssuer", - "subject": "CN=example.subject", - }, - }, - }, - }, 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.Target = armchaos.Target{ - // Name: to.Ptr("Microsoft-Agent"), - // Type: to.Ptr("Microsoft.Chaos/targets"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-Agent"), - // Location: to.Ptr("centraluseuap"), - // Properties: map[string]any{ - // "agentProfileId": "ac4e8251-fdc9-4277-8e87-dc57fe5794cf", - // "identities": []any{ - // map[string]any{ - // "type": "CertificateSubjectIssuer", - // "subject": "CN=example.subject", - // }, - // }, - // }, - // SystemData: &armchaos.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T00:00:00.000Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/chaos/armchaos/targets_live_test.go b/sdk/resourcemanager/chaos/armchaos/targets_live_test.go index cf78e4a3a1a6..3d17da23c2d4 100644 --- a/sdk/resourcemanager/chaos/armchaos/targets_live_test.go +++ b/sdk/resourcemanager/chaos/armchaos/targets_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" diff --git a/sdk/resourcemanager/chaos/armchaos/targettypes_client.go b/sdk/resourcemanager/chaos/armchaos/targettypes_client.go index c84ab3f33eb4..91d3cbea62f2 100644 --- a/sdk/resourcemanager/chaos/armchaos/targettypes_client.go +++ b/sdk/resourcemanager/chaos/armchaos/targettypes_client.go @@ -28,7 +28,7 @@ type TargetTypesClient struct { } // NewTargetTypesClient creates a new instance of TargetTypesClient with the specified values. -// - subscriptionID - GUID that represents an Azure subscription ID. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewTargetTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TargetTypesClient, error) { @@ -46,17 +46,17 @@ func NewTargetTypesClient(subscriptionID string, credential azcore.TokenCredenti // Get - Get a Target Type resources for given location. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-01-01 -// - locationName - String that represents a Location resource name. +// Generated from API version 2025-01-01 +// - location - The name of the Azure region. // - targetTypeName - String that represents a Target Type resource name. // - options - TargetTypesClientGetOptions contains the optional parameters for the TargetTypesClient.Get method. -func (client *TargetTypesClient) Get(ctx context.Context, locationName string, targetTypeName string, options *TargetTypesClientGetOptions) (TargetTypesClientGetResponse, error) { +func (client *TargetTypesClient) Get(ctx context.Context, location string, targetTypeName string, options *TargetTypesClientGetOptions) (TargetTypesClientGetResponse, error) { var err error const operationName = "TargetTypesClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, locationName, targetTypeName, options) + req, err := client.getCreateRequest(ctx, location, targetTypeName, options) if err != nil { return TargetTypesClientGetResponse{}, err } @@ -73,16 +73,16 @@ func (client *TargetTypesClient) Get(ctx context.Context, locationName string, t } // getCreateRequest creates the Get request. -func (client *TargetTypesClient) getCreateRequest(ctx context.Context, locationName string, targetTypeName string, options *TargetTypesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}" +func (client *TargetTypesClient) getCreateRequest(ctx context.Context, location string, targetTypeName string, options *TargetTypesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes/{targetTypeName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if locationName == "" { - return nil, errors.New("parameter locationName cannot be empty") + if location == "" { + return nil, errors.New("parameter location cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) if targetTypeName == "" { return nil, errors.New("parameter targetTypeName cannot be empty") } @@ -92,7 +92,7 @@ func (client *TargetTypesClient) getCreateRequest(ctx context.Context, locationN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -109,10 +109,10 @@ func (client *TargetTypesClient) getHandleResponse(resp *http.Response) (TargetT // NewListPager - Get a list of Target Type resources for given location. // -// Generated from API version 2024-01-01 -// - locationName - String that represents a Location resource name. +// Generated from API version 2025-01-01 +// - location - The name of the Azure region. // - options - TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.NewListPager method. -func (client *TargetTypesClient) NewListPager(locationName string, options *TargetTypesClientListOptions) *runtime.Pager[TargetTypesClientListResponse] { +func (client *TargetTypesClient) NewListPager(location string, options *TargetTypesClientListOptions) *runtime.Pager[TargetTypesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TargetTypesClientListResponse]{ More: func(page TargetTypesClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -124,7 +124,7 @@ func (client *TargetTypesClient) NewListPager(locationName string, options *Targ nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, locationName, options) + return client.listCreateRequest(ctx, location, options) }, nil) if err != nil { return TargetTypesClientListResponse{}, err @@ -136,22 +136,22 @@ func (client *TargetTypesClient) NewListPager(locationName string, options *Targ } // listCreateRequest creates the List request. -func (client *TargetTypesClient) listCreateRequest(ctx context.Context, locationName string, options *TargetTypesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes" +func (client *TargetTypesClient) listCreateRequest(ctx context.Context, location string, options *TargetTypesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/targetTypes" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if locationName == "" { - return nil, errors.New("parameter locationName cannot be empty") + if location == "" { + return nil, errors.New("parameter location cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-01-01") + reqQP.Set("api-version", "2025-01-01") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/targettypes_client_example_test.go b/sdk/resourcemanager/chaos/armchaos/targettypes_client_example_test.go deleted file mode 100644 index c26ec4669bc6..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/targettypes_client_example_test.go +++ /dev/null @@ -1,94 +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 armchaos_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListTargetTypes.json -func ExampleTargetTypesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTargetTypesClient().NewListPager("westus2", &armchaos.TargetTypesClientListOptions{ContinuationToken: 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.TargetTypeListResult = armchaos.TargetTypeListResult{ - // Value: []*armchaos.TargetType{ - // { - // Name: to.Ptr("Microsoft-Agent"), - // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/providers/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-Agent"), - // Location: to.Ptr("centraluseuap"), - // Properties: &armchaos.TargetTypeProperties{ - // Description: to.Ptr("A target represents Chaos Agent."), - // DisplayName: to.Ptr("Chaos Agent"), - // PropertiesSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine.json"), - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.Compute/virtualMachines"), - // to.Ptr("Microsoft.Compute/virtualMachineScaleSets")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e4009d2f8d3bf0271757e522c7d1c1997e193d44/specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetTargetType.json -func ExampleTargetTypesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchaos.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTargetTypesClient().Get(ctx, "westus2", "Microsoft-Agent", 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.TargetType = armchaos.TargetType{ - // Name: to.Ptr("Microsoft-Agent"), - // Type: to.Ptr("Microsoft.Chaos/locations/targetTypes"), - // ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/providers/Microsoft.Chaos/locations/westus2/targetTypes/Microsoft-Agent"), - // Location: to.Ptr("centraluseuap"), - // Properties: &armchaos.TargetTypeProperties{ - // Description: to.Ptr("A target represents Chaos Agent."), - // DisplayName: to.Ptr("Chaos Agent"), - // PropertiesSchema: to.Ptr("https://schema.centralus.chaos-prod.azure.com/targets/Microsoft-VirtualMachine.json"), - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.Compute/virtualMachines"), - // to.Ptr("Microsoft.Compute/virtualMachineScaleSets")}, - // }, - // } -} diff --git a/sdk/resourcemanager/chaos/armchaos/targettypes_live_test.go b/sdk/resourcemanager/chaos/armchaos/targettypes_live_test.go index 494f73e36464..74d58009e393 100644 --- a/sdk/resourcemanager/chaos/armchaos/targettypes_live_test.go +++ b/sdk/resourcemanager/chaos/armchaos/targettypes_live_test.go @@ -14,7 +14,7 @@ import ( "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/internal/recording" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" "github.com/stretchr/testify/suite" )