From c9349a2660098879c35a9b115dc427d24009f276 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 18 Mar 2023 02:07:33 +0000 Subject: [PATCH] CodeGen from PR 23171 in Azure/azure-rest-api-specs Merge 37ec657b0a0f20c8403690a4254a73f907a4f640 into 72664c83300dfaf6782e22822a5aae0b0df92735 --- .../chaos/armchaos/CHANGELOG.md | 24 + .../chaos/armchaos/autorest.md | 6 +- ...ities_client.go => capabilities_client.go} | 86 +- ...es_client.go => capabilitytypes_client.go} | 33 +- ...zz_generated_constants.go => constants.go} | 19 +- ...iments_client.go => experiments_client.go} | 268 ++- sdk/resourcemanager/chaos/armchaos/go.mod | 14 +- sdk/resourcemanager/chaos/armchaos/go.sum | 24 +- .../{zz_generated_models.go => models.go} | 124 +- .../chaos/armchaos/models_serde.go | 1980 +++++++++++++++++ ...rations_client.go => operations_client.go} | 13 +- ...phic_helpers.go => polymorphic_helpers.go} | 21 +- ...ed_response_types.go => response_types.go} | 24 +- ...ed_targets_client.go => targets_client.go} | 76 +- ...ttypes_client.go => targettypes_client.go} | 28 +- ...erated_time_rfc3339.go => time_rfc3339.go} | 3 +- ...erated_example_capabilities_client_test.go | 125 -- ...ted_example_capabilitytypes_client_test.go | 66 - ...nerated_example_experiments_client_test.go | 312 --- ...e_generated_example_targets_client_test.go | 128 -- ...nerated_example_targettypes_client_test.go | 64 - .../armchaos/zz_generated_models_serde.go | 438 ---- 22 files changed, 2454 insertions(+), 1422 deletions(-) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_capabilities_client.go => capabilities_client.go} (84%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_capabilitytypes_client.go => capabilitytypes_client.go} (87%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_constants.go => constants.go} (85%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_experiments_client.go => experiments_client.go} (76%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_models.go => models.go} (87%) create mode 100644 sdk/resourcemanager/chaos/armchaos/models_serde.go rename sdk/resourcemanager/chaos/armchaos/{zz_generated_operations_client.go => operations_client.go} (89%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_polymorphic_helpers.go => polymorphic_helpers.go} (75%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_response_types.go => response_types.go} (88%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_targets_client.go => targets_client.go} (85%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_targettypes_client.go => targettypes_client.go} (88%) rename sdk/resourcemanager/chaos/armchaos/{zz_generated_time_rfc3339.go => time_rfc3339.go} (96%) delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go delete mode 100644 sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go diff --git a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md index f64cb2f70f6a..50bbcc982c21 100644 --- a/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md +++ b/sdk/resourcemanager/chaos/armchaos/CHANGELOG.md @@ -1,5 +1,29 @@ # Release History +## 0.6.0 (2023-03-18) +### Breaking Changes + +- Operation `*ExperimentsClient.BeginCancel` has been changed to non-LRO, use `*ExperimentsClient.Cancel` instead. +- Operation `*ExperimentsClient.BeginCreateOrUpdate` has been changed to non-LRO, use `*ExperimentsClient.CreateOrUpdate` instead. + +### Features Added + +- New value `ResourceIdentityTypeUserAssigned` added to type alias `ResourceIdentityType` +- New type alias `FilterType` with values `FilterTypeSimple` +- New function `*ExperimentsClient.Update(context.Context, string, string, ExperimentUpdate, *ExperimentsClientUpdateOptions) (ExperimentsClientUpdateResponse, error)` +- New function `*Filter.GetFilter() *Filter` +- New function `*SimpleFilter.GetFilter() *Filter` +- New struct `CapabilityTypePropertiesRuntimeProperties` +- New struct `ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties` +- New struct `ExperimentUpdate` +- New struct `SimpleFilter` +- New struct `SimpleFilterParameters` +- New field `Kind` in struct `CapabilityTypeProperties` +- New field `RuntimeProperties` in struct `CapabilityTypeProperties` +- New field `UserAssignedIdentities` in struct `ResourceIdentity` +- New field `Filter` in struct `Selector` + + ## 0.5.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.5.0, which contains breaking changes. diff --git a/sdk/resourcemanager/chaos/armchaos/autorest.md b/sdk/resourcemanager/chaos/armchaos/autorest.md index 3e4d42f635dd..11fbe4e27f16 100644 --- a/sdk/resourcemanager/chaos/armchaos/autorest.md +++ b/sdk/resourcemanager/chaos/armchaos/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/chaos/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/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: 0.5.0 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go b/sdk/resourcemanager/chaos/armchaos/capabilities_client.go similarity index 84% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go rename to sdk/resourcemanager/chaos/armchaos/capabilities_client.go index c6fc29372416..5ca018a29b5e 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilities_client.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilities_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -31,9 +32,9 @@ type CapabilitiesClient struct { } // NewCapabilitiesClient creates a new instance of CapabilitiesClient 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. +// - 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 NewCapabilitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CapabilitiesClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -56,16 +57,17 @@ 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 2021-09-15-preview -// 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. -// targetName - String that represents a Target resource name. -// capabilityName - String that represents a Capability resource name. -// capability - Capability resource to be created or updated. -// options - CapabilitiesClientCreateOrUpdateOptions contains the optional parameters for the CapabilitiesClient.CreateOrUpdate -// method. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - targetName - String that represents a Target resource name. +// - capabilityName - String that represents a Capability resource name. +// - capability - 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) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, capability, options) if err != nil { @@ -117,7 +119,7 @@ func (client *CapabilitiesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, capability) @@ -134,14 +136,15 @@ 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 2021-09-15-preview -// 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. -// 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. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - 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) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) if err != nil { @@ -193,7 +196,7 @@ func (client *CapabilitiesClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -201,14 +204,15 @@ 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 2021-09-15-preview -// 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. -// 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. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - 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) { req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, capabilityName, options) if err != nil { @@ -260,7 +264,7 @@ func (client *CapabilitiesClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -276,14 +280,14 @@ func (client *CapabilitiesClient) getHandleResponse(resp *http.Response) (Capabi } // NewListPager - Get a list of Capability resources that extend a Target resource.. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// 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. -// targetName - String that represents a Target resource name. -// options - CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.List method. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - 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] { return runtime.NewPager(runtime.PagingHandler[CapabilitiesClientListResponse]{ More: func(page CapabilitiesClientListResponse) bool { @@ -344,7 +348,7 @@ func (client *CapabilitiesClient) listCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go similarity index 87% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go rename to sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go index cbfe07c6cfe8..aef06d8aae9c 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_capabilitytypes_client.go +++ b/sdk/resourcemanager/chaos/armchaos/capabilitytypes_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -31,9 +32,9 @@ type CapabilityTypesClient struct { } // NewCapabilityTypesClient creates a new instance of CapabilityTypesClient 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. +// - 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 NewCapabilityTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CapabilityTypesClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -56,11 +57,12 @@ 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 2021-09-15-preview -// locationName - String that represents a Location resource name. -// 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. +// +// Generated from API version 2023-04-01-preview +// - locationName - String that represents a Location resource name. +// - 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) { req, err := client.getCreateRequest(ctx, locationName, targetTypeName, capabilityTypeName, options) if err != nil { @@ -100,7 +102,7 @@ func (client *CapabilityTypesClient) getCreateRequest(ctx context.Context, locat return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -116,11 +118,12 @@ func (client *CapabilityTypesClient) getHandleResponse(resp *http.Response) (Cap } // NewListPager - Get a list of Capability Type resources for given Target Type and location. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// locationName - String that represents a Location resource name. -// targetTypeName - String that represents a Target Type resource name. -// options - CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.List method. +// +// Generated from API version 2023-04-01-preview +// - locationName - String that represents a Location resource name. +// - 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] { return runtime.NewPager(runtime.PagingHandler[CapabilityTypesClientListResponse]{ More: func(page CapabilityTypesClientListResponse) bool { @@ -169,7 +172,7 @@ func (client *CapabilityTypesClient) listCreateRequest(ctx context.Context, loca return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go b/sdk/resourcemanager/chaos/armchaos/constants.go similarity index 85% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go rename to sdk/resourcemanager/chaos/armchaos/constants.go index 1a1b5fec5363..5e78a8464a47 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_constants.go +++ b/sdk/resourcemanager/chaos/armchaos/constants.go @@ -5,12 +5,13 @@ // 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 const ( moduleName = "armchaos" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -47,6 +48,20 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// FilterType - Enum that discriminates between filter types. Currently only Simple type is supported. +type FilterType string + +const ( + FilterTypeSimple FilterType = "Simple" +) + +// PossibleFilterTypeValues returns the possible values for the FilterType const type. +func PossibleFilterTypeValues() []FilterType { + return []FilterType{ + FilterTypeSimple, + } +} + // 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 @@ -72,6 +87,7 @@ type ResourceIdentityType string const ( ResourceIdentityTypeNone ResourceIdentityType = "None" ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" ) // PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. @@ -79,6 +95,7 @@ func PossibleResourceIdentityTypeValues() []ResourceIdentityType { return []ResourceIdentityType{ ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned, + ResourceIdentityTypeUserAssigned, } } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go b/sdk/resourcemanager/chaos/armchaos/experiments_client.go similarity index 76% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go rename to sdk/resourcemanager/chaos/armchaos/experiments_client.go index e6f6877213d6..3e2c314e1723 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_experiments_client.go +++ b/sdk/resourcemanager/chaos/armchaos/experiments_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -32,9 +33,9 @@ type ExperimentsClient struct { } // NewExperimentsClient creates a new instance of ExperimentsClient 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. +// - 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 NewExperimentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExperimentsClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -55,46 +56,30 @@ func NewExperimentsClient(subscriptionID string, credential azcore.TokenCredenti return client, nil } -// BeginCancel - Cancel a running Experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// 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) { - if options == nil || options.ResumeToken == "" { - resp, err := client.cancel(ctx, resourceGroupName, experimentName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ExperimentsClientCancelResponse]{ - FinalStateVia: runtime.FinalStateViaOriginalURI, - }) - } else { - return runtime.NewPollerFromResumeToken[ExperimentsClientCancelResponse](options.ResumeToken, client.pl, nil) - } -} - // Cancel - Cancel a running Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -func (client *ExperimentsClient) cancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginCancelOptions) (*http.Response, error) { +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientCancelOptions contains the optional parameters for the ExperimentsClient.Cancel method. +func (client *ExperimentsClient) Cancel(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientCancelOptions) (ExperimentsClientCancelResponse, error) { req, err := client.cancelCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { - return nil, err + return ExperimentsClientCancelResponse{}, err } resp, err := client.pl.Do(req) if err != nil { - return nil, err + return ExperimentsClientCancelResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + return ExperimentsClientCancelResponse{}, runtime.NewResponseError(resp) } - return resp, nil + return client.cancelHandleResponse(resp) } // cancelCreateRequest creates the Cancel request. -func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientBeginCancelOptions) (*policy.Request, error) { +func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientCancelOptions) (*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") @@ -113,54 +98,47 @@ func (client *ExperimentsClient) cancelCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// BeginCreateOrUpdate - Create or update a Experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// experiment - 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) { - if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, experimentName, experiment, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ExperimentsClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaOriginalURI, - }) - } else { - return runtime.NewPollerFromResumeToken[ExperimentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) +// cancelHandleResponse handles the Cancel response. +func (client *ExperimentsClient) cancelHandleResponse(resp *http.Response) (ExperimentsClientCancelResponse, error) { + result := ExperimentsClientCancelResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExperimentCancelOperationResult); err != nil { + return ExperimentsClientCancelResponse{}, err } + return result, nil } // CreateOrUpdate - Create or update a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -func (client *ExperimentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - experiment - Experiment resource to be created or updated. +// - options - ExperimentsClientCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.CreateOrUpdate +// method. +func (client *ExperimentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, experimentName string, experiment Experiment, options *ExperimentsClientCreateOrUpdateOptions) (ExperimentsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, experimentName, experiment, options) if err != nil { - return nil, err + return ExperimentsClientCreateOrUpdateResponse{}, err } resp, err := client.pl.Do(req) if err != nil { - return nil, err + return ExperimentsClientCreateOrUpdateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return nil, runtime.NewResponseError(resp) + return ExperimentsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) } - return resp, nil + return client.createOrUpdateHandleResponse(resp) } // 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, experiment Experiment, options *ExperimentsClientCreateOrUpdateOptions) (*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") @@ -179,18 +157,28 @@ func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, experiment) } +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ExperimentsClient) createOrUpdateHandleResponse(resp *http.Response) (ExperimentsClientCreateOrUpdateResponse, error) { + result := ExperimentsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Experiment); err != nil { + return ExperimentsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + // Delete - Delete a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientDeleteOptions contains the optional parameters for the ExperimentsClient.Delete method. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientDeleteOptions contains the optional parameters for the ExperimentsClient.Delete method. func (client *ExperimentsClient) Delete(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientDeleteOptions) (ExperimentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { @@ -226,7 +214,7 @@ func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -234,10 +222,11 @@ func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Get a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientGetOptions contains the optional parameters for the ExperimentsClient.Get method. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - 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) { req, err := client.getCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { @@ -273,7 +262,7 @@ func (client *ExperimentsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -290,12 +279,13 @@ func (client *ExperimentsClient) getHandleResponse(resp *http.Response) (Experim // GetExecutionDetails - Get an execution detail of a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// executionDetailsID - GUID that represents a Experiment execution detail. -// options - ExperimentsClientGetExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.GetExecutionDetails -// method. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - executionDetailsID - GUID that represents a Experiment execution detail. +// - options - ExperimentsClientGetExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.GetExecutionDetails +// method. func (client *ExperimentsClient) GetExecutionDetails(ctx context.Context, resourceGroupName string, experimentName string, executionDetailsID string, options *ExperimentsClientGetExecutionDetailsOptions) (ExperimentsClientGetExecutionDetailsResponse, error) { req, err := client.getExecutionDetailsCreateRequest(ctx, resourceGroupName, experimentName, executionDetailsID, options) if err != nil { @@ -335,7 +325,7 @@ func (client *ExperimentsClient) getExecutionDetailsCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -352,11 +342,12 @@ func (client *ExperimentsClient) getExecutionDetailsHandleResponse(resp *http.Re // GetStatus - Get a status of a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// statusID - GUID that represents a Experiment status. -// options - ExperimentsClientGetStatusOptions contains the optional parameters for the ExperimentsClient.GetStatus method. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - statusID - GUID that represents a Experiment status. +// - options - ExperimentsClientGetStatusOptions contains the optional parameters for the ExperimentsClient.GetStatus method. func (client *ExperimentsClient) GetStatus(ctx context.Context, resourceGroupName string, experimentName string, statusID string, options *ExperimentsClientGetStatusOptions) (ExperimentsClientGetStatusResponse, error) { req, err := client.getStatusCreateRequest(ctx, resourceGroupName, experimentName, statusID, options) if err != nil { @@ -396,7 +387,7 @@ func (client *ExperimentsClient) getStatusCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -412,10 +403,10 @@ func (client *ExperimentsClient) getStatusHandleResponse(resp *http.Response) (E } // NewListPager - Get a list of Experiment resources in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// options - ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.List method. +// +// Generated from API version 2023-04-01-preview +// - 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 { @@ -460,7 +451,7 @@ func (client *ExperimentsClient) listCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") if options != nil && options.Running != nil { reqQP.Set("running", strconv.FormatBool(*options.Running)) } @@ -482,9 +473,9 @@ func (client *ExperimentsClient) listHandleResponse(resp *http.Response) (Experi } // NewListAllPager - Get a list of Experiment resources in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// options - ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.ListAll method. +// +// Generated from API version 2023-04-01-preview +// - 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 { @@ -525,7 +516,7 @@ func (client *ExperimentsClient) listAllCreateRequest(ctx context.Context, optio return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") if options != nil && options.Running != nil { reqQP.Set("running", strconv.FormatBool(*options.Running)) } @@ -547,12 +538,12 @@ func (client *ExperimentsClient) listAllHandleResponse(resp *http.Response) (Exp } // NewListAllStatusesPager - Get a list of statuses of a Experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.ListAllStatuses -// method. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.NewListAllStatusesPager +// method. func (client *ExperimentsClient) NewListAllStatusesPager(resourceGroupName string, experimentName string, options *ExperimentsClientListAllStatusesOptions) *runtime.Pager[ExperimentsClientListAllStatusesResponse] { return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListAllStatusesResponse]{ More: func(page ExperimentsClientListAllStatusesResponse) bool { @@ -601,7 +592,7 @@ func (client *ExperimentsClient) listAllStatusesCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -617,12 +608,12 @@ func (client *ExperimentsClient) listAllStatusesHandleResponse(resp *http.Respon } // NewListExecutionDetailsPager - Get a list of execution details of a Experiment resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.ListExecutionDetails -// method. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.NewListExecutionDetailsPager +// method. func (client *ExperimentsClient) NewListExecutionDetailsPager(resourceGroupName string, experimentName string, options *ExperimentsClientListExecutionDetailsOptions) *runtime.Pager[ExperimentsClientListExecutionDetailsResponse] { return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListExecutionDetailsResponse]{ More: func(page ExperimentsClientListExecutionDetailsResponse) bool { @@ -671,7 +662,7 @@ func (client *ExperimentsClient) listExecutionDetailsCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -688,10 +679,11 @@ func (client *ExperimentsClient) listExecutionDetailsHandleResponse(resp *http.R // Start - Start a Experiment resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// resourceGroupName - String that represents an Azure resource group. -// experimentName - String that represents a Experiment resource name. -// options - ExperimentsClientStartOptions contains the optional parameters for the ExperimentsClient.Start method. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - options - ExperimentsClientStartOptions contains the optional parameters for the ExperimentsClient.Start method. func (client *ExperimentsClient) Start(ctx context.Context, resourceGroupName string, experimentName string, options *ExperimentsClientStartOptions) (ExperimentsClientStartResponse, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, experimentName, options) if err != nil { @@ -727,7 +719,7 @@ func (client *ExperimentsClient) startCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -741,3 +733,61 @@ func (client *ExperimentsClient) startHandleResponse(resp *http.Response) (Exper } return result, nil } + +// Update - The operation to update an experiment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01-preview +// - resourceGroupName - String that represents an Azure resource group. +// - experimentName - String that represents a Experiment resource name. +// - experiment - Parameters supplied to the Update experiment operation. +// - options - ExperimentsClientUpdateOptions contains the optional parameters for the ExperimentsClient.Update method. +func (client *ExperimentsClient) Update(ctx context.Context, resourceGroupName string, experimentName string, experiment ExperimentUpdate, options *ExperimentsClientUpdateOptions) (ExperimentsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, experimentName, experiment, options) + if err != nil { + return ExperimentsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExperimentsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExperimentsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ExperimentsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, experimentName string, experiment ExperimentUpdate, options *ExperimentsClientUpdateOptions) (*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") + } + 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.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, experiment) +} + +// updateHandleResponse handles the Update response. +func (client *ExperimentsClient) updateHandleResponse(resp *http.Response) (ExperimentsClientUpdateResponse, error) { + result := ExperimentsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Experiment); err != nil { + return ExperimentsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/chaos/armchaos/go.mod b/sdk/resourcemanager/chaos/armchaos/go.mod index 2cad5279935a..3b3aa1310953 100644 --- a/sdk/resourcemanager/chaos/armchaos/go.mod +++ b/sdk/resourcemanager/chaos/armchaos/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/chaos/armchaos go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/chaos/armchaos/go.sum b/sdk/resourcemanager/chaos/armchaos/go.sum index ed5b814680ee..3afb578030a5 100644 --- a/sdk/resourcemanager/chaos/armchaos/go.sum +++ b/sdk/resourcemanager/chaos/armchaos/go.sum @@ -1,33 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_models.go b/sdk/resourcemanager/chaos/armchaos/models.go similarity index 87% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_models.go rename to sdk/resourcemanager/chaos/armchaos/models.go index fe1c7593af6b..ca0649b41820 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_models.go +++ b/sdk/resourcemanager/chaos/armchaos/models.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -91,7 +92,7 @@ type CapabilitiesClientGetOptions struct { // placeholder for future optional parameters } -// CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.List method. +// CapabilitiesClientListOptions contains the optional parameters for the CapabilitiesClient.NewListPager method. type CapabilitiesClientListOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -174,12 +175,18 @@ type CapabilityTypeListResult struct { // CapabilityTypeProperties - Model that represents the Capability Type properties model. type CapabilityTypeProperties struct { + // Runtime properties of this Capability Type. + RuntimeProperties *CapabilityTypePropertiesRuntimeProperties `json:"runtimeProperties,omitempty"` + // READ-ONLY; Localized string of the description. Description *string `json:"description,omitempty" azure:"ro"` // READ-ONLY; Localized string of the display name. DisplayName *string `json:"displayName,omitempty" azure:"ro"` + // READ-ONLY; String of the kind of this Capability Type. + Kind *string `json:"kind,omitempty" azure:"ro"` + // READ-ONLY; URL to retrieve JSON schema of the Capability Type parameters. ParametersSchema *string `json:"parametersSchema,omitempty" azure:"ro"` @@ -193,17 +200,32 @@ type CapabilityTypeProperties struct { Urn *string `json:"urn,omitempty" azure:"ro"` } +// CapabilityTypePropertiesRuntimeProperties - Runtime properties of this Capability Type. +type CapabilityTypePropertiesRuntimeProperties struct { + // READ-ONLY; String of the kind of the resource's action type (continuous or discrete). + Kind *string `json:"kind,omitempty" azure:"ro"` +} + // CapabilityTypesClientGetOptions contains the optional parameters for the CapabilityTypesClient.Get method. type CapabilityTypesClientGetOptions struct { // placeholder for future optional parameters } -// CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.List method. +// CapabilityTypesClientListOptions contains the optional parameters for the CapabilityTypesClient.NewListPager method. type CapabilityTypesClientListOptions struct { // String that sets the continuation token. ContinuationToken *string } +// ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties - The list of user identities associated with the experiment. +type ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + // ContinuousAction - Model that represents a continuous action. type ContinuousAction struct { // REQUIRED; ISO8601 formatted string that represents a duration. @@ -276,7 +298,7 @@ func (d *DiscreteAction) GetAction() *Action { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -494,17 +516,20 @@ type ExperimentStatusProperties struct { Status *string `json:"status,omitempty" azure:"ro"` } -// ExperimentsClientBeginCancelOptions contains the optional parameters for the ExperimentsClient.BeginCancel method. -type ExperimentsClientBeginCancelOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string +// ExperimentUpdate - Describes an experiment update. +type ExperimentUpdate struct { + // The identity of the experiment resource. + Identity *ResourceIdentity `json:"identity,omitempty"` +} + +// ExperimentsClientCancelOptions contains the optional parameters for the ExperimentsClient.Cancel method. +type ExperimentsClientCancelOptions struct { + // placeholder for future optional parameters } -// ExperimentsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.BeginCreateOrUpdate -// method. -type ExperimentsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string +// ExperimentsClientCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.CreateOrUpdate method. +type ExperimentsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters } // ExperimentsClientDeleteOptions contains the optional parameters for the ExperimentsClient.Delete method. @@ -528,7 +553,7 @@ type ExperimentsClientGetStatusOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.ListAll method. +// ExperimentsClientListAllOptions contains the optional parameters for the ExperimentsClient.NewListAllPager method. type ExperimentsClientListAllOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -537,18 +562,19 @@ type ExperimentsClientListAllOptions struct { Running *bool } -// ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.ListAllStatuses method. +// ExperimentsClientListAllStatusesOptions contains the optional parameters for the ExperimentsClient.NewListAllStatusesPager +// method. type ExperimentsClientListAllStatusesOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.ListExecutionDetails +// ExperimentsClientListExecutionDetailsOptions contains the optional parameters for the ExperimentsClient.NewListExecutionDetailsPager // method. type ExperimentsClientListExecutionDetailsOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.List method. +// ExperimentsClientListOptions contains the optional parameters for the ExperimentsClient.NewListPager method. type ExperimentsClientListOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -562,6 +588,29 @@ type ExperimentsClientStartOptions struct { // placeholder for future optional parameters } +// ExperimentsClientUpdateOptions contains the optional parameters for the ExperimentsClient.Update method. +type ExperimentsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// FilterClassification provides polymorphic access to related types. +// Call the interface's GetFilter() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *Filter, *SimpleFilter +type FilterClassification interface { + // GetFilter returns the Filter content of the underlying type. + GetFilter() *Filter +} + +// Filter - Model that represents available filter types that can be applied to a targets list. +type Filter struct { + // REQUIRED; Enum that discriminates between filter types. Currently only Simple type is supported. + Type *FilterType `json:"type,omitempty"` +} + +// GetFilter implements the FilterClassification interface for type Filter. +func (f *Filter) GetFilter() *Filter { return f } + // KeyValuePair - A map to describe the settings of an action. type KeyValuePair struct { // REQUIRED; The name of the setting for the action. @@ -620,7 +669,7 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty" azure:"ro"` } -// OperationsClientListAllOptions contains the optional parameters for the OperationsClient.ListAll method. +// OperationsClientListAllOptions contains the optional parameters for the OperationsClient.NewListAllPager method. type OperationsClientListAllOptions struct { // placeholder for future optional parameters } @@ -637,11 +686,16 @@ type Resource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// ResourceIdentity - The managed identity of a resource. +// ResourceIdentity - The identity of a resource. type ResourceIdentity struct { // REQUIRED; String of the resource identity type. Type *ResourceIdentityType `json:"type,omitempty"` + // 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]*ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties `json:"userAssignedIdentities,omitempty"` + // READ-ONLY; GUID that represents the principal ID of this resource identity. PrincipalID *string `json:"principalId,omitempty" azure:"ro"` @@ -659,6 +713,31 @@ type Selector struct { // REQUIRED; Enum of the selector type. Type *SelectorType `json:"type,omitempty"` + + // Model that represents available filter types that can be applied to a targets list. + Filter FilterClassification `json:"filter,omitempty"` +} + +// SimpleFilter - Model that represents a simple target filter. +type SimpleFilter struct { + // REQUIRED; Enum that discriminates between filter types. Currently only Simple type is supported. + Type *FilterType `json:"type,omitempty"` + + // Model that represents the Simple filter parameters. + Parameters *SimpleFilterParameters `json:"parameters,omitempty"` +} + +// GetFilter implements the FilterClassification interface for type SimpleFilter. +func (s *SimpleFilter) GetFilter() *Filter { + return &Filter{ + Type: s.Type, + } +} + +// SimpleFilterParameters - Model that represents the Simple filter parameters. +type SimpleFilterParameters struct { + // List of Azure availability zones to filter targets by. + Zones []*string `json:"zones,omitempty"` } // Step - Model that represents a step in the Experiment resource. @@ -709,7 +788,7 @@ type SystemData struct { // Target - Model that represents a Target resource. type Target struct { // REQUIRED; The properties of the target resource. - Properties map[string]interface{} `json:"properties,omitempty"` + Properties map[string]any `json:"properties,omitempty"` // Location of the target resource. Location *string `json:"location,omitempty"` @@ -741,7 +820,8 @@ type TargetReference struct { // REQUIRED; String of the resource ID of a Target resource. ID *string `json:"id,omitempty"` - // REQUIRED; Enum of the Target reference type. + // CONSTANT; Enum of the Target reference type. + // Field has constant value "ChaosTarget", any specified value is ignored. Type *string `json:"type,omitempty"` } @@ -795,7 +875,7 @@ type TargetTypesClientGetOptions struct { // placeholder for future optional parameters } -// TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.List method. +// TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.NewListPager method. type TargetTypesClientListOptions struct { // String that sets the continuation token. ContinuationToken *string @@ -816,7 +896,7 @@ type TargetsClientGetOptions struct { // placeholder for future optional parameters } -// TargetsClientListOptions contains the optional parameters for the TargetsClient.List method. +// TargetsClientListOptions contains the optional parameters for the TargetsClient.NewListPager method. type TargetsClientListOptions struct { // String that sets the continuation token. ContinuationToken *string diff --git a/sdk/resourcemanager/chaos/armchaos/models_serde.go b/sdk/resourcemanager/chaos/armchaos/models_serde.go new file mode 100644 index 000000000000..a3f0449d7448 --- /dev/null +++ b/sdk/resourcemanager/chaos/armchaos/models_serde.go @@ -0,0 +1,1980 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Action. +func (a Action) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + objectMap["type"] = a.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Action. +func (a *Action) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ActionStatus. +func (a ActionStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionId", a.ActionID) + populate(objectMap, "actionName", a.ActionName) + populateTimeRFC3339(objectMap, "endTime", a.EndTime) + populateTimeRFC3339(objectMap, "startTime", a.StartTime) + populate(objectMap, "status", a.Status) + populate(objectMap, "targets", a.Targets) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ActionStatus. +func (a *ActionStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionId": + err = unpopulate(val, "ActionID", &a.ActionID) + delete(rawMsg, key) + case "actionName": + err = unpopulate(val, "ActionName", &a.ActionName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "targets": + err = unpopulate(val, "Targets", &a.Targets) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Branch. +func (b Branch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actions", b.Actions) + populate(objectMap, "name", b.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Branch. +func (b *Branch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + b.Actions, err = unmarshalActionClassificationArray(val) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BranchStatus. +func (b BranchStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actions", b.Actions) + populate(objectMap, "branchId", b.BranchID) + populate(objectMap, "branchName", b.BranchName) + populate(objectMap, "status", b.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BranchStatus. +func (b *BranchStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, "Actions", &b.Actions) + delete(rawMsg, key) + case "branchId": + err = unpopulate(val, "BranchID", &b.BranchID) + delete(rawMsg, key) + case "branchName": + err = unpopulate(val, "BranchName", &b.BranchName) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Capability. +func (c Capability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Capability. +func (c *Capability) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 CapabilityListResult. +func (c CapabilityListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityListResult. +func (c *CapabilityListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityProperties. +func (c CapabilityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", c.Description) + populate(objectMap, "parametersSchema", c.ParametersSchema) + populate(objectMap, "publisher", c.Publisher) + populate(objectMap, "targetType", c.TargetType) + populate(objectMap, "urn", c.Urn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityProperties. +func (c *CapabilityProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "parametersSchema": + err = unpopulate(val, "ParametersSchema", &c.ParametersSchema) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &c.Publisher) + delete(rawMsg, key) + case "targetType": + err = unpopulate(val, "TargetType", &c.TargetType) + delete(rawMsg, key) + case "urn": + err = unpopulate(val, "Urn", &c.Urn) + 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 CapabilityType. +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) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityType. +func (c *CapabilityType) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 CapabilityTypeListResult. +func (c CapabilityTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityTypeListResult. +func (c *CapabilityTypeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilityTypeProperties. +func (c CapabilityTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", c.Description) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "kind", c.Kind) + populate(objectMap, "parametersSchema", c.ParametersSchema) + populate(objectMap, "publisher", c.Publisher) + populate(objectMap, "runtimeProperties", c.RuntimeProperties) + populate(objectMap, "targetType", c.TargetType) + populate(objectMap, "urn", c.Urn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityTypeProperties. +func (c *CapabilityTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &c.DisplayName) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &c.Kind) + delete(rawMsg, key) + case "parametersSchema": + err = unpopulate(val, "ParametersSchema", &c.ParametersSchema) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &c.Publisher) + delete(rawMsg, key) + case "runtimeProperties": + err = unpopulate(val, "RuntimeProperties", &c.RuntimeProperties) + delete(rawMsg, key) + case "targetType": + err = unpopulate(val, "TargetType", &c.TargetType) + delete(rawMsg, key) + case "urn": + err = unpopulate(val, "Urn", &c.Urn) + 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 CapabilityTypePropertiesRuntimeProperties. +func (c CapabilityTypePropertiesRuntimeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", c.Kind) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapabilityTypePropertiesRuntimeProperties. +func (c *CapabilityTypePropertiesRuntimeProperties) 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 "kind": + err = unpopulate(val, "Kind", &c.Kind) + 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 ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties. +func (c ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties) 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 ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties. +func (c *ComponentsEwb5TmSchemasUserassignedidentitiesAdditionalproperties) 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) + populate(objectMap, "duration", c.Duration) + populate(objectMap, "name", c.Name) + populate(objectMap, "parameters", c.Parameters) + populate(objectMap, "selectorId", c.SelectorID) + objectMap["type"] = "continuous" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContinuousAction. +func (c *ContinuousAction) 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 "duration": + err = unpopulate(val, "Duration", &c.Duration) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &c.Parameters) + delete(rawMsg, key) + case "selectorId": + err = unpopulate(val, "SelectorID", &c.SelectorID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 DelayAction. +func (d DelayAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "duration", d.Duration) + populate(objectMap, "name", d.Name) + objectMap["type"] = "delay" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DelayAction. +func (d *DelayAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "duration": + err = unpopulate(val, "Duration", &d.Duration) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DiscreteAction. +func (d DiscreteAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", d.Name) + populate(objectMap, "parameters", d.Parameters) + populate(objectMap, "selectorId", d.SelectorID) + objectMap["type"] = "discrete" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DiscreteAction. +func (d *DiscreteAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "selectorId": + err = unpopulate(val, "SelectorID", &d.SelectorID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Experiment. +func (e Experiment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Experiment. +func (e *Experiment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentCancelOperationResult. +func (e ExperimentCancelOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", e.Name) + populate(objectMap, "statusUrl", e.StatusURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentCancelOperationResult. +func (e *ExperimentCancelOperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "statusUrl": + err = unpopulate(val, "StatusURL", &e.StatusURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionActionTargetDetailsError. +func (e ExperimentExecutionActionTargetDetailsError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionActionTargetDetailsError. +func (e *ExperimentExecutionActionTargetDetailsError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionActionTargetDetailsProperties. +func (e ExperimentExecutionActionTargetDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + populate(objectMap, "status", e.Status) + populate(objectMap, "target", e.Target) + populateTimeRFC3339(objectMap, "targetCompletedTime", e.TargetCompletedTime) + populateTimeRFC3339(objectMap, "targetFailedTime", e.TargetFailedTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionActionTargetDetailsProperties. +func (e *ExperimentExecutionActionTargetDetailsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + case "targetCompletedTime": + err = unpopulateTimeRFC3339(val, "TargetCompletedTime", &e.TargetCompletedTime) + delete(rawMsg, key) + case "targetFailedTime": + err = unpopulateTimeRFC3339(val, "TargetFailedTime", &e.TargetFailedTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetails. +func (e ExperimentExecutionDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetails. +func (e *ExperimentExecutionDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsListResult. +func (e ExperimentExecutionDetailsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsListResult. +func (e *ExperimentExecutionDetailsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsProperties. +func (e ExperimentExecutionDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDateTime", e.CreatedDateTime) + populate(objectMap, "experimentId", e.ExperimentID) + populate(objectMap, "failureReason", e.FailureReason) + populateTimeRFC3339(objectMap, "lastActionDateTime", e.LastActionDateTime) + populate(objectMap, "runInformation", e.RunInformation) + populateTimeRFC3339(objectMap, "startDateTime", e.StartDateTime) + populate(objectMap, "status", e.Status) + populateTimeRFC3339(objectMap, "stopDateTime", e.StopDateTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsProperties. +func (e *ExperimentExecutionDetailsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdDateTime": + err = unpopulateTimeRFC3339(val, "CreatedDateTime", &e.CreatedDateTime) + delete(rawMsg, key) + case "experimentId": + err = unpopulate(val, "ExperimentID", &e.ExperimentID) + delete(rawMsg, key) + case "failureReason": + err = unpopulate(val, "FailureReason", &e.FailureReason) + delete(rawMsg, key) + case "lastActionDateTime": + err = unpopulateTimeRFC3339(val, "LastActionDateTime", &e.LastActionDateTime) + delete(rawMsg, key) + case "runInformation": + err = unpopulate(val, "RunInformation", &e.RunInformation) + delete(rawMsg, key) + case "startDateTime": + err = unpopulateTimeRFC3339(val, "StartDateTime", &e.StartDateTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "stopDateTime": + err = unpopulateTimeRFC3339(val, "StopDateTime", &e.StopDateTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentExecutionDetailsPropertiesRunInformation. +func (e ExperimentExecutionDetailsPropertiesRunInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "steps", e.Steps) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsPropertiesRunInformation. +func (e *ExperimentExecutionDetailsPropertiesRunInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "steps": + err = unpopulate(val, "Steps", &e.Steps) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentListResult. +func (e ExperimentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentListResult. +func (e *ExperimentListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentProperties. +func (e ExperimentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "selectors", e.Selectors) + populate(objectMap, "startOnCreation", e.StartOnCreation) + populate(objectMap, "steps", e.Steps) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentProperties. +func (e *ExperimentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "selectors": + err = unpopulate(val, "Selectors", &e.Selectors) + delete(rawMsg, key) + case "startOnCreation": + err = unpopulate(val, "StartOnCreation", &e.StartOnCreation) + delete(rawMsg, key) + case "steps": + err = unpopulate(val, "Steps", &e.Steps) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStartOperationResult. +func (e ExperimentStartOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", e.Name) + populate(objectMap, "statusUrl", e.StatusURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStartOperationResult. +func (e *ExperimentStartOperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "statusUrl": + err = unpopulate(val, "StatusURL", &e.StatusURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatus. +func (e ExperimentStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatus. +func (e *ExperimentStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatusListResult. +func (e ExperimentStatusListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatusListResult. +func (e *ExperimentStatusListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentStatusProperties. +func (e ExperimentStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdDateUtc", e.CreatedDateUTC) + populateTimeRFC3339(objectMap, "endDateUtc", e.EndDateUTC) + populate(objectMap, "status", e.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatusProperties. +func (e *ExperimentStatusProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdDateUtc": + err = unpopulateTimeRFC3339(val, "CreatedDateUTC", &e.CreatedDateUTC) + delete(rawMsg, key) + case "endDateUtc": + err = unpopulateTimeRFC3339(val, "EndDateUTC", &e.EndDateUTC) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExperimentUpdate. +func (e ExperimentUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", e.Identity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentUpdate. +func (e *ExperimentUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Filter. +func (f Filter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = f.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Filter. +func (f *Filter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyValuePair. +func (k KeyValuePair) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "key", k.Key) + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyValuePair. +func (k *KeyValuePair) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "key": + err = unpopulate(val, "Key", &k.Key) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceIdentity. +func (r ResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", r.PrincipalID) + populate(objectMap, "tenantId", r.TenantID) + 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 { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &r.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &r.TenantID) + 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) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Selector. +func (s Selector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "filter", s.Filter) + populate(objectMap, "id", s.ID) + populate(objectMap, "targets", s.Targets) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Selector. +func (s *Selector) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "filter": + s.Filter, err = unmarshalFilterClassification(val) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "targets": + err = unpopulate(val, "Targets", &s.Targets) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SimpleFilter. +func (s SimpleFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "parameters", s.Parameters) + objectMap["type"] = FilterTypeSimple + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SimpleFilter. +func (s *SimpleFilter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "parameters": + err = unpopulate(val, "Parameters", &s.Parameters) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SimpleFilterParameters. +func (s SimpleFilterParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "zones", s.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SimpleFilterParameters. +func (s *SimpleFilterParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "zones": + err = unpopulate(val, "Zones", &s.Zones) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Step. +func (s Step) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branches", s.Branches) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Step. +func (s *Step) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branches": + err = unpopulate(val, "Branches", &s.Branches) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StepStatus. +func (s StepStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branches", s.Branches) + populate(objectMap, "status", s.Status) + populate(objectMap, "stepId", s.StepID) + populate(objectMap, "stepName", s.StepName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StepStatus. +func (s *StepStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branches": + err = unpopulate(val, "Branches", &s.Branches) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "stepId": + err = unpopulate(val, "StepID", &s.StepID) + delete(rawMsg, key) + case "stepName": + err = unpopulate(val, "StepName", &s.StepName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Target. +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) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Target. +func (t *Target) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetListResult. +func (t TargetListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetListResult. +func (t *TargetListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetReference. +func (t TargetReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + objectMap["type"] = "ChaosTarget" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetReference. +func (t *TargetReference) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetType. +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) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetType. +func (t *TargetType) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetTypeListResult. +func (t TargetTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetTypeListResult. +func (t *TargetTypeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetTypeProperties. +func (t TargetTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", t.Description) + populate(objectMap, "displayName", t.DisplayName) + populate(objectMap, "propertiesSchema", t.PropertiesSchema) + populate(objectMap, "resourceTypes", t.ResourceTypes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetTypeProperties. +func (t *TargetTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &t.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &t.DisplayName) + delete(rawMsg, key) + case "propertiesSchema": + err = unpopulate(val, "PropertiesSchema", &t.PropertiesSchema) + delete(rawMsg, key) + case "resourceTypes": + err = unpopulate(val, "ResourceTypes", &t.ResourceTypes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) 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, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go b/sdk/resourcemanager/chaos/armchaos/operations_client.go similarity index 89% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go rename to sdk/resourcemanager/chaos/armchaos/operations_client.go index 762a432fd8c0..05b7d1e4d97d 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_operations_client.go +++ b/sdk/resourcemanager/chaos/armchaos/operations_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -27,8 +28,8 @@ type OperationsClient struct { } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -49,9 +50,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO } // NewListAllPager - Get a list all available Operations. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// options - OperationsClientListAllOptions contains the optional parameters for the OperationsClient.ListAll method. +// +// Generated from API version 2023-04-01-preview +// - 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 { @@ -88,7 +89,7 @@ func (client *OperationsClient) listAllCreateRequest(ctx context.Context, option return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go similarity index 75% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go index b23d5051eeb6..40337b8d8e6c 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/chaos/armchaos/polymorphic_helpers.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -14,7 +15,7 @@ func unmarshalActionClassification(rawMsg json.RawMessage) (ActionClassification if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -50,3 +51,21 @@ func unmarshalActionClassificationArray(rawMsg json.RawMessage) ([]ActionClassif } return fArray, nil } + +func unmarshalFilterClassification(rawMsg json.RawMessage) (FilterClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b FilterClassification + switch m["type"] { + case string(FilterTypeSimple): + b = &SimpleFilter{} + default: + b = &Filter{} + } + return b, json.Unmarshal(rawMsg, b) +} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go b/sdk/resourcemanager/chaos/armchaos/response_types.go similarity index 88% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go rename to sdk/resourcemanager/chaos/armchaos/response_types.go index 3d53332ee2ca..7a92e0573fd6 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_response_types.go +++ b/sdk/resourcemanager/chaos/armchaos/response_types.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -23,7 +24,7 @@ type CapabilitiesClientGetResponse struct { Capability } -// CapabilitiesClientListResponse contains the response from method CapabilitiesClient.List. +// CapabilitiesClientListResponse contains the response from method CapabilitiesClient.NewListPager. type CapabilitiesClientListResponse struct { CapabilityListResult } @@ -33,7 +34,7 @@ type CapabilityTypesClientGetResponse struct { CapabilityType } -// CapabilityTypesClientListResponse contains the response from method CapabilityTypesClient.List. +// CapabilityTypesClientListResponse contains the response from method CapabilityTypesClient.NewListPager. type CapabilityTypesClientListResponse struct { CapabilityTypeListResult } @@ -68,22 +69,22 @@ type ExperimentsClientGetStatusResponse struct { ExperimentStatus } -// ExperimentsClientListAllResponse contains the response from method ExperimentsClient.ListAll. +// ExperimentsClientListAllResponse contains the response from method ExperimentsClient.NewListAllPager. type ExperimentsClientListAllResponse struct { ExperimentListResult } -// ExperimentsClientListAllStatusesResponse contains the response from method ExperimentsClient.ListAllStatuses. +// ExperimentsClientListAllStatusesResponse contains the response from method ExperimentsClient.NewListAllStatusesPager. type ExperimentsClientListAllStatusesResponse struct { ExperimentStatusListResult } -// ExperimentsClientListExecutionDetailsResponse contains the response from method ExperimentsClient.ListExecutionDetails. +// ExperimentsClientListExecutionDetailsResponse contains the response from method ExperimentsClient.NewListExecutionDetailsPager. type ExperimentsClientListExecutionDetailsResponse struct { ExperimentExecutionDetailsListResult } -// ExperimentsClientListResponse contains the response from method ExperimentsClient.List. +// ExperimentsClientListResponse contains the response from method ExperimentsClient.NewListPager. type ExperimentsClientListResponse struct { ExperimentListResult } @@ -93,7 +94,12 @@ type ExperimentsClientStartResponse struct { ExperimentStartOperationResult } -// OperationsClientListAllResponse contains the response from method OperationsClient.ListAll. +// ExperimentsClientUpdateResponse contains the response from method ExperimentsClient.Update. +type ExperimentsClientUpdateResponse struct { + Experiment +} + +// OperationsClientListAllResponse contains the response from method OperationsClient.NewListAllPager. type OperationsClientListAllResponse struct { OperationListResult } @@ -103,7 +109,7 @@ type TargetTypesClientGetResponse struct { TargetType } -// TargetTypesClientListResponse contains the response from method TargetTypesClient.List. +// TargetTypesClientListResponse contains the response from method TargetTypesClient.NewListPager. type TargetTypesClientListResponse struct { TargetTypeListResult } @@ -123,7 +129,7 @@ type TargetsClientGetResponse struct { Target } -// TargetsClientListResponse contains the response from method TargetsClient.List. +// TargetsClientListResponse contains the response from method TargetsClient.NewListPager. type TargetsClientListResponse struct { TargetListResult } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go b/sdk/resourcemanager/chaos/armchaos/targets_client.go similarity index 85% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go rename to sdk/resourcemanager/chaos/armchaos/targets_client.go index d7e9fad2262f..cce80701f044 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_targets_client.go +++ b/sdk/resourcemanager/chaos/armchaos/targets_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -31,9 +32,9 @@ type TargetsClient struct { } // NewTargetsClient creates a new instance of TargetsClient 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. +// - 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 NewTargetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TargetsClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -56,14 +57,15 @@ 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 2021-09-15-preview -// 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. -// targetName - String that represents a Target resource name. -// target - Target resource to be created or updated. -// options - TargetsClientCreateOrUpdateOptions contains the optional parameters for the TargetsClient.CreateOrUpdate method. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - targetName - String that represents a Target resource name. +// - target - 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) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, target, options) if err != nil { @@ -111,7 +113,7 @@ func (client *TargetsClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, target) @@ -128,13 +130,14 @@ 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 2021-09-15-preview -// 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. -// targetName - String that represents a Target resource name. -// options - TargetsClientDeleteOptions contains the optional parameters for the TargetsClient.Delete method. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - 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) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) if err != nil { @@ -182,7 +185,7 @@ func (client *TargetsClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -190,13 +193,14 @@ 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 2021-09-15-preview -// 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. -// targetName - String that represents a Target resource name. -// options - TargetsClientGetOptions contains the optional parameters for the TargetsClient.Get method. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - 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) { req, err := client.getCreateRequest(ctx, resourceGroupName, parentProviderNamespace, parentResourceType, parentResourceName, targetName, options) if err != nil { @@ -244,7 +248,7 @@ func (client *TargetsClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -260,13 +264,13 @@ func (client *TargetsClient) getHandleResponse(resp *http.Response) (TargetsClie } // NewListPager - Get a list of Target resources that extend a tracked regional resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// 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. -// options - TargetsClientListOptions contains the optional parameters for the TargetsClient.List method. +// +// Generated from API version 2023-04-01-preview +// - 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. +// - 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] { return runtime.NewPager(runtime.PagingHandler[TargetsClientListResponse]{ More: func(page TargetsClientListResponse) bool { @@ -323,7 +327,7 @@ func (client *TargetsClient) listCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go b/sdk/resourcemanager/chaos/armchaos/targettypes_client.go similarity index 88% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go rename to sdk/resourcemanager/chaos/armchaos/targettypes_client.go index 02b1bcd841de..2c7b415fe791 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_targettypes_client.go +++ b/sdk/resourcemanager/chaos/armchaos/targettypes_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -31,9 +32,9 @@ type TargetTypesClient struct { } // NewTargetTypesClient creates a new instance of TargetTypesClient 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. +// - 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 NewTargetTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TargetTypesClient, error) { if options == nil { options = &arm.ClientOptions{} @@ -56,10 +57,11 @@ 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 2021-09-15-preview -// locationName - String that represents a Location resource name. -// targetTypeName - String that represents a Target Type resource name. -// options - TargetTypesClientGetOptions contains the optional parameters for the TargetTypesClient.Get method. +// +// Generated from API version 2023-04-01-preview +// - locationName - String that represents a Location resource name. +// - 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) { req, err := client.getCreateRequest(ctx, locationName, targetTypeName, options) if err != nil { @@ -95,7 +97,7 @@ func (client *TargetTypesClient) getCreateRequest(ctx context.Context, locationN return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -111,10 +113,10 @@ func (client *TargetTypesClient) getHandleResponse(resp *http.Response) (TargetT } // NewListPager - Get a list of Target Type resources for given location. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-09-15-preview -// locationName - String that represents a Location resource name. -// options - TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.List method. +// +// Generated from API version 2023-04-01-preview +// - locationName - String that represents a Location resource name. +// - options - TargetTypesClientListOptions contains the optional parameters for the TargetTypesClient.NewListPager method. func (client *TargetTypesClient) NewListPager(locationName string, options *TargetTypesClientListOptions) *runtime.Pager[TargetTypesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TargetTypesClientListResponse]{ More: func(page TargetTypesClientListResponse) bool { @@ -159,7 +161,7 @@ func (client *TargetTypesClient) listCreateRequest(ctx context.Context, location return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-15-preview") + reqQP.Set("api-version", "2023-04-01-preview") if options != nil && options.ContinuationToken != nil { reqQP.Set("continuationToken", *options.ContinuationToken) } diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go b/sdk/resourcemanager/chaos/armchaos/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/chaos/armchaos/time_rfc3339.go index 6213a56e2f08..13c031ec6d72 100644 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/chaos/armchaos/time_rfc3339.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armchaos @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go deleted file mode 100644 index a9d07468a7a2..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilities_client_test.go +++ /dev/null @@ -1,125 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/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() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-VirtualMachine", - &armchaos.CapabilitiesClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapability.json -func ExampleCapabilitiesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteACapability.json -func ExampleCapabilitiesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateACapability.json -func ExampleCapabilitiesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilitiesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go deleted file mode 100644 index 8f10a8517638..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_capabilitytypes_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/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() - client, err := armchaos.NewCapabilityTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - "Microsoft-VirtualMachine", - &armchaos.CapabilityTypesClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetACapabilityType.json -func ExampleCapabilityTypesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewCapabilityTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "Microsoft-VirtualMachine", - "Shutdown-1.0", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go deleted file mode 100644 index 0d6994ba09a6..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_experiments_client_test.go +++ /dev/null @@ -1,312 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/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() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAllPager(&armchaos.ExperimentsClientListAllOptions{Running: nil, - ContinuationToken: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/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() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("exampleRG", - &armchaos.ExperimentsClientListOptions{Running: nil, - ContinuationToken: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteAExperiment.json -func ExampleExperimentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "exampleRG", - "exampleExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperiment.json -func ExampleExperimentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "exampleRG", - "exampleExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateAExperiment.json -func ExampleExperimentsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "exampleRG", - "exampleExperiment", - armchaos.Experiment{ - Location: to.Ptr("centraluseuap"), - Identity: &armchaos.ResourceIdentity{ - Type: to.Ptr(armchaos.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armchaos.ExperimentProperties{ - Selectors: []*armchaos.Selector{ - { - Type: to.Ptr(armchaos.SelectorTypeList), - ID: to.Ptr("selector1"), - Targets: []*armchaos.TargetReference{ - { - Type: to.Ptr("ChaosTarget"), - ID: to.Ptr("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"), - }}, - }}, - Steps: []*armchaos.Step{ - { - Name: to.Ptr("step1"), - Branches: []*armchaos.Branch{ - { - Name: to.Ptr("branch1"), - Actions: []armchaos.ActionClassification{ - &armchaos.Action{ - Name: to.Ptr("urn:csci:provider:providername:Shutdown/1.0"), - Type: to.Ptr("Continuous"), - }}, - }}, - }}, - }, - }, - 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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CancelAExperiment.json -func ExampleExperimentsClient_BeginCancel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/StartAExperiment.json -func ExampleExperimentsClient_Start() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Start(ctx, - "exampleRG", - "exampleExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentStatuses.json -func ExampleExperimentsClient_NewListAllStatusesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListAllStatusesPager("exampleRG", - "exampleExperiment", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentStatus.json -func ExampleExperimentsClient_GetStatus() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetStatus(ctx, - "exampleRG", - "exampleExperiment", - "50734542-2e64-4e08-814c-cc0e7475f7e4", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/ListExperimentExecutionsDetails.json -func ExampleExperimentsClient_NewListExecutionDetailsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListExecutionDetailsPager("exampleRG", - "exampleExperiment", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetAExperimentExecutionDetails.json -func ExampleExperimentsClient_GetExecutionDetails() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewExperimentsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetExecutionDetails(ctx, - "exampleRG", - "exampleExperiment", - "f24500ad-744e-4a26-864b-b76199eac333", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go deleted file mode 100644 index 74c3435cc083..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targets_client_test.go +++ /dev/null @@ -1,128 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/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() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - &armchaos.TargetsClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATarget.json -func ExampleTargetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-Agent", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/DeleteATarget.json -func ExampleTargetsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/CreateOrUpdateATarget.json -func ExampleTargetsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetsClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "exampleRG", - "Microsoft.Compute", - "virtualMachines", - "exampleVM", - "Microsoft-Agent", - armchaos.Target{ - Properties: map[string]interface{}{ - "identities": []interface{}{ - map[string]interface{}{ - "type": "CertificateSubjectIssuer", - "subject": "CN=example.subject", - }, - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go b/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go deleted file mode 100644 index 7e63882fa8fb..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/ze_generated_example_targettypes_client_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/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() - client, err := armchaos.NewTargetTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - &armchaos.TargetTypesClientListOptions{ContinuationToken: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/chaos/resource-manager/Microsoft.Chaos/preview/2021-09-15-preview/examples/GetATargetType.json -func ExampleTargetTypesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armchaos.NewTargetTypesClient("6b052e15-03d3-4f17-b2e1-be7f07588291", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "Microsoft-Agent", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go b/sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go deleted file mode 100644 index 74d39b994d02..000000000000 --- a/sdk/resourcemanager/chaos/armchaos/zz_generated_models_serde.go +++ /dev/null @@ -1,438 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armchaos - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// UnmarshalJSON implements the json.Unmarshaller interface for type ActionStatus. -func (a *ActionStatus) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "actionId": - err = unpopulate(val, "ActionID", &a.ActionID) - delete(rawMsg, key) - case "actionName": - err = unpopulate(val, "ActionName", &a.ActionName) - delete(rawMsg, key) - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &a.Status) - delete(rawMsg, key) - case "targets": - err = unpopulate(val, "Targets", &a.Targets) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Branch. -func (b Branch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "actions", b.Actions) - populate(objectMap, "name", b.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Branch. -func (b *Branch) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "actions": - b.Actions, err = unmarshalActionClassificationArray(val) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &b.Name) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ContinuousAction. -func (c ContinuousAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "duration", c.Duration) - populate(objectMap, "name", c.Name) - populate(objectMap, "parameters", c.Parameters) - populate(objectMap, "selectorId", c.SelectorID) - objectMap["type"] = "continuous" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ContinuousAction. -func (c *ContinuousAction) 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 "duration": - err = unpopulate(val, "Duration", &c.Duration) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &c.Parameters) - delete(rawMsg, key) - case "selectorId": - err = unpopulate(val, "SelectorID", &c.SelectorID) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) - 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 DelayAction. -func (d DelayAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "duration", d.Duration) - populate(objectMap, "name", d.Name) - objectMap["type"] = "delay" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DelayAction. -func (d *DelayAction) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "duration": - err = unpopulate(val, "Duration", &d.Duration) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DiscreteAction. -func (d DiscreteAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "name", d.Name) - populate(objectMap, "parameters", d.Parameters) - populate(objectMap, "selectorId", d.SelectorID) - objectMap["type"] = "discrete" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DiscreteAction. -func (d *DiscreteAction) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &d.Parameters) - delete(rawMsg, key) - case "selectorId": - err = unpopulate(val, "SelectorID", &d.SelectorID) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Experiment. -func (e Experiment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", e.ID) - populate(objectMap, "identity", e.Identity) - populate(objectMap, "location", e.Location) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "systemData", e.SystemData) - populate(objectMap, "tags", e.Tags) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionActionTargetDetailsProperties. -func (e *ExperimentExecutionActionTargetDetailsProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &e.Target) - delete(rawMsg, key) - case "targetCompletedTime": - err = unpopulateTimeRFC3339(val, "TargetCompletedTime", &e.TargetCompletedTime) - delete(rawMsg, key) - case "targetFailedTime": - err = unpopulateTimeRFC3339(val, "TargetFailedTime", &e.TargetFailedTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentExecutionDetailsProperties. -func (e *ExperimentExecutionDetailsProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdDateTime": - err = unpopulateTimeRFC3339(val, "CreatedDateTime", &e.CreatedDateTime) - delete(rawMsg, key) - case "experimentId": - err = unpopulate(val, "ExperimentID", &e.ExperimentID) - delete(rawMsg, key) - case "failureReason": - err = unpopulate(val, "FailureReason", &e.FailureReason) - delete(rawMsg, key) - case "lastActionDateTime": - err = unpopulateTimeRFC3339(val, "LastActionDateTime", &e.LastActionDateTime) - delete(rawMsg, key) - case "runInformation": - err = unpopulate(val, "RunInformation", &e.RunInformation) - delete(rawMsg, key) - case "startDateTime": - err = unpopulateTimeRFC3339(val, "StartDateTime", &e.StartDateTime) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - case "stopDateTime": - err = unpopulateTimeRFC3339(val, "StopDateTime", &e.StopDateTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExperimentProperties. -func (e ExperimentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "selectors", e.Selectors) - populate(objectMap, "startOnCreation", e.StartOnCreation) - populate(objectMap, "steps", e.Steps) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentStatusProperties. -func (e *ExperimentStatusProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdDateUtc": - err = unpopulateTimeRFC3339(val, "CreatedDateUTC", &e.CreatedDateUTC) - delete(rawMsg, key) - case "endDateUtc": - err = unpopulateTimeRFC3339(val, "EndDateUTC", &e.EndDateUTC) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Selector. -func (s Selector) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "targets", s.Targets) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Step. -func (s Step) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "branches", s.Branches) - populate(objectMap, "name", s.Name) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Target. -func (t Target) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "properties", t.Properties) - populate(objectMap, "systemData", t.SystemData) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TargetTypeProperties. -func (t TargetTypeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", t.Description) - populate(objectMap, "displayName", t.DisplayName) - populate(objectMap, "propertiesSchema", t.PropertiesSchema) - populate(objectMap, "resourceTypes", t.ResourceTypes) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -}