diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/CHANGELOG.md b/sdk/resourcemanager/solutions/armmanagedapplications/CHANGELOG.md index 1d566da3dda6..98bf13181f97 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/CHANGELOG.md +++ b/sdk/resourcemanager/solutions/armmanagedapplications/CHANGELOG.md @@ -1,5 +1,77 @@ # Release History +## 2.0.0 (2022-09-09) +### Breaking Changes + +- Function `*ApplicationsClient.Update` has been removed +- Function `*ApplicationDefinitionsClient.BeginCreateOrUpdate` has been removed +- Function `*ApplicationDefinitionsClient.BeginDelete` has been removed +- Struct `ApplicationDefinitionsClientBeginCreateOrUpdateOptions` has been removed +- Struct `ApplicationDefinitionsClientBeginDeleteOptions` has been removed +- Struct `ApplicationPropertiesPatchable` has been removed +- Struct `ApplicationsClientUpdateOptions` has been removed +- Field `ProvisioningState` of struct `ApplicationDefinitionProperties` has been removed + +### Features Added + +- New const `SubstatusApproved` +- New const `SubstatusFailed` +- New const `StatusElevate` +- New const `SubstatusDenied` +- New const `SubstatusTimeout` +- New const `StatusNotSpecified` +- New const `SubstatusExpired` +- New const `StatusRemove` +- New const `SubstatusNotSpecified` +- New type alias `Status` +- New type alias `Substatus` +- New function `*ApplicationDefinitionsClient.DeleteByID(context.Context, string, string, *ApplicationDefinitionsClientDeleteByIDOptions) (ApplicationDefinitionsClientDeleteByIDResponse, error)` +- New function `PossibleStatusValues() []Status` +- New function `*ApplicationDefinitionsClient.GetByID(context.Context, string, string, *ApplicationDefinitionsClientGetByIDOptions) (ApplicationDefinitionsClientGetByIDResponse, error)` +- New function `*ApplicationsClient.BeginCreateOrUpdateByID(context.Context, string, Application, *ApplicationsClientBeginCreateOrUpdateByIDOptions) (*runtime.Poller[ApplicationsClientCreateOrUpdateByIDResponse], error)` +- New function `*ApplicationsClient.ListTokens(context.Context, string, string, ListTokenRequest, *ApplicationsClientListTokensOptions) (ApplicationsClientListTokensResponse, error)` +- New function `*ApplicationDefinitionsClient.Delete(context.Context, string, string, *ApplicationDefinitionsClientDeleteOptions) (ApplicationDefinitionsClientDeleteResponse, error)` +- New function `*ApplicationDefinitionsClient.CreateOrUpdateByID(context.Context, string, string, ApplicationDefinition, *ApplicationDefinitionsClientCreateOrUpdateByIDOptions) (ApplicationDefinitionsClientCreateOrUpdateByIDResponse, error)` +- New function `*ApplicationsClient.BeginUpdateAccess(context.Context, string, string, UpdateAccessDefinition, *ApplicationsClientBeginUpdateAccessOptions) (*runtime.Poller[ApplicationsClientUpdateAccessResponse], error)` +- New function `*ApplicationDefinitionsClient.UpdateByID(context.Context, string, string, ApplicationDefinitionPatchable, *ApplicationDefinitionsClientUpdateByIDOptions) (ApplicationDefinitionsClientUpdateByIDResponse, error)` +- New function `*ApplicationsClient.GetByID(context.Context, string, *ApplicationsClientGetByIDOptions) (ApplicationsClientGetByIDResponse, error)` +- New function `*ApplicationsClient.BeginUpdate(context.Context, string, string, *ApplicationsClientBeginUpdateOptions) (*runtime.Poller[ApplicationsClientUpdateResponse], error)` +- New function `*ApplicationDefinitionsClient.CreateOrUpdate(context.Context, string, string, ApplicationDefinition, *ApplicationDefinitionsClientCreateOrUpdateOptions) (ApplicationDefinitionsClientCreateOrUpdateResponse, error)` +- New function `PossibleSubstatusValues() []Substatus` +- New function `*ApplicationsClient.BeginUpdateByID(context.Context, string, *ApplicationsClientBeginUpdateByIDOptions) (*runtime.Poller[ApplicationsClientUpdateByIDResponse], error)` +- New function `*ApplicationsClient.BeginDeleteByID(context.Context, string, *ApplicationsClientBeginDeleteByIDOptions) (*runtime.Poller[ApplicationsClientDeleteByIDResponse], error)` +- New struct `AllowedUpgradePlansResult` +- New struct `ApplicationDefinitionsClientCreateOrUpdateByIDOptions` +- New struct `ApplicationDefinitionsClientCreateOrUpdateByIDResponse` +- New struct `ApplicationDefinitionsClientCreateOrUpdateOptions` +- New struct `ApplicationDefinitionsClientDeleteByIDOptions` +- New struct `ApplicationDefinitionsClientDeleteByIDResponse` +- New struct `ApplicationDefinitionsClientDeleteOptions` +- New struct `ApplicationDefinitionsClientGetByIDOptions` +- New struct `ApplicationDefinitionsClientGetByIDResponse` +- New struct `ApplicationDefinitionsClientUpdateByIDOptions` +- New struct `ApplicationDefinitionsClientUpdateByIDResponse` +- New struct `ApplicationsClientBeginCreateOrUpdateByIDOptions` +- New struct `ApplicationsClientBeginDeleteByIDOptions` +- New struct `ApplicationsClientBeginUpdateAccessOptions` +- New struct `ApplicationsClientBeginUpdateByIDOptions` +- New struct `ApplicationsClientBeginUpdateOptions` +- New struct `ApplicationsClientCreateOrUpdateByIDResponse` +- New struct `ApplicationsClientDeleteByIDResponse` +- New struct `ApplicationsClientGetByIDOptions` +- New struct `ApplicationsClientGetByIDResponse` +- New struct `ApplicationsClientListTokensOptions` +- New struct `ApplicationsClientListTokensResponse` +- New struct `ApplicationsClientUpdateAccessResponse` +- New struct `ApplicationsClientUpdateByIDResponse` +- New struct `JitRequestMetadata` +- New struct `ListTokenRequest` +- New struct `ManagedIdentityToken` +- New struct `ManagedIdentityTokenResult` +- New struct `UpdateAccessDefinition` +- New anonymous field `AllowedUpgradePlansResult` in struct `ApplicationsClientListAllowedUpgradePlansResponse` + + ## 1.0.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/solutions/armmanagedapplications` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_application_client.go b/sdk/resourcemanager/solutions/armmanagedapplications/application_client.go similarity index 98% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_application_client.go rename to sdk/resourcemanager/solutions/armmanagedapplications/application_client.go index 10fac428525c..b632c1cbf44d 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_application_client.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/application_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 armmanagedapplications @@ -49,7 +50,6 @@ func NewApplicationClient(credential azcore.TokenCredential, options *arm.Client } // NewListOperationsPager - Lists all of the available Microsoft.Solutions REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // options - ApplicationClientListOperationsOptions contains the optional parameters for the ApplicationClient.ListOperations // method. diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_applicationdefinitions_client.go b/sdk/resourcemanager/solutions/armmanagedapplications/applicationdefinitions_client.go similarity index 57% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_applicationdefinitions_client.go rename to sdk/resourcemanager/solutions/armmanagedapplications/applicationdefinitions_client.go index 31520a6f7960..113d80ea376d 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_applicationdefinitions_client.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/applicationdefinitions_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 armmanagedapplications @@ -54,48 +55,31 @@ func NewApplicationDefinitionsClient(subscriptionID string, credential azcore.To return client, nil } -// BeginCreateOrUpdate - Creates a new managed application definition. +// CreateOrUpdate - Creates or updates a managed application definition. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // resourceGroupName - The name of the resource group. The name is case insensitive. // applicationDefinitionName - The name of the managed application definition. // parameters - Parameters supplied to the create or update an managed application definition. -// options - ApplicationDefinitionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginCreateOrUpdate +// options - ApplicationDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the ApplicationDefinitionsClient.CreateOrUpdate // method. -func (client *ApplicationDefinitionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ApplicationDefinitionsClientCreateOrUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, applicationDefinitionName, parameters, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ApplicationDefinitionsClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[ApplicationDefinitionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) - } -} - -// CreateOrUpdate - Creates a new managed application definition. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2021-07-01 -func (client *ApplicationDefinitionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +func (client *ApplicationDefinitionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientCreateOrUpdateOptions) (ApplicationDefinitionsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, applicationDefinitionName, parameters, options) if err != nil { - return nil, err + return ApplicationDefinitionsClientCreateOrUpdateResponse{}, err } resp, err := client.pl.Do(req) if err != nil { - return nil, err + return ApplicationDefinitionsClientCreateOrUpdateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + return ApplicationDefinitionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) } - return resp, nil + return client.createOrUpdateHandleResponse(resp) } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ApplicationDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -120,45 +104,97 @@ func (client *ApplicationDefinitionsClient) createOrUpdateCreateRequest(ctx cont return req, runtime.MarshalAsJSON(req, parameters) } -// BeginDelete - Deletes the managed application definition. +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ApplicationDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (ApplicationDefinitionsClientCreateOrUpdateResponse, error) { + result := ApplicationDefinitionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationDefinition); err != nil { + return ApplicationDefinitionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// CreateOrUpdateByID - Creates or updates a managed application definition. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // resourceGroupName - The name of the resource group. The name is case insensitive. // applicationDefinitionName - The name of the managed application definition. -// options - ApplicationDefinitionsClientBeginDeleteOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginDelete +// parameters - Parameters supplied to the create or update a managed application definition. +// options - ApplicationDefinitionsClientCreateOrUpdateByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.CreateOrUpdateByID // method. -func (client *ApplicationDefinitionsClient) BeginDelete(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientBeginDeleteOptions) (*runtime.Poller[ApplicationDefinitionsClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceGroupName, applicationDefinitionName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller[ApplicationDefinitionsClientDeleteResponse](resp, client.pl, nil) - } else { - return runtime.NewPollerFromResumeToken[ApplicationDefinitionsClientDeleteResponse](options.ResumeToken, client.pl, nil) +func (client *ApplicationDefinitionsClient) CreateOrUpdateByID(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientCreateOrUpdateByIDOptions) (ApplicationDefinitionsClientCreateOrUpdateByIDResponse, error) { + req, err := client.createOrUpdateByIDCreateRequest(ctx, resourceGroupName, applicationDefinitionName, parameters, options) + if err != nil { + return ApplicationDefinitionsClientCreateOrUpdateByIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ApplicationDefinitionsClientCreateOrUpdateByIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return ApplicationDefinitionsClientCreateOrUpdateByIDResponse{}, runtime.NewResponseError(resp) } + return client.createOrUpdateByIDHandleResponse(resp) +} + +// createOrUpdateByIDCreateRequest creates the CreateOrUpdateByID request. +func (client *ApplicationDefinitionsClient) createOrUpdateByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinition, options *ApplicationDefinitionsClientCreateOrUpdateByIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if applicationDefinitionName == "" { + return nil, errors.New("parameter applicationDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationDefinitionName}", url.PathEscape(applicationDefinitionName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateByIDHandleResponse handles the CreateOrUpdateByID response. +func (client *ApplicationDefinitionsClient) createOrUpdateByIDHandleResponse(resp *http.Response) (ApplicationDefinitionsClientCreateOrUpdateByIDResponse, error) { + result := ApplicationDefinitionsClientCreateOrUpdateByIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationDefinition); err != nil { + return ApplicationDefinitionsClientCreateOrUpdateByIDResponse{}, err + } + return result, nil } // Delete - Deletes the managed application definition. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 -func (client *ApplicationDefinitionsClient) deleteOperation(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientBeginDeleteOptions) (*http.Response, error) { +// resourceGroupName - The name of the resource group. The name is case insensitive. +// applicationDefinitionName - The name of the managed application definition. +// options - ApplicationDefinitionsClientDeleteOptions contains the optional parameters for the ApplicationDefinitionsClient.Delete +// method. +func (client *ApplicationDefinitionsClient) Delete(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientDeleteOptions) (ApplicationDefinitionsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, applicationDefinitionName, options) if err != nil { - return nil, err + return ApplicationDefinitionsClientDeleteResponse{}, err } resp, err := client.pl.Do(req) if err != nil { - return nil, err + return ApplicationDefinitionsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ApplicationDefinitionsClientDeleteResponse{}, runtime.NewResponseError(resp) } - return resp, nil + return ApplicationDefinitionsClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. -func (client *ApplicationDefinitionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientBeginDeleteOptions) (*policy.Request, error) { +func (client *ApplicationDefinitionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -183,6 +219,54 @@ func (client *ApplicationDefinitionsClient) deleteCreateRequest(ctx context.Cont return req, nil } +// DeleteByID - Deletes the managed application definition. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// applicationDefinitionName - The name of the managed application definition. +// options - ApplicationDefinitionsClientDeleteByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.DeleteByID +// method. +func (client *ApplicationDefinitionsClient) DeleteByID(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientDeleteByIDOptions) (ApplicationDefinitionsClientDeleteByIDResponse, error) { + req, err := client.deleteByIDCreateRequest(ctx, resourceGroupName, applicationDefinitionName, options) + if err != nil { + return ApplicationDefinitionsClientDeleteByIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ApplicationDefinitionsClientDeleteByIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ApplicationDefinitionsClientDeleteByIDResponse{}, runtime.NewResponseError(resp) + } + return ApplicationDefinitionsClientDeleteByIDResponse{}, nil +} + +// deleteByIDCreateRequest creates the DeleteByID request. +func (client *ApplicationDefinitionsClient) deleteByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientDeleteByIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if applicationDefinitionName == "" { + return nil, errors.New("parameter applicationDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationDefinitionName}", url.PathEscape(applicationDefinitionName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // Get - Gets the managed application definition. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 @@ -199,7 +283,7 @@ func (client *ApplicationDefinitionsClient) Get(ctx context.Context, resourceGro if err != nil { return ApplicationDefinitionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNotFound) { return ApplicationDefinitionsClientGetResponse{}, runtime.NewResponseError(resp) } return client.getHandleResponse(resp) @@ -240,10 +324,66 @@ func (client *ApplicationDefinitionsClient) getHandleResponse(resp *http.Respons return result, nil } -// NewListByResourceGroupPager - Lists the managed application definitions in a resource group. +// GetByID - Gets the managed application definition. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // resourceGroupName - The name of the resource group. The name is case insensitive. +// applicationDefinitionName - The name of the managed application definition. +// options - ApplicationDefinitionsClientGetByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.GetByID +// method. +func (client *ApplicationDefinitionsClient) GetByID(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientGetByIDOptions) (ApplicationDefinitionsClientGetByIDResponse, error) { + req, err := client.getByIDCreateRequest(ctx, resourceGroupName, applicationDefinitionName, options) + if err != nil { + return ApplicationDefinitionsClientGetByIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ApplicationDefinitionsClientGetByIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNotFound) { + return ApplicationDefinitionsClientGetByIDResponse{}, runtime.NewResponseError(resp) + } + return client.getByIDHandleResponse(resp) +} + +// getByIDCreateRequest creates the GetByID request. +func (client *ApplicationDefinitionsClient) getByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, options *ApplicationDefinitionsClientGetByIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if applicationDefinitionName == "" { + return nil, errors.New("parameter applicationDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationDefinitionName}", url.PathEscape(applicationDefinitionName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByIDHandleResponse handles the GetByID response. +func (client *ApplicationDefinitionsClient) getByIDHandleResponse(resp *http.Response) (ApplicationDefinitionsClientGetByIDResponse, error) { + result := ApplicationDefinitionsClientGetByIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationDefinition); err != nil { + return ApplicationDefinitionsClientGetByIDResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists the managed application definitions in a resource group. +// Generated from API version 2021-07-01 +// resourceGroupName - The name of the resource group. The name is case insensitive. // options - ApplicationDefinitionsClientListByResourceGroupOptions contains the optional parameters for the ApplicationDefinitionsClient.ListByResourceGroup // method. func (client *ApplicationDefinitionsClient) NewListByResourceGroupPager(resourceGroupName string, options *ApplicationDefinitionsClientListByResourceGroupOptions) *runtime.Pager[ApplicationDefinitionsClientListByResourceGroupResponse] { @@ -305,8 +445,7 @@ func (client *ApplicationDefinitionsClient) listByResourceGroupHandleResponse(re return result, nil } -// NewListBySubscriptionPager - Gets all the application definitions within a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListBySubscriptionPager - Lists all the application definitions within a subscription. // Generated from API version 2021-07-01 // options - ApplicationDefinitionsClientListBySubscriptionOptions contains the optional parameters for the ApplicationDefinitionsClient.ListBySubscription // method. @@ -422,3 +561,61 @@ func (client *ApplicationDefinitionsClient) updateHandleResponse(resp *http.Resp } return result, nil } + +// UpdateByID - Updates the managed application definition. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// applicationDefinitionName - The name of the managed application definition. +// parameters - Parameters supplied to the update a managed application definition. +// options - ApplicationDefinitionsClientUpdateByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.UpdateByID +// method. +func (client *ApplicationDefinitionsClient) UpdateByID(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinitionPatchable, options *ApplicationDefinitionsClientUpdateByIDOptions) (ApplicationDefinitionsClientUpdateByIDResponse, error) { + req, err := client.updateByIDCreateRequest(ctx, resourceGroupName, applicationDefinitionName, parameters, options) + if err != nil { + return ApplicationDefinitionsClientUpdateByIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ApplicationDefinitionsClientUpdateByIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ApplicationDefinitionsClientUpdateByIDResponse{}, runtime.NewResponseError(resp) + } + return client.updateByIDHandleResponse(resp) +} + +// updateByIDCreateRequest creates the UpdateByID request. +func (client *ApplicationDefinitionsClient) updateByIDCreateRequest(ctx context.Context, resourceGroupName string, applicationDefinitionName string, parameters ApplicationDefinitionPatchable, options *ApplicationDefinitionsClientUpdateByIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}" + 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 applicationDefinitionName == "" { + return nil, errors.New("parameter applicationDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationDefinitionName}", url.PathEscape(applicationDefinitionName)) + 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", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateByIDHandleResponse handles the UpdateByID response. +func (client *ApplicationDefinitionsClient) updateByIDHandleResponse(resp *http.Response) (ApplicationDefinitionsClientUpdateByIDResponse, error) { + result := ApplicationDefinitionsClientUpdateByIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationDefinition); err != nil { + return ApplicationDefinitionsClientUpdateByIDResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_applications_client.go b/sdk/resourcemanager/solutions/armmanagedapplications/applications_client.go similarity index 56% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_applications_client.go rename to sdk/resourcemanager/solutions/armmanagedapplications/applications_client.go index 528fcf4196be..26962357573a 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_applications_client.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/applications_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 armmanagedapplications @@ -54,7 +55,7 @@ func NewApplicationsClient(subscriptionID string, credential azcore.TokenCredent return client, nil } -// BeginCreateOrUpdate - Creates a new managed application. +// BeginCreateOrUpdate - Creates or updates a managed application. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // resourceGroupName - The name of the resource group. The name is case insensitive. @@ -76,7 +77,7 @@ func (client *ApplicationsClient) BeginCreateOrUpdate(ctx context.Context, resou } } -// CreateOrUpdate - Creates a new managed application. +// CreateOrUpdate - Creates or updates a managed application. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 func (client *ApplicationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, applicationName string, parameters Application, options *ApplicationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { @@ -120,6 +121,62 @@ func (client *ApplicationsClient) createOrUpdateCreateRequest(ctx context.Contex return req, runtime.MarshalAsJSON(req, parameters) } +// BeginCreateOrUpdateByID - Creates or updates a managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// applicationID - The fully qualified ID of the managed application, including the managed application name and the managed +// application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +// parameters - Parameters supplied to the create or update a managed application. +// options - ApplicationsClientBeginCreateOrUpdateByIDOptions contains the optional parameters for the ApplicationsClient.BeginCreateOrUpdateByID +// method. +func (client *ApplicationsClient) BeginCreateOrUpdateByID(ctx context.Context, applicationID string, parameters Application, options *ApplicationsClientBeginCreateOrUpdateByIDOptions) (*runtime.Poller[ApplicationsClientCreateOrUpdateByIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateByID(ctx, applicationID, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ApplicationsClientCreateOrUpdateByIDResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ApplicationsClientCreateOrUpdateByIDResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdateByID - Creates or updates a managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +func (client *ApplicationsClient) createOrUpdateByID(ctx context.Context, applicationID string, parameters Application, options *ApplicationsClientBeginCreateOrUpdateByIDOptions) (*http.Response, error) { + req, err := client.createOrUpdateByIDCreateRequest(ctx, applicationID, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateByIDCreateRequest creates the CreateOrUpdateByID request. +func (client *ApplicationsClient) createOrUpdateByIDCreateRequest(ctx context.Context, applicationID string, parameters Application, options *ApplicationsClientBeginCreateOrUpdateByIDOptions) (*policy.Request, error) { + urlPath := "/{applicationId}" + urlPath = strings.ReplaceAll(urlPath, "{applicationId}", applicationID) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + // BeginDelete - Deletes the managed application. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 @@ -153,7 +210,7 @@ func (client *ApplicationsClient) deleteOperation(ctx context.Context, resourceG if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { return nil, runtime.NewResponseError(resp) } return resp, nil @@ -185,6 +242,61 @@ func (client *ApplicationsClient) deleteCreateRequest(ctx context.Context, resou return req, nil } +// BeginDeleteByID - Deletes the managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// applicationID - The fully qualified ID of the managed application, including the managed application name and the managed +// application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +// options - ApplicationsClientBeginDeleteByIDOptions contains the optional parameters for the ApplicationsClient.BeginDeleteByID +// method. +func (client *ApplicationsClient) BeginDeleteByID(ctx context.Context, applicationID string, options *ApplicationsClientBeginDeleteByIDOptions) (*runtime.Poller[ApplicationsClientDeleteByIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteByID(ctx, applicationID, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ApplicationsClientDeleteByIDResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ApplicationsClientDeleteByIDResponse](options.ResumeToken, client.pl, nil) + } +} + +// DeleteByID - Deletes the managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +func (client *ApplicationsClient) deleteByID(ctx context.Context, applicationID string, options *ApplicationsClientBeginDeleteByIDOptions) (*http.Response, error) { + req, err := client.deleteByIDCreateRequest(ctx, applicationID, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteByIDCreateRequest creates the DeleteByID request. +func (client *ApplicationsClient) deleteByIDCreateRequest(ctx context.Context, applicationID string, options *ApplicationsClientBeginDeleteByIDOptions) (*policy.Request, error) { + urlPath := "/{applicationId}" + urlPath = strings.ReplaceAll(urlPath, "{applicationId}", applicationID) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // Get - Gets the managed application. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 @@ -200,7 +312,7 @@ func (client *ApplicationsClient) Get(ctx context.Context, resourceGroupName str if err != nil { return ApplicationsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNotFound) { return ApplicationsClientGetResponse{}, runtime.NewResponseError(resp) } return client.getHandleResponse(resp) @@ -241,6 +353,52 @@ func (client *ApplicationsClient) getHandleResponse(resp *http.Response) (Applic return result, nil } +// GetByID - Gets the managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// applicationID - The fully qualified ID of the managed application, including the managed application name and the managed +// application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +// options - ApplicationsClientGetByIDOptions contains the optional parameters for the ApplicationsClient.GetByID method. +func (client *ApplicationsClient) GetByID(ctx context.Context, applicationID string, options *ApplicationsClientGetByIDOptions) (ApplicationsClientGetByIDResponse, error) { + req, err := client.getByIDCreateRequest(ctx, applicationID, options) + if err != nil { + return ApplicationsClientGetByIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ApplicationsClientGetByIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNotFound) { + return ApplicationsClientGetByIDResponse{}, runtime.NewResponseError(resp) + } + return client.getByIDHandleResponse(resp) +} + +// getByIDCreateRequest creates the GetByID request. +func (client *ApplicationsClient) getByIDCreateRequest(ctx context.Context, applicationID string, options *ApplicationsClientGetByIDOptions) (*policy.Request, error) { + urlPath := "/{applicationId}" + urlPath = strings.ReplaceAll(urlPath, "{applicationId}", applicationID) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByIDHandleResponse handles the GetByID response. +func (client *ApplicationsClient) getByIDHandleResponse(resp *http.Response) (ApplicationsClientGetByIDResponse, error) { + result := ApplicationsClientGetByIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Application); err != nil { + return ApplicationsClientGetByIDResponse{}, err + } + return result, nil +} + // ListAllowedUpgradePlans - List allowed upgrade plans for application. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 @@ -260,7 +418,7 @@ func (client *ApplicationsClient) ListAllowedUpgradePlans(ctx context.Context, r if !runtime.HasStatusCode(resp, http.StatusOK) { return ApplicationsClientListAllowedUpgradePlansResponse{}, runtime.NewResponseError(resp) } - return ApplicationsClientListAllowedUpgradePlansResponse{}, nil + return client.listAllowedUpgradePlansHandleResponse(resp) } // listAllowedUpgradePlansCreateRequest creates the ListAllowedUpgradePlans request. @@ -289,8 +447,16 @@ func (client *ApplicationsClient) listAllowedUpgradePlansCreateRequest(ctx conte return req, nil } -// NewListByResourceGroupPager - Gets all the applications within a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// listAllowedUpgradePlansHandleResponse handles the ListAllowedUpgradePlans response. +func (client *ApplicationsClient) listAllowedUpgradePlansHandleResponse(resp *http.Response) (ApplicationsClientListAllowedUpgradePlansResponse, error) { + result := ApplicationsClientListAllowedUpgradePlansResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AllowedUpgradePlansResult); err != nil { + return ApplicationsClientListAllowedUpgradePlansResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists all the applications within a resource group. // Generated from API version 2021-07-01 // resourceGroupName - The name of the resource group. The name is case insensitive. // options - ApplicationsClientListByResourceGroupOptions contains the optional parameters for the ApplicationsClient.ListByResourceGroup @@ -354,8 +520,7 @@ func (client *ApplicationsClient) listByResourceGroupHandleResponse(resp *http.R return result, nil } -// NewListBySubscriptionPager - Gets all the applications within a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListBySubscriptionPager - Lists all the applications within a subscription. // Generated from API version 2021-07-01 // options - ApplicationsClientListBySubscriptionOptions contains the optional parameters for the ApplicationsClient.ListBySubscription // method. @@ -414,6 +579,63 @@ func (client *ApplicationsClient) listBySubscriptionHandleResponse(resp *http.Re return result, nil } +// ListTokens - List tokens for application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// applicationName - The name of the managed application. +// parameters - Request body parameters to list tokens. +// options - ApplicationsClientListTokensOptions contains the optional parameters for the ApplicationsClient.ListTokens method. +func (client *ApplicationsClient) ListTokens(ctx context.Context, resourceGroupName string, applicationName string, parameters ListTokenRequest, options *ApplicationsClientListTokensOptions) (ApplicationsClientListTokensResponse, error) { + req, err := client.listTokensCreateRequest(ctx, resourceGroupName, applicationName, parameters, options) + if err != nil { + return ApplicationsClientListTokensResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ApplicationsClientListTokensResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ApplicationsClientListTokensResponse{}, runtime.NewResponseError(resp) + } + return client.listTokensHandleResponse(resp) +} + +// listTokensCreateRequest creates the ListTokens request. +func (client *ApplicationsClient) listTokensCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, parameters ListTokenRequest, options *ApplicationsClientListTokensOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/listTokens" + 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 applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// listTokensHandleResponse handles the ListTokens response. +func (client *ApplicationsClient) listTokensHandleResponse(resp *http.Response) (ApplicationsClientListTokensResponse, error) { + result := ApplicationsClientListTokensResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ManagedIdentityTokenResult); err != nil { + return ApplicationsClientListTokensResponse{}, err + } + return result, nil +} + // BeginRefreshPermissions - Refresh Permissions for application. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 @@ -427,7 +649,9 @@ func (client *ApplicationsClient) BeginRefreshPermissions(ctx context.Context, r if err != nil { return nil, err } - return runtime.NewPoller[ApplicationsClientRefreshPermissionsResponse](resp, client.pl, nil) + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ApplicationsClientRefreshPermissionsResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) } else { return runtime.NewPollerFromResumeToken[ApplicationsClientRefreshPermissionsResponse](options.ResumeToken, client.pl, nil) } @@ -477,29 +701,47 @@ func (client *ApplicationsClient) refreshPermissionsCreateRequest(ctx context.Co return req, nil } -// Update - Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. +// BeginUpdate - Updates an existing managed application. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // resourceGroupName - The name of the resource group. The name is case insensitive. // applicationName - The name of the managed application. -// options - ApplicationsClientUpdateOptions contains the optional parameters for the ApplicationsClient.Update method. -func (client *ApplicationsClient) Update(ctx context.Context, resourceGroupName string, applicationName string, options *ApplicationsClientUpdateOptions) (ApplicationsClientUpdateResponse, error) { +// options - ApplicationsClientBeginUpdateOptions contains the optional parameters for the ApplicationsClient.BeginUpdate +// method. +func (client *ApplicationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, applicationName string, options *ApplicationsClientBeginUpdateOptions) (*runtime.Poller[ApplicationsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, applicationName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ApplicationsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ApplicationsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates an existing managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +func (client *ApplicationsClient) update(ctx context.Context, resourceGroupName string, applicationName string, options *ApplicationsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, applicationName, options) if err != nil { - return ApplicationsClientUpdateResponse{}, err + return nil, err } resp, err := client.pl.Do(req) if err != nil { - return ApplicationsClientUpdateResponse{}, err + return nil, err } if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return ApplicationsClientUpdateResponse{}, runtime.NewResponseError(resp) + return nil, runtime.NewResponseError(resp) } - return client.updateHandleResponse(resp) + return resp, nil } // updateCreateRequest creates the Update request. -func (client *ApplicationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, options *ApplicationsClientUpdateOptions) (*policy.Request, error) { +func (client *ApplicationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, options *ApplicationsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -527,11 +769,126 @@ func (client *ApplicationsClient) updateCreateRequest(ctx context.Context, resou return req, nil } -// updateHandleResponse handles the Update response. -func (client *ApplicationsClient) updateHandleResponse(resp *http.Response) (ApplicationsClientUpdateResponse, error) { - result := ApplicationsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Application); err != nil { - return ApplicationsClientUpdateResponse{}, err +// BeginUpdateAccess - Update access for application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// applicationName - The name of the managed application. +// parameters - Request body parameters to list tokens. +// options - ApplicationsClientBeginUpdateAccessOptions contains the optional parameters for the ApplicationsClient.BeginUpdateAccess +// method. +func (client *ApplicationsClient) BeginUpdateAccess(ctx context.Context, resourceGroupName string, applicationName string, parameters UpdateAccessDefinition, options *ApplicationsClientBeginUpdateAccessOptions) (*runtime.Poller[ApplicationsClientUpdateAccessResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.updateAccess(ctx, resourceGroupName, applicationName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ApplicationsClientUpdateAccessResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[ApplicationsClientUpdateAccessResponse](options.ResumeToken, client.pl, nil) } - return result, nil +} + +// UpdateAccess - Update access for application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +func (client *ApplicationsClient) updateAccess(ctx context.Context, resourceGroupName string, applicationName string, parameters UpdateAccessDefinition, options *ApplicationsClientBeginUpdateAccessOptions) (*http.Response, error) { + req, err := client.updateAccessCreateRequest(ctx, resourceGroupName, applicationName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateAccessCreateRequest creates the UpdateAccess request. +func (client *ApplicationsClient) updateAccessCreateRequest(ctx context.Context, resourceGroupName string, applicationName string, parameters UpdateAccessDefinition, options *ApplicationsClientBeginUpdateAccessOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}/updateAccess" + 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 applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginUpdateByID - Updates an existing managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +// applicationID - The fully qualified ID of the managed application, including the managed application name and the managed +// application resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} +// options - ApplicationsClientBeginUpdateByIDOptions contains the optional parameters for the ApplicationsClient.BeginUpdateByID +// method. +func (client *ApplicationsClient) BeginUpdateByID(ctx context.Context, applicationID string, options *ApplicationsClientBeginUpdateByIDOptions) (*runtime.Poller[ApplicationsClientUpdateByIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.updateByID(ctx, applicationID, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ApplicationsClientUpdateByIDResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ApplicationsClientUpdateByIDResponse](options.ResumeToken, client.pl, nil) + } +} + +// UpdateByID - Updates an existing managed application. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-07-01 +func (client *ApplicationsClient) updateByID(ctx context.Context, applicationID string, options *ApplicationsClientBeginUpdateByIDOptions) (*http.Response, error) { + req, err := client.updateByIDCreateRequest(ctx, applicationID, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateByIDCreateRequest creates the UpdateByID request. +func (client *ApplicationsClient) updateByIDCreateRequest(ctx context.Context, applicationID string, options *ApplicationsClientBeginUpdateByIDOptions) (*policy.Request, error) { + urlPath := "/{applicationId}" + urlPath = strings.ReplaceAll(urlPath, "{applicationId}", applicationID) + 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", "2021-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Parameters != nil { + return req, runtime.MarshalAsJSON(req, *options.Parameters) + } + return req, nil } diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/autorest.md b/sdk/resourcemanager/solutions/armmanagedapplications/autorest.md index 43bbc49df8d2..59b31ed3cc39 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/autorest.md +++ b/sdk/resourcemanager/solutions/armmanagedapplications/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/solutions/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/solutions/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/solutions/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/solutions/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 2.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_constants.go b/sdk/resourcemanager/solutions/armmanagedapplications/constants.go similarity index 91% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_constants.go rename to sdk/resourcemanager/solutions/armmanagedapplications/constants.go index 3b8adeca11aa..09b5e6053e98 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_constants.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/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 armmanagedapplications const ( moduleName = "armmanagedapplications" - moduleVersion = "v1.0.0" + moduleVersion = "v2.0.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -307,3 +308,45 @@ func PossibleResourceIdentityTypeValues() []ResourceIdentityType { ResourceIdentityTypeNone, } } + +// Status - The JIT status. +type Status string + +const ( + StatusElevate Status = "Elevate" + StatusNotSpecified Status = "NotSpecified" + StatusRemove Status = "Remove" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusElevate, + StatusNotSpecified, + StatusRemove, + } +} + +// Substatus - The sub status. +type Substatus string + +const ( + SubstatusApproved Substatus = "Approved" + SubstatusDenied Substatus = "Denied" + SubstatusExpired Substatus = "Expired" + SubstatusFailed Substatus = "Failed" + SubstatusNotSpecified Substatus = "NotSpecified" + SubstatusTimeout Substatus = "Timeout" +) + +// PossibleSubstatusValues returns the possible values for the Substatus const type. +func PossibleSubstatusValues() []Substatus { + return []Substatus{ + SubstatusApproved, + SubstatusDenied, + SubstatusExpired, + SubstatusFailed, + SubstatusNotSpecified, + SubstatusTimeout, + } +} diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/go.mod b/sdk/resourcemanager/solutions/armmanagedapplications/go.mod index a9a9939da1b4..7fa33d6d17d4 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/go.mod +++ b/sdk/resourcemanager/solutions/armmanagedapplications/go.mod @@ -1,21 +1,13 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/solutions/armmanagedapplications +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/solutions/armmanagedapplications/v2 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/solutions/armmanagedapplications/go.sum b/sdk/resourcemanager/solutions/armmanagedapplications/go.sum index ed5b814680ee..3afb578030a5 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/go.sum +++ b/sdk/resourcemanager/solutions/armmanagedapplications/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/solutions/armmanagedapplications/zz_generated_jitrequests_client.go b/sdk/resourcemanager/solutions/armmanagedapplications/jitrequests_client.go similarity index 98% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_jitrequests_client.go rename to sdk/resourcemanager/solutions/armmanagedapplications/jitrequests_client.go index d0a2dbdfcaec..ecbdacc37107 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_jitrequests_client.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/jitrequests_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 armmanagedapplications @@ -182,7 +183,7 @@ func (client *JitRequestsClient) Get(ctx context.Context, resourceGroupName stri if err != nil { return JitRequestsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNotFound) { return JitRequestsClientGetResponse{}, runtime.NewResponseError(resp) } return client.getHandleResponse(resp) @@ -223,7 +224,7 @@ func (client *JitRequestsClient) getHandleResponse(resp *http.Response) (JitRequ return result, nil } -// ListByResourceGroup - Retrieves all JIT requests within the resource group. +// ListByResourceGroup - Lists all JIT requests within the resource group. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // resourceGroupName - The name of the resource group. The name is case insensitive. @@ -275,7 +276,7 @@ func (client *JitRequestsClient) listByResourceGroupHandleResponse(resp *http.Re return result, nil } -// ListBySubscription - Retrieves all JIT requests within the subscription. +// ListBySubscription - Lists all JIT requests within the subscription. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-07-01 // options - JitRequestsClientListBySubscriptionOptions contains the optional parameters for the JitRequestsClient.ListBySubscription diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_models.go b/sdk/resourcemanager/solutions/armmanagedapplications/models.go similarity index 84% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_models.go rename to sdk/resourcemanager/solutions/armmanagedapplications/models.go index f19ff47ef600..0abb7d690b25 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_models.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/models.go @@ -5,11 +5,18 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armmanagedapplications import "time" +// AllowedUpgradePlansResult - The array of plan. +type AllowedUpgradePlansResult struct { + // The array of plans. + Value []*Plan `json:"value,omitempty"` +} + // Application - Information about managed application. type Application struct { // REQUIRED; The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. @@ -202,23 +209,36 @@ type ApplicationDefinitionProperties struct { // The storage account id for bring your own storage scenario. StorageAccountID *string `json:"storageAccountId,omitempty"` +} - // READ-ONLY; Provisioning state. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +// ApplicationDefinitionsClientCreateOrUpdateByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.CreateOrUpdateByID +// method. +type ApplicationDefinitionsClientCreateOrUpdateByIDOptions struct { + // placeholder for future optional parameters } -// ApplicationDefinitionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginCreateOrUpdate +// ApplicationDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the ApplicationDefinitionsClient.CreateOrUpdate // method. -type ApplicationDefinitionsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string +type ApplicationDefinitionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters } -// ApplicationDefinitionsClientBeginDeleteOptions contains the optional parameters for the ApplicationDefinitionsClient.BeginDelete +// ApplicationDefinitionsClientDeleteByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.DeleteByID // method. -type ApplicationDefinitionsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string +type ApplicationDefinitionsClientDeleteByIDOptions struct { + // placeholder for future optional parameters +} + +// ApplicationDefinitionsClientDeleteOptions contains the optional parameters for the ApplicationDefinitionsClient.Delete +// method. +type ApplicationDefinitionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ApplicationDefinitionsClientGetByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.GetByID +// method. +type ApplicationDefinitionsClientGetByIDOptions struct { + // placeholder for future optional parameters } // ApplicationDefinitionsClientGetOptions contains the optional parameters for the ApplicationDefinitionsClient.Get method. @@ -238,6 +258,12 @@ type ApplicationDefinitionsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } +// ApplicationDefinitionsClientUpdateByIDOptions contains the optional parameters for the ApplicationDefinitionsClient.UpdateByID +// method. +type ApplicationDefinitionsClientUpdateByIDOptions struct { + // placeholder for future optional parameters +} + // ApplicationDefinitionsClientUpdateOptions contains the optional parameters for the ApplicationDefinitionsClient.Update // method. type ApplicationDefinitionsClientUpdateOptions struct { @@ -421,22 +447,11 @@ type ApplicationProperties struct { UpdatedBy *ApplicationClientDetails `json:"updatedBy,omitempty" azure:"ro"` } -// ApplicationPropertiesPatchable - The managed application properties. -type ApplicationPropertiesPatchable struct { - // The fully qualified path of managed application definition Id. - ApplicationDefinitionID *string `json:"applicationDefinitionId,omitempty"` - - // The managed resource group Id. - ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"` - - // Name and value pairs that define the managed application parameters. It can be a JObject or a well formed JSON string. - Parameters interface{} `json:"parameters,omitempty"` - - // READ-ONLY; Name and value pairs that define the managed application outputs. - Outputs interface{} `json:"outputs,omitempty" azure:"ro"` - - // READ-ONLY; The managed application provisioning state. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +// ApplicationsClientBeginCreateOrUpdateByIDOptions contains the optional parameters for the ApplicationsClient.BeginCreateOrUpdateByID +// method. +type ApplicationsClientBeginCreateOrUpdateByIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // ApplicationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ApplicationsClient.BeginCreateOrUpdate @@ -446,6 +461,12 @@ type ApplicationsClientBeginCreateOrUpdateOptions struct { ResumeToken string } +// ApplicationsClientBeginDeleteByIDOptions contains the optional parameters for the ApplicationsClient.BeginDeleteByID method. +type ApplicationsClientBeginDeleteByIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // ApplicationsClientBeginDeleteOptions contains the optional parameters for the ApplicationsClient.BeginDelete method. type ApplicationsClientBeginDeleteOptions struct { // Resumes the LRO from the provided token. @@ -459,6 +480,34 @@ type ApplicationsClientBeginRefreshPermissionsOptions struct { ResumeToken string } +// ApplicationsClientBeginUpdateAccessOptions contains the optional parameters for the ApplicationsClient.BeginUpdateAccess +// method. +type ApplicationsClientBeginUpdateAccessOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ApplicationsClientBeginUpdateByIDOptions contains the optional parameters for the ApplicationsClient.BeginUpdateByID method. +type ApplicationsClientBeginUpdateByIDOptions struct { + // Parameters supplied to update an existing managed application. + Parameters *ApplicationPatchable + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ApplicationsClientBeginUpdateOptions contains the optional parameters for the ApplicationsClient.BeginUpdate method. +type ApplicationsClientBeginUpdateOptions struct { + // Parameters supplied to update an existing managed application. + Parameters *ApplicationPatchable + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ApplicationsClientGetByIDOptions contains the optional parameters for the ApplicationsClient.GetByID method. +type ApplicationsClientGetByIDOptions struct { + // placeholder for future optional parameters +} + // ApplicationsClientGetOptions contains the optional parameters for the ApplicationsClient.Get method. type ApplicationsClientGetOptions struct { // placeholder for future optional parameters @@ -482,10 +531,9 @@ type ApplicationsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } -// ApplicationsClientUpdateOptions contains the optional parameters for the ApplicationsClient.Update method. -type ApplicationsClientUpdateOptions struct { - // Parameters supplied to update an existing managed application. - Parameters *ApplicationPatchable +// ApplicationsClientListTokensOptions contains the optional parameters for the ApplicationsClient.ListTokens method. +type ApplicationsClientListTokensOptions struct { + // placeholder for future optional parameters } // ErrorAdditionalInfo - The resource management error additional info. @@ -620,6 +668,21 @@ type JitRequestDefinitionListResult struct { Value []*JitRequestDefinition `json:"value,omitempty"` } +// JitRequestMetadata - The JIT request metadata. +type JitRequestMetadata struct { + // The origin request id. + OriginRequestID *string `json:"originRequestId,omitempty"` + + // The requestor id. + RequestorID *string `json:"requestorId,omitempty"` + + // The subject display name. + SubjectDisplayName *string `json:"subjectDisplayName,omitempty"` + + // The publisher's tenant name. + TenantDisplayName *string `json:"tenantDisplayName,omitempty"` +} + // JitRequestPatchable - Information about JIT request. type JitRequestPatchable struct { // Jit request tags @@ -699,6 +762,45 @@ type JitSchedulingPolicy struct { Type *JitSchedulingType `json:"type,omitempty"` } +// ListTokenRequest - List token request body. +type ListTokenRequest struct { + // The authorization audience. + AuthorizationAudience *string `json:"authorizationAudience,omitempty"` + + // The user assigned identities. + UserAssignedIdentities []*string `json:"userAssignedIdentities,omitempty"` +} + +// ManagedIdentityToken - The managed identity token for the managed app resource. +type ManagedIdentityToken struct { + // The requested access token. + AccessToken *string `json:"accessToken,omitempty"` + + // The aud (audience) the access token was request for. This is the same as what was provided in the listTokens request. + AuthorizationAudience *string `json:"authorizationAudience,omitempty"` + + // The number of seconds the access token will be valid. + ExpiresIn *string `json:"expiresIn,omitempty"` + + // The timespan when the access token expires. This is represented as the number of seconds from epoch. + ExpiresOn *string `json:"expiresOn,omitempty"` + + // The timespan when the access token takes effect. This is represented as the number of seconds from epoch. + NotBefore *string `json:"notBefore,omitempty"` + + // The Azure resource ID for the issued token. This is either the managed application ID or the user-assigned identity ID. + ResourceID *string `json:"resourceId,omitempty"` + + // The type of the token. + TokenType *string `json:"tokenType,omitempty"` +} + +// ManagedIdentityTokenResult - The array of managed identity tokens. +type ManagedIdentityTokenResult struct { + // The array of managed identity tokens. + Value []*ManagedIdentityToken `json:"value,omitempty"` +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -847,6 +949,21 @@ type SystemData struct { LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` } +// UpdateAccessDefinition - Update access request definition. +type UpdateAccessDefinition struct { + // REQUIRED; The JIT request metadata. + Metadata *JitRequestMetadata `json:"metadata,omitempty"` + + // REQUIRED; The JIT status. + Status *Status `json:"status,omitempty"` + + // REQUIRED; The JIT status. + SubStatus *Substatus `json:"subStatus,omitempty"` + + // The approver name. + Approver *string `json:"approver,omitempty"` +} + // UserAssignedResourceIdentity - Represents the user assigned identity that is contained within the UserAssignedIdentities // dictionary on ResourceIdentity type UserAssignedResourceIdentity struct { diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/models_serde.go b/sdk/resourcemanager/solutions/armmanagedapplications/models_serde.go new file mode 100644 index 000000000000..cc3b77b728ef --- /dev/null +++ b/sdk/resourcemanager/solutions/armmanagedapplications/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 armmanagedapplications + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AllowedUpgradePlansResult. +func (a AllowedUpgradePlansResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AllowedUpgradePlansResult. +func (a *AllowedUpgradePlansResult) UnmarshalJSON(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 "value": + err = unpopulate(val, "Value", &a.Value) + 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 Application. +func (a Application) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "location", a.Location) + populate(objectMap, "managedBy", a.ManagedBy) + populate(objectMap, "name", a.Name) + populate(objectMap, "plan", a.Plan) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "sku", a.SKU) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Application. +func (a *Application) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &a.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "managedBy": + err = unpopulate(val, "ManagedBy", &a.ManagedBy) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &a.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &a.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApplicationArtifact. +func (a ApplicationArtifact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", a.Name) + populate(objectMap, "type", a.Type) + populate(objectMap, "uri", a.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationArtifact. +func (a *ApplicationArtifact) UnmarshalJSON(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) + case "uri": + err = unpopulate(val, "URI", &a.URI) + 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 ApplicationAuthorization. +func (a ApplicationAuthorization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", a.PrincipalID) + populate(objectMap, "roleDefinitionId", a.RoleDefinitionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationAuthorization. +func (a *ApplicationAuthorization) UnmarshalJSON(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 "principalId": + err = unpopulate(val, "PrincipalID", &a.PrincipalID) + delete(rawMsg, key) + case "roleDefinitionId": + err = unpopulate(val, "RoleDefinitionID", &a.RoleDefinitionID) + 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 ApplicationBillingDetailsDefinition. +func (a ApplicationBillingDetailsDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "resourceUsageId", a.ResourceUsageID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationBillingDetailsDefinition. +func (a *ApplicationBillingDetailsDefinition) UnmarshalJSON(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 "resourceUsageId": + err = unpopulate(val, "ResourceUsageID", &a.ResourceUsageID) + 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 ApplicationClientDetails. +func (a ApplicationClientDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "applicationId", a.ApplicationID) + populate(objectMap, "oid", a.Oid) + populate(objectMap, "puid", a.Puid) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationClientDetails. +func (a *ApplicationClientDetails) UnmarshalJSON(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 "applicationId": + err = unpopulate(val, "ApplicationID", &a.ApplicationID) + delete(rawMsg, key) + case "oid": + err = unpopulate(val, "Oid", &a.Oid) + delete(rawMsg, key) + case "puid": + err = unpopulate(val, "Puid", &a.Puid) + 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 ApplicationDefinition. +func (a ApplicationDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "managedBy", a.ManagedBy) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "sku", a.SKU) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationDefinition. +func (a *ApplicationDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "managedBy": + err = unpopulate(val, "ManagedBy", &a.ManagedBy) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &a.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApplicationDefinitionArtifact. +func (a ApplicationDefinitionArtifact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", a.Name) + populate(objectMap, "type", a.Type) + populate(objectMap, "uri", a.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationDefinitionArtifact. +func (a *ApplicationDefinitionArtifact) UnmarshalJSON(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) + case "uri": + err = unpopulate(val, "URI", &a.URI) + 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 ApplicationDefinitionListResult. +func (a ApplicationDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationDefinitionListResult. +func (a *ApplicationDefinitionListResult) UnmarshalJSON(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 "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + 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 ApplicationDefinitionPatchable. +func (a ApplicationDefinitionPatchable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationDefinitionPatchable. +func (a *ApplicationDefinitionPatchable) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ApplicationDefinitionProperties. +func (a ApplicationDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "artifacts", a.Artifacts) + populate(objectMap, "authorizations", a.Authorizations) + populate(objectMap, "createUiDefinition", &a.CreateUIDefinition) + populate(objectMap, "deploymentPolicy", a.DeploymentPolicy) + populate(objectMap, "description", a.Description) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "isEnabled", a.IsEnabled) + populate(objectMap, "lockLevel", a.LockLevel) + populate(objectMap, "lockingPolicy", a.LockingPolicy) + populate(objectMap, "mainTemplate", &a.MainTemplate) + populate(objectMap, "managementPolicy", a.ManagementPolicy) + populate(objectMap, "notificationPolicy", a.NotificationPolicy) + populate(objectMap, "packageFileUri", a.PackageFileURI) + populate(objectMap, "policies", a.Policies) + populate(objectMap, "storageAccountId", a.StorageAccountID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationDefinitionProperties. +func (a *ApplicationDefinitionProperties) UnmarshalJSON(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 "artifacts": + err = unpopulate(val, "Artifacts", &a.Artifacts) + delete(rawMsg, key) + case "authorizations": + err = unpopulate(val, "Authorizations", &a.Authorizations) + delete(rawMsg, key) + case "createUiDefinition": + err = unpopulate(val, "CreateUIDefinition", &a.CreateUIDefinition) + delete(rawMsg, key) + case "deploymentPolicy": + err = unpopulate(val, "DeploymentPolicy", &a.DeploymentPolicy) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "isEnabled": + err = unpopulate(val, "IsEnabled", &a.IsEnabled) + delete(rawMsg, key) + case "lockLevel": + err = unpopulate(val, "LockLevel", &a.LockLevel) + delete(rawMsg, key) + case "lockingPolicy": + err = unpopulate(val, "LockingPolicy", &a.LockingPolicy) + delete(rawMsg, key) + case "mainTemplate": + err = unpopulate(val, "MainTemplate", &a.MainTemplate) + delete(rawMsg, key) + case "managementPolicy": + err = unpopulate(val, "ManagementPolicy", &a.ManagementPolicy) + delete(rawMsg, key) + case "notificationPolicy": + err = unpopulate(val, "NotificationPolicy", &a.NotificationPolicy) + delete(rawMsg, key) + case "packageFileUri": + err = unpopulate(val, "PackageFileURI", &a.PackageFileURI) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &a.Policies) + delete(rawMsg, key) + case "storageAccountId": + err = unpopulate(val, "StorageAccountID", &a.StorageAccountID) + 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 ApplicationDeploymentPolicy. +func (a ApplicationDeploymentPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "deploymentMode", a.DeploymentMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationDeploymentPolicy. +func (a *ApplicationDeploymentPolicy) UnmarshalJSON(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 "deploymentMode": + err = unpopulate(val, "DeploymentMode", &a.DeploymentMode) + 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 ApplicationJitAccessPolicy. +func (a ApplicationJitAccessPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "jitAccessEnabled", a.JitAccessEnabled) + populate(objectMap, "jitApprovalMode", a.JitApprovalMode) + populate(objectMap, "jitApprovers", a.JitApprovers) + populate(objectMap, "maximumJitAccessDuration", a.MaximumJitAccessDuration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationJitAccessPolicy. +func (a *ApplicationJitAccessPolicy) UnmarshalJSON(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 "jitAccessEnabled": + err = unpopulate(val, "JitAccessEnabled", &a.JitAccessEnabled) + delete(rawMsg, key) + case "jitApprovalMode": + err = unpopulate(val, "JitApprovalMode", &a.JitApprovalMode) + delete(rawMsg, key) + case "jitApprovers": + err = unpopulate(val, "JitApprovers", &a.JitApprovers) + delete(rawMsg, key) + case "maximumJitAccessDuration": + err = unpopulate(val, "MaximumJitAccessDuration", &a.MaximumJitAccessDuration) + 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 ApplicationListResult. +func (a ApplicationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationListResult. +func (a *ApplicationListResult) UnmarshalJSON(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 "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + 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 ApplicationManagementPolicy. +func (a ApplicationManagementPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "mode", a.Mode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationManagementPolicy. +func (a *ApplicationManagementPolicy) UnmarshalJSON(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 "mode": + err = unpopulate(val, "Mode", &a.Mode) + 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 ApplicationNotificationEndpoint. +func (a ApplicationNotificationEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "uri", a.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationNotificationEndpoint. +func (a *ApplicationNotificationEndpoint) UnmarshalJSON(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 "uri": + err = unpopulate(val, "URI", &a.URI) + 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 ApplicationNotificationPolicy. +func (a ApplicationNotificationPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "notificationEndpoints", a.NotificationEndpoints) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationNotificationPolicy. +func (a *ApplicationNotificationPolicy) UnmarshalJSON(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 "notificationEndpoints": + err = unpopulate(val, "NotificationEndpoints", &a.NotificationEndpoints) + 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 ApplicationPackageContact. +func (a ApplicationPackageContact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "contactName", a.ContactName) + populate(objectMap, "email", a.Email) + populate(objectMap, "phone", a.Phone) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationPackageContact. +func (a *ApplicationPackageContact) UnmarshalJSON(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 "contactName": + err = unpopulate(val, "ContactName", &a.ContactName) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &a.Email) + delete(rawMsg, key) + case "phone": + err = unpopulate(val, "Phone", &a.Phone) + 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 ApplicationPackageLockingPolicyDefinition. +func (a ApplicationPackageLockingPolicyDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowedActions", a.AllowedActions) + populate(objectMap, "allowedDataActions", a.AllowedDataActions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationPackageLockingPolicyDefinition. +func (a *ApplicationPackageLockingPolicyDefinition) UnmarshalJSON(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 "allowedActions": + err = unpopulate(val, "AllowedActions", &a.AllowedActions) + delete(rawMsg, key) + case "allowedDataActions": + err = unpopulate(val, "AllowedDataActions", &a.AllowedDataActions) + 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 ApplicationPackageSupportUrls. +func (a ApplicationPackageSupportUrls) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "governmentCloud", a.GovernmentCloud) + populate(objectMap, "publicAzure", a.PublicAzure) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationPackageSupportUrls. +func (a *ApplicationPackageSupportUrls) UnmarshalJSON(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 "governmentCloud": + err = unpopulate(val, "GovernmentCloud", &a.GovernmentCloud) + delete(rawMsg, key) + case "publicAzure": + err = unpopulate(val, "PublicAzure", &a.PublicAzure) + 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 ApplicationPatchable. +func (a ApplicationPatchable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "location", a.Location) + populate(objectMap, "managedBy", a.ManagedBy) + populate(objectMap, "name", a.Name) + populate(objectMap, "plan", a.Plan) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "sku", a.SKU) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationPatchable. +func (a *ApplicationPatchable) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &a.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "managedBy": + err = unpopulate(val, "ManagedBy", &a.ManagedBy) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &a.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &a.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApplicationPolicy. +func (a ApplicationPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", a.Name) + populate(objectMap, "parameters", a.Parameters) + populate(objectMap, "policyDefinitionId", a.PolicyDefinitionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationPolicy. +func (a *ApplicationPolicy) UnmarshalJSON(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 "parameters": + err = unpopulate(val, "Parameters", &a.Parameters) + delete(rawMsg, key) + case "policyDefinitionId": + err = unpopulate(val, "PolicyDefinitionID", &a.PolicyDefinitionID) + 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 ApplicationProperties. +func (a ApplicationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "applicationDefinitionId", a.ApplicationDefinitionID) + populate(objectMap, "artifacts", a.Artifacts) + populate(objectMap, "authorizations", a.Authorizations) + populate(objectMap, "billingDetails", a.BillingDetails) + populate(objectMap, "createdBy", a.CreatedBy) + populate(objectMap, "customerSupport", a.CustomerSupport) + populate(objectMap, "jitAccessPolicy", a.JitAccessPolicy) + populate(objectMap, "managedResourceGroupId", a.ManagedResourceGroupID) + populate(objectMap, "managementMode", a.ManagementMode) + populate(objectMap, "outputs", &a.Outputs) + populate(objectMap, "parameters", &a.Parameters) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "publisherTenantId", a.PublisherTenantID) + populate(objectMap, "supportUrls", a.SupportUrls) + populate(objectMap, "updatedBy", a.UpdatedBy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationProperties. +func (a *ApplicationProperties) UnmarshalJSON(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 "applicationDefinitionId": + err = unpopulate(val, "ApplicationDefinitionID", &a.ApplicationDefinitionID) + delete(rawMsg, key) + case "artifacts": + err = unpopulate(val, "Artifacts", &a.Artifacts) + delete(rawMsg, key) + case "authorizations": + err = unpopulate(val, "Authorizations", &a.Authorizations) + delete(rawMsg, key) + case "billingDetails": + err = unpopulate(val, "BillingDetails", &a.BillingDetails) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &a.CreatedBy) + delete(rawMsg, key) + case "customerSupport": + err = unpopulate(val, "CustomerSupport", &a.CustomerSupport) + delete(rawMsg, key) + case "jitAccessPolicy": + err = unpopulate(val, "JitAccessPolicy", &a.JitAccessPolicy) + delete(rawMsg, key) + case "managedResourceGroupId": + err = unpopulate(val, "ManagedResourceGroupID", &a.ManagedResourceGroupID) + delete(rawMsg, key) + case "managementMode": + err = unpopulate(val, "ManagementMode", &a.ManagementMode) + delete(rawMsg, key) + case "outputs": + err = unpopulate(val, "Outputs", &a.Outputs) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &a.Parameters) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "publisherTenantId": + err = unpopulate(val, "PublisherTenantID", &a.PublisherTenantID) + delete(rawMsg, key) + case "supportUrls": + err = unpopulate(val, "SupportUrls", &a.SupportUrls) + delete(rawMsg, key) + case "updatedBy": + err = unpopulate(val, "UpdatedBy", &a.UpdatedBy) + 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 ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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]interface{}) + 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]interface{}) + 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 GenericResource. +func (g GenericResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", g.ID) + populate(objectMap, "location", g.Location) + populate(objectMap, "managedBy", g.ManagedBy) + populate(objectMap, "name", g.Name) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResource. +func (g *GenericResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &g.Location) + delete(rawMsg, key) + case "managedBy": + err = unpopulate(val, "ManagedBy", &g.ManagedBy) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitApproverDefinition. +func (j JitApproverDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", j.DisplayName) + populate(objectMap, "id", j.ID) + populate(objectMap, "type", j.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitApproverDefinition. +func (j *JitApproverDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &j.DisplayName) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &j.ID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &j.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitAuthorizationPolicies. +func (j JitAuthorizationPolicies) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", j.PrincipalID) + populate(objectMap, "roleDefinitionId", j.RoleDefinitionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitAuthorizationPolicies. +func (j *JitAuthorizationPolicies) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &j.PrincipalID) + delete(rawMsg, key) + case "roleDefinitionId": + err = unpopulate(val, "RoleDefinitionID", &j.RoleDefinitionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitRequestDefinition. +func (j JitRequestDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", j.ID) + populate(objectMap, "location", j.Location) + populate(objectMap, "name", j.Name) + populate(objectMap, "properties", j.Properties) + populate(objectMap, "systemData", j.SystemData) + populate(objectMap, "tags", j.Tags) + populate(objectMap, "type", j.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitRequestDefinition. +func (j *JitRequestDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &j.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &j.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &j.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &j.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &j.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &j.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &j.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitRequestDefinitionListResult. +func (j JitRequestDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", j.NextLink) + populate(objectMap, "value", j.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitRequestDefinitionListResult. +func (j *JitRequestDefinitionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &j.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &j.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitRequestMetadata. +func (j JitRequestMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "originRequestId", j.OriginRequestID) + populate(objectMap, "requestorId", j.RequestorID) + populate(objectMap, "subjectDisplayName", j.SubjectDisplayName) + populate(objectMap, "tenantDisplayName", j.TenantDisplayName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitRequestMetadata. +func (j *JitRequestMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "originRequestId": + err = unpopulate(val, "OriginRequestID", &j.OriginRequestID) + delete(rawMsg, key) + case "requestorId": + err = unpopulate(val, "RequestorID", &j.RequestorID) + delete(rawMsg, key) + case "subjectDisplayName": + err = unpopulate(val, "SubjectDisplayName", &j.SubjectDisplayName) + delete(rawMsg, key) + case "tenantDisplayName": + err = unpopulate(val, "TenantDisplayName", &j.TenantDisplayName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitRequestPatchable. +func (j JitRequestPatchable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", j.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitRequestPatchable. +func (j *JitRequestPatchable) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &j.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitRequestProperties. +func (j JitRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "applicationResourceId", j.ApplicationResourceID) + populate(objectMap, "createdBy", j.CreatedBy) + populate(objectMap, "jitAuthorizationPolicies", j.JitAuthorizationPolicies) + populate(objectMap, "jitRequestState", j.JitRequestState) + populate(objectMap, "jitSchedulingPolicy", j.JitSchedulingPolicy) + populate(objectMap, "provisioningState", j.ProvisioningState) + populate(objectMap, "publisherTenantId", j.PublisherTenantID) + populate(objectMap, "updatedBy", j.UpdatedBy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitRequestProperties. +func (j *JitRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "applicationResourceId": + err = unpopulate(val, "ApplicationResourceID", &j.ApplicationResourceID) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &j.CreatedBy) + delete(rawMsg, key) + case "jitAuthorizationPolicies": + err = unpopulate(val, "JitAuthorizationPolicies", &j.JitAuthorizationPolicies) + delete(rawMsg, key) + case "jitRequestState": + err = unpopulate(val, "JitRequestState", &j.JitRequestState) + delete(rawMsg, key) + case "jitSchedulingPolicy": + err = unpopulate(val, "JitSchedulingPolicy", &j.JitSchedulingPolicy) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &j.ProvisioningState) + delete(rawMsg, key) + case "publisherTenantId": + err = unpopulate(val, "PublisherTenantID", &j.PublisherTenantID) + delete(rawMsg, key) + case "updatedBy": + err = unpopulate(val, "UpdatedBy", &j.UpdatedBy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JitSchedulingPolicy. +func (j JitSchedulingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "duration", j.Duration) + populateTimeRFC3339(objectMap, "startTime", j.StartTime) + populate(objectMap, "type", j.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JitSchedulingPolicy. +func (j *JitSchedulingPolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "duration": + err = unpopulate(val, "Duration", &j.Duration) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &j.StartTime) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &j.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListTokenRequest. +func (l ListTokenRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizationAudience", l.AuthorizationAudience) + populate(objectMap, "userAssignedIdentities", l.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListTokenRequest. +func (l *ListTokenRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authorizationAudience": + err = unpopulate(val, "AuthorizationAudience", &l.AuthorizationAudience) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &l.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedIdentityToken. +func (m ManagedIdentityToken) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "accessToken", m.AccessToken) + populate(objectMap, "authorizationAudience", m.AuthorizationAudience) + populate(objectMap, "expiresIn", m.ExpiresIn) + populate(objectMap, "expiresOn", m.ExpiresOn) + populate(objectMap, "notBefore", m.NotBefore) + populate(objectMap, "resourceId", m.ResourceID) + populate(objectMap, "tokenType", m.TokenType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedIdentityToken. +func (m *ManagedIdentityToken) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accessToken": + err = unpopulate(val, "AccessToken", &m.AccessToken) + delete(rawMsg, key) + case "authorizationAudience": + err = unpopulate(val, "AuthorizationAudience", &m.AuthorizationAudience) + delete(rawMsg, key) + case "expiresIn": + err = unpopulate(val, "ExpiresIn", &m.ExpiresIn) + delete(rawMsg, key) + case "expiresOn": + err = unpopulate(val, "ExpiresOn", &m.ExpiresOn) + delete(rawMsg, key) + case "notBefore": + err = unpopulate(val, "NotBefore", &m.NotBefore) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &m.ResourceID) + delete(rawMsg, key) + case "tokenType": + err = unpopulate(val, "TokenType", &m.TokenType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedIdentityTokenResult. +func (m ManagedIdentityTokenResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedIdentityTokenResult. +func (m *ManagedIdentityTokenResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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]interface{}) + 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]interface{}) + 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 Plan. +func (p Plan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", p.Name) + populate(objectMap, "product", p.Product) + populate(objectMap, "promotionCode", p.PromotionCode) + populate(objectMap, "publisher", p.Publisher) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Plan. +func (p *Plan) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &p.Product) + delete(rawMsg, key) + case "promotionCode": + err = unpopulate(val, "PromotionCode", &p.PromotionCode) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &p.Publisher) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &p.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlanPatchable. +func (p PlanPatchable) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", p.Name) + populate(objectMap, "product", p.Product) + populate(objectMap, "promotionCode", p.PromotionCode) + populate(objectMap, "publisher", p.Publisher) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlanPatchable. +func (p *PlanPatchable) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &p.Product) + delete(rawMsg, key) + case "promotionCode": + err = unpopulate(val, "PromotionCode", &p.PromotionCode) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &p.Publisher) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &p.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + 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 "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + 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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) + populate(objectMap, "model", s.Model) + populate(objectMap, "name", s.Name) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(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 "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "model": + err = unpopulate(val, "Model", &s.Model) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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]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 UpdateAccessDefinition. +func (u UpdateAccessDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "approver", u.Approver) + populate(objectMap, "metadata", u.Metadata) + populate(objectMap, "status", u.Status) + populate(objectMap, "subStatus", u.SubStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateAccessDefinition. +func (u *UpdateAccessDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approver": + err = unpopulate(val, "Approver", &u.Approver) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &u.Metadata) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &u.Status) + delete(rawMsg, key) + case "subStatus": + err = unpopulate(val, "SubStatus", &u.SubStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedResourceIdentity. +func (u UserAssignedResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", u.PrincipalID) + populate(objectMap, "tenantId", u.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedResourceIdentity. +func (u *UserAssignedResourceIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &u.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +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 +} diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_response_types.go b/sdk/resourcemanager/solutions/armmanagedapplications/response_types.go similarity index 69% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_response_types.go rename to sdk/resourcemanager/solutions/armmanagedapplications/response_types.go index 02cb94eef2e8..4eed6f7b214e 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_response_types.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/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 armmanagedapplications @@ -13,16 +14,31 @@ type ApplicationClientListOperationsResponse struct { OperationListResult } +// ApplicationDefinitionsClientCreateOrUpdateByIDResponse contains the response from method ApplicationDefinitionsClient.CreateOrUpdateByID. +type ApplicationDefinitionsClientCreateOrUpdateByIDResponse struct { + ApplicationDefinition +} + // ApplicationDefinitionsClientCreateOrUpdateResponse contains the response from method ApplicationDefinitionsClient.CreateOrUpdate. type ApplicationDefinitionsClientCreateOrUpdateResponse struct { ApplicationDefinition } +// ApplicationDefinitionsClientDeleteByIDResponse contains the response from method ApplicationDefinitionsClient.DeleteByID. +type ApplicationDefinitionsClientDeleteByIDResponse struct { + // placeholder for future response values +} + // ApplicationDefinitionsClientDeleteResponse contains the response from method ApplicationDefinitionsClient.Delete. type ApplicationDefinitionsClientDeleteResponse struct { // placeholder for future response values } +// ApplicationDefinitionsClientGetByIDResponse contains the response from method ApplicationDefinitionsClient.GetByID. +type ApplicationDefinitionsClientGetByIDResponse struct { + ApplicationDefinition +} + // ApplicationDefinitionsClientGetResponse contains the response from method ApplicationDefinitionsClient.Get. type ApplicationDefinitionsClientGetResponse struct { ApplicationDefinition @@ -38,21 +54,41 @@ type ApplicationDefinitionsClientListBySubscriptionResponse struct { ApplicationDefinitionListResult } +// ApplicationDefinitionsClientUpdateByIDResponse contains the response from method ApplicationDefinitionsClient.UpdateByID. +type ApplicationDefinitionsClientUpdateByIDResponse struct { + ApplicationDefinition +} + // ApplicationDefinitionsClientUpdateResponse contains the response from method ApplicationDefinitionsClient.Update. type ApplicationDefinitionsClientUpdateResponse struct { ApplicationDefinition } +// ApplicationsClientCreateOrUpdateByIDResponse contains the response from method ApplicationsClient.CreateOrUpdateByID. +type ApplicationsClientCreateOrUpdateByIDResponse struct { + Application +} + // ApplicationsClientCreateOrUpdateResponse contains the response from method ApplicationsClient.CreateOrUpdate. type ApplicationsClientCreateOrUpdateResponse struct { Application } +// ApplicationsClientDeleteByIDResponse contains the response from method ApplicationsClient.DeleteByID. +type ApplicationsClientDeleteByIDResponse struct { + // placeholder for future response values +} + // ApplicationsClientDeleteResponse contains the response from method ApplicationsClient.Delete. type ApplicationsClientDeleteResponse struct { // placeholder for future response values } +// ApplicationsClientGetByIDResponse contains the response from method ApplicationsClient.GetByID. +type ApplicationsClientGetByIDResponse struct { + Application +} + // ApplicationsClientGetResponse contains the response from method ApplicationsClient.Get. type ApplicationsClientGetResponse struct { Application @@ -60,7 +96,7 @@ type ApplicationsClientGetResponse struct { // ApplicationsClientListAllowedUpgradePlansResponse contains the response from method ApplicationsClient.ListAllowedUpgradePlans. type ApplicationsClientListAllowedUpgradePlansResponse struct { - // placeholder for future response values + AllowedUpgradePlansResult } // ApplicationsClientListByResourceGroupResponse contains the response from method ApplicationsClient.ListByResourceGroup. @@ -73,11 +109,26 @@ type ApplicationsClientListBySubscriptionResponse struct { ApplicationListResult } +// ApplicationsClientListTokensResponse contains the response from method ApplicationsClient.ListTokens. +type ApplicationsClientListTokensResponse struct { + ManagedIdentityTokenResult +} + // ApplicationsClientRefreshPermissionsResponse contains the response from method ApplicationsClient.RefreshPermissions. type ApplicationsClientRefreshPermissionsResponse struct { // placeholder for future response values } +// ApplicationsClientUpdateAccessResponse contains the response from method ApplicationsClient.UpdateAccess. +type ApplicationsClientUpdateAccessResponse struct { + UpdateAccessDefinition +} + +// ApplicationsClientUpdateByIDResponse contains the response from method ApplicationsClient.UpdateByID. +type ApplicationsClientUpdateByIDResponse struct { + Application +} + // ApplicationsClientUpdateResponse contains the response from method ApplicationsClient.Update. type ApplicationsClientUpdateResponse struct { Application diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_time_rfc3339.go b/sdk/resourcemanager/solutions/armmanagedapplications/time_rfc3339.go similarity index 99% rename from sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/solutions/armmanagedapplications/time_rfc3339.go index 10863c367092..c3d11504faea 100644 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/solutions/armmanagedapplications/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 armmanagedapplications diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applicationclient_client_test.go b/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applicationclient_client_test.go deleted file mode 100644 index 1359488f50fb..000000000000 --- a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applicationclient_client_test.go +++ /dev/null @@ -1,41 +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 armmanagedapplications_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/solutions/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listSolutionsOperations.json -func ExampleApplicationClient_NewListOperationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListOperationsPager(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 - } - } -} diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applicationdefinitions_client_test.go b/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applicationdefinitions_client_test.go deleted file mode 100644 index 85f0c7aea955..000000000000 --- a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applicationdefinitions_client_test.go +++ /dev/null @@ -1,179 +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 armmanagedapplications_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/solutions/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/getApplicationDefinition.json -func ExampleApplicationDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationDefinitionsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg", - "myManagedApplicationDef", - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/deleteApplicationDefinition.json -func ExampleApplicationDefinitionsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationDefinitionsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "rg", - "myManagedApplicationDef", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/createOrUpdateApplicationDefinition.json -func ExampleApplicationDefinitionsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationDefinitionsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "rg", - "myManagedApplicationDef", - armmanagedapplications.ApplicationDefinition{ - Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - Description: to.Ptr("myManagedApplicationDef description"), - Authorizations: []*armmanagedapplications.ApplicationAuthorization{ - { - PrincipalID: to.Ptr("validprincipalguid"), - RoleDefinitionID: to.Ptr("validroleguid"), - }}, - DisplayName: to.Ptr("myManagedApplicationDef"), - LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateApplicationDefinition.json -func ExampleApplicationDefinitionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationDefinitionsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg", - "myManagedApplicationDef", - armmanagedapplications.ApplicationDefinitionPatchable{ - Tags: map[string]*string{ - "department": to.Ptr("Finance"), - }, - }, - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listApplicationDefinitionsByResourceGroup.json -func ExampleApplicationDefinitionsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationDefinitionsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("rg", - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listApplicationDefinitionsByResourceGroup.json -func ExampleApplicationDefinitionsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationDefinitionsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(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 - } - } -} diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applications_client_test.go b/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applications_client_test.go deleted file mode 100644 index ea766cae6e83..000000000000 --- a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_applications_client_test.go +++ /dev/null @@ -1,219 +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 armmanagedapplications_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/solutions/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/getApplication.json -func ExampleApplicationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg", - "myManagedApplication", - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/deleteApplication.json -func ExampleApplicationsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "rg", - "myManagedApplication", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/createOrUpdateApplication.json -func ExampleApplicationsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "rg", - "myManagedApplication", - armmanagedapplications.Application{ - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateApplication.json -func ExampleApplicationsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg", - "myManagedApplication", - &armmanagedapplications.ApplicationsClientUpdateOptions{Parameters: &armmanagedapplications.ApplicationPatchable{ - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listApplicationsByResourceGroup.json -func ExampleApplicationsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("rg", - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listApplicationsByResourceGroup.json -func ExampleApplicationsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/refreshApplicationPermissions.json -func ExampleApplicationsClient_BeginRefreshPermissions() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRefreshPermissions(ctx, - "rg", - "myManagedApplication", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listAllowedUpgradePlans.json -func ExampleApplicationsClient_ListAllowedUpgradePlans() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewApplicationsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.ListAllowedUpgradePlans(ctx, - "rg", - "myManagedApplication", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_jitrequests_client_test.go b/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_jitrequests_client_test.go deleted file mode 100644 index 7cdf6d3efe09..000000000000 --- a/sdk/resourcemanager/solutions/armmanagedapplications/ze_generated_example_jitrequests_client_test.go +++ /dev/null @@ -1,171 +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 armmanagedapplications_test - -import ( - "context" - "log" - - "time" - - "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/solutions/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/getJitRequest.json -func ExampleJitRequestsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewJitRequestsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg", - "myJitRequest", - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/createOrUpdateJitRequest.json -func ExampleJitRequestsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewJitRequestsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "rg", - "myJitRequest", - armmanagedapplications.JitRequestDefinition{ - Properties: &armmanagedapplications.JitRequestProperties{ - ApplicationResourceID: to.Ptr("/subscriptions/00c76877-e316-48a7-af60-4a09fec9d43f/resourceGroups/52F30DB2/providers/Microsoft.Solutions/applications/7E193158"), - JitAuthorizationPolicies: []*armmanagedapplications.JitAuthorizationPolicies{ - { - PrincipalID: to.Ptr("1db8e132e2934dbcb8e1178a61319491"), - RoleDefinitionID: to.Ptr("ecd05a23-931a-4c38-a52b-ac7c4c583334"), - }}, - JitSchedulingPolicy: &armmanagedapplications.JitSchedulingPolicy{ - Type: to.Ptr(armmanagedapplications.JitSchedulingTypeOnce), - Duration: to.Ptr("PT8H"), - StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-22T05:48:30.6661804Z"); return t }()), - }, - }, - }, - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/updateJitRequest.json -func ExampleJitRequestsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewJitRequestsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg", - "myJitRequest", - armmanagedapplications.JitRequestPatchable{ - Tags: map[string]*string{ - "department": to.Ptr("Finance"), - }, - }, - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/deleteJitRequest.json -func ExampleJitRequestsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewJitRequestsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "rg", - "myJitRequest", - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listJitRequestsByResourceGroup.json -func ExampleJitRequestsClient_ListBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewJitRequestsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListBySubscription(ctx, - 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/solutions/resource-manager/Microsoft.Solutions/stable/2021-07-01/examples/listJitRequestsByResourceGroup.json -func ExampleJitRequestsClient_ListByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armmanagedapplications.NewJitRequestsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByResourceGroup(ctx, - "rg", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_models_serde.go b/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_models_serde.go deleted file mode 100644 index 3f13c9a8939e..000000000000 --- a/sdk/resourcemanager/solutions/armmanagedapplications/zz_generated_models_serde.go +++ /dev/null @@ -1,314 +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 armmanagedapplications - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type Application. -func (a Application) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "identity", a.Identity) - populate(objectMap, "kind", a.Kind) - populate(objectMap, "location", a.Location) - populate(objectMap, "managedBy", a.ManagedBy) - populate(objectMap, "name", a.Name) - populate(objectMap, "plan", a.Plan) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "sku", a.SKU) - populate(objectMap, "systemData", a.SystemData) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationDefinition. -func (a ApplicationDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "location", a.Location) - populate(objectMap, "managedBy", a.ManagedBy) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "sku", a.SKU) - populate(objectMap, "systemData", a.SystemData) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationDefinitionPatchable. -func (a ApplicationDefinitionPatchable) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", a.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationDefinitionProperties. -func (a ApplicationDefinitionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "artifacts", a.Artifacts) - populate(objectMap, "authorizations", a.Authorizations) - populate(objectMap, "createUiDefinition", &a.CreateUIDefinition) - populate(objectMap, "deploymentPolicy", a.DeploymentPolicy) - populate(objectMap, "description", a.Description) - populate(objectMap, "displayName", a.DisplayName) - populate(objectMap, "isEnabled", a.IsEnabled) - populate(objectMap, "lockLevel", a.LockLevel) - populate(objectMap, "lockingPolicy", a.LockingPolicy) - populate(objectMap, "mainTemplate", &a.MainTemplate) - populate(objectMap, "managementPolicy", a.ManagementPolicy) - populate(objectMap, "notificationPolicy", a.NotificationPolicy) - populate(objectMap, "packageFileUri", a.PackageFileURI) - populate(objectMap, "policies", a.Policies) - populate(objectMap, "provisioningState", a.ProvisioningState) - populate(objectMap, "storageAccountId", a.StorageAccountID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationJitAccessPolicy. -func (a ApplicationJitAccessPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "jitAccessEnabled", a.JitAccessEnabled) - populate(objectMap, "jitApprovalMode", a.JitApprovalMode) - populate(objectMap, "jitApprovers", a.JitApprovers) - populate(objectMap, "maximumJitAccessDuration", a.MaximumJitAccessDuration) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationNotificationPolicy. -func (a ApplicationNotificationPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "notificationEndpoints", a.NotificationEndpoints) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationPackageLockingPolicyDefinition. -func (a ApplicationPackageLockingPolicyDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allowedActions", a.AllowedActions) - populate(objectMap, "allowedDataActions", a.AllowedDataActions) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationPatchable. -func (a ApplicationPatchable) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "identity", a.Identity) - populate(objectMap, "kind", a.Kind) - populate(objectMap, "location", a.Location) - populate(objectMap, "managedBy", a.ManagedBy) - populate(objectMap, "name", a.Name) - populate(objectMap, "plan", a.Plan) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "sku", a.SKU) - populate(objectMap, "systemData", a.SystemData) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationProperties. -func (a ApplicationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "applicationDefinitionId", a.ApplicationDefinitionID) - populate(objectMap, "artifacts", a.Artifacts) - populate(objectMap, "authorizations", a.Authorizations) - populate(objectMap, "billingDetails", a.BillingDetails) - populate(objectMap, "createdBy", a.CreatedBy) - populate(objectMap, "customerSupport", a.CustomerSupport) - populate(objectMap, "jitAccessPolicy", a.JitAccessPolicy) - populate(objectMap, "managedResourceGroupId", a.ManagedResourceGroupID) - populate(objectMap, "managementMode", a.ManagementMode) - populate(objectMap, "outputs", &a.Outputs) - populate(objectMap, "parameters", &a.Parameters) - populate(objectMap, "provisioningState", a.ProvisioningState) - populate(objectMap, "publisherTenantId", a.PublisherTenantID) - populate(objectMap, "supportUrls", a.SupportUrls) - populate(objectMap, "updatedBy", a.UpdatedBy) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type GenericResource. -func (g GenericResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", g.ID) - populate(objectMap, "location", g.Location) - populate(objectMap, "managedBy", g.ManagedBy) - populate(objectMap, "name", g.Name) - populate(objectMap, "sku", g.SKU) - populate(objectMap, "systemData", g.SystemData) - populate(objectMap, "tags", g.Tags) - populate(objectMap, "type", g.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Identity. -func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "principalId", i.PrincipalID) - populate(objectMap, "tenantId", i.TenantID) - populate(objectMap, "type", i.Type) - populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type JitRequestDefinition. -func (j JitRequestDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", j.ID) - populate(objectMap, "location", j.Location) - populate(objectMap, "name", j.Name) - populate(objectMap, "properties", j.Properties) - populate(objectMap, "systemData", j.SystemData) - populate(objectMap, "tags", j.Tags) - populate(objectMap, "type", j.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type JitRequestPatchable. -func (j JitRequestPatchable) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", j.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type JitRequestProperties. -func (j JitRequestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "applicationResourceId", j.ApplicationResourceID) - populate(objectMap, "createdBy", j.CreatedBy) - populate(objectMap, "jitAuthorizationPolicies", j.JitAuthorizationPolicies) - populate(objectMap, "jitRequestState", j.JitRequestState) - populate(objectMap, "jitSchedulingPolicy", j.JitSchedulingPolicy) - populate(objectMap, "provisioningState", j.ProvisioningState) - populate(objectMap, "publisherTenantId", j.PublisherTenantID) - populate(objectMap, "updatedBy", j.UpdatedBy) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type JitSchedulingPolicy. -func (j JitSchedulingPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "duration", j.Duration) - populateTimeRFC3339(objectMap, "startTime", j.StartTime) - populate(objectMap, "type", j.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type JitSchedulingPolicy. -func (j *JitSchedulingPolicy) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", j, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "duration": - err = unpopulate(val, "Duration", &j.Duration) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &j.StartTime) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &j.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", j, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "systemData", r.SystemData) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - 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 -} - -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 -}