diff --git a/sdk/resourcemanager/apicenter/armapicenter/CHANGELOG.md b/sdk/resourcemanager/apicenter/armapicenter/CHANGELOG.md index bd247c1aa239..f365afab44c0 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/CHANGELOG.md +++ b/sdk/resourcemanager/apicenter/armapicenter/CHANGELOG.md @@ -1,5 +1,115 @@ # Release History +## 1.0.0 (2023-11-06) +### Breaking Changes + +- Function `NewClientFactory` parameter(s) have been changed from `(string, string, azcore.TokenCredential, *arm.ClientOptions)` to `(string, string, string, string, string, string, string, string, *string, azcore.TokenCredential, *arm.ClientOptions)` +- Function `NewServicesClient` parameter(s) have been changed from `(string, string, azcore.TokenCredential, *arm.ClientOptions)` to `(string, azcore.TokenCredential, *arm.ClientOptions)` +- Function `*ServicesClient.CreateOrUpdate` parameter(s) have been changed from `(context.Context, string, Service, *ServicesClientCreateOrUpdateOptions)` to `(context.Context, string, string, Service, *ServicesClientCreateOrUpdateOptions)` +- Function `*ServicesClient.Delete` parameter(s) have been changed from `(context.Context, string, *ServicesClientDeleteOptions)` to `(context.Context, string, string, *ServicesClientDeleteOptions)` +- Function `*ServicesClient.Get` parameter(s) have been changed from `(context.Context, string, *ServicesClientGetOptions)` to `(context.Context, string, string, *ServicesClientGetOptions)` +- Function `*ServicesClient.Update` parameter(s) have been changed from `(context.Context, string, ServiceUpdate, *ServicesClientUpdateOptions)` to `(context.Context, string, string, ServiceUpdate, *ServicesClientUpdateOptions)` + +### Features Added + +- New enum type `APIKind` with values `APIKindGraphql`, `APIKindGrpc`, `APIKindRest`, `APIKindSoap`, `APIKindWebhook`, `APIKindWebsocket` +- New enum type `APISpecExportResultFormat` with values `APISpecExportResultFormatInline`, `APISpecExportResultFormatLink` +- New enum type `APISpecImportSourceFormat` with values `APISpecImportSourceFormatInline`, `APISpecImportSourceFormatLink` +- New enum type `DeploymentState` with values `DeploymentStateActive`, `DeploymentStateInactive` +- New enum type `EnvironmentKind` with values `EnvironmentKindDevelopment`, `EnvironmentKindProduction`, `EnvironmentKindStaging`, `EnvironmentKindTesting` +- New enum type `EnvironmentServerType` with values `EnvironmentServerTypeAWSAPIGateway`, `EnvironmentServerTypeApigeeAPIManagement`, `EnvironmentServerTypeAzureAPIManagement`, `EnvironmentServerTypeAzureComputeService`, `EnvironmentServerTypeKongAPIGateway`, `EnvironmentServerTypeKubernetes`, `EnvironmentServerTypeMuleSoftAPIManagement` +- New enum type `LifecycleStage` with values `LifecycleStageDeprecated`, `LifecycleStageDesign`, `LifecycleStageDevelopment`, `LifecycleStagePreview`, `LifecycleStageProduction`, `LifecycleStageRetired`, `LifecycleStageTesting` +- New enum type `MetadataAssignmentEntity` with values `MetadataAssignmentEntityAPI`, `MetadataAssignmentEntityDeployment`, `MetadataAssignmentEntityEnvironment` +- New enum type `MetadataSchemaExportFormat` with values `MetadataSchemaExportFormatInline`, `MetadataSchemaExportFormatLink` +- New function `NewAPIDefinitionsClient(string, string, string, string, string, *string, azcore.TokenCredential, *arm.ClientOptions) (*APIDefinitionsClient, error)` +- New function `*APIDefinitionsClient.CreateOrUpdate(context.Context, string, string, APIDefinition, *APIDefinitionsClientCreateOrUpdateOptions) (APIDefinitionsClientCreateOrUpdateResponse, error)` +- New function `*APIDefinitionsClient.Delete(context.Context, string, string, *APIDefinitionsClientDeleteOptions) (APIDefinitionsClientDeleteResponse, error)` +- New function `*APIDefinitionsClient.ExportSpecification(context.Context, string, string, *APIDefinitionsClientExportSpecificationOptions) (APIDefinitionsClientExportSpecificationResponse, error)` +- New function `*APIDefinitionsClient.Get(context.Context, string, string, *APIDefinitionsClientGetOptions) (APIDefinitionsClientGetResponse, error)` +- New function `*APIDefinitionsClient.Head(context.Context, string, string, *APIDefinitionsClientHeadOptions) (APIDefinitionsClientHeadResponse, error)` +- New function `*APIDefinitionsClient.ImportSpecification(context.Context, string, string, APISpecImportRequest, *APIDefinitionsClientImportSpecificationOptions) (APIDefinitionsClientImportSpecificationResponse, error)` +- New function `*APIDefinitionsClient.NewListPager(string, string, *APIDefinitionsClientListOptions) *runtime.Pager[APIDefinitionsClientListResponse]` +- New function `NewAPIVersionsClient(string, string, string, string, *string, azcore.TokenCredential, *arm.ClientOptions) (*APIVersionsClient, error)` +- New function `*APIVersionsClient.CreateOrUpdate(context.Context, string, string, APIVersion, *APIVersionsClientCreateOrUpdateOptions) (APIVersionsClientCreateOrUpdateResponse, error)` +- New function `*APIVersionsClient.Delete(context.Context, string, string, *APIVersionsClientDeleteOptions) (APIVersionsClientDeleteResponse, error)` +- New function `*APIVersionsClient.Get(context.Context, string, string, *APIVersionsClientGetOptions) (APIVersionsClientGetResponse, error)` +- New function `*APIVersionsClient.Head(context.Context, string, string, *APIVersionsClientHeadOptions) (APIVersionsClientHeadResponse, error)` +- New function `*APIVersionsClient.NewListPager(string, string, *APIVersionsClientListOptions) *runtime.Pager[APIVersionsClientListResponse]` +- New function `NewApisClient(string, string, string, *string, azcore.TokenCredential, *arm.ClientOptions) (*ApisClient, error)` +- New function `*ApisClient.CreateOrUpdate(context.Context, string, string, API, *ApisClientCreateOrUpdateOptions) (ApisClientCreateOrUpdateResponse, error)` +- New function `*ApisClient.Delete(context.Context, string, string, *ApisClientDeleteOptions) (ApisClientDeleteResponse, error)` +- New function `*ApisClient.Get(context.Context, string, string, *ApisClientGetOptions) (ApisClientGetResponse, error)` +- New function `*ApisClient.Head(context.Context, string, string, *ApisClientHeadOptions) (ApisClientHeadResponse, error)` +- New function `*ApisClient.NewListPager(string, string, *ApisClientListOptions) *runtime.Pager[ApisClientListResponse]` +- New function `*ClientFactory.NewAPIDefinitionsClient() *APIDefinitionsClient` +- New function `*ClientFactory.NewAPIVersionsClient() *APIVersionsClient` +- New function `*ClientFactory.NewApisClient() *ApisClient` +- New function `*ClientFactory.NewDeploymentsClient() *DeploymentsClient` +- New function `*ClientFactory.NewEnvironmentsClient() *EnvironmentsClient` +- New function `*ClientFactory.NewMetadataSchemasClient() *MetadataSchemasClient` +- New function `*ClientFactory.NewWorkspacesClient() *WorkspacesClient` +- New function `NewDeploymentsClient(string, string, string, string, *string, azcore.TokenCredential, *arm.ClientOptions) (*DeploymentsClient, error)` +- New function `*DeploymentsClient.CreateOrUpdate(context.Context, string, string, Deployment, *DeploymentsClientCreateOrUpdateOptions) (DeploymentsClientCreateOrUpdateResponse, error)` +- New function `*DeploymentsClient.Delete(context.Context, string, string, *DeploymentsClientDeleteOptions) (DeploymentsClientDeleteResponse, error)` +- New function `*DeploymentsClient.Get(context.Context, string, string, *DeploymentsClientGetOptions) (DeploymentsClientGetResponse, error)` +- New function `*DeploymentsClient.Head(context.Context, string, string, *DeploymentsClientHeadOptions) (DeploymentsClientHeadResponse, error)` +- New function `*DeploymentsClient.NewListPager(string, string, *DeploymentsClientListOptions) *runtime.Pager[DeploymentsClientListResponse]` +- New function `NewEnvironmentsClient(string, string, string, *string, azcore.TokenCredential, *arm.ClientOptions) (*EnvironmentsClient, error)` +- New function `*EnvironmentsClient.CreateOrUpdate(context.Context, string, string, Environment, *EnvironmentsClientCreateOrUpdateOptions) (EnvironmentsClientCreateOrUpdateResponse, error)` +- New function `*EnvironmentsClient.Delete(context.Context, string, string, *EnvironmentsClientDeleteOptions) (EnvironmentsClientDeleteResponse, error)` +- New function `*EnvironmentsClient.Get(context.Context, string, string, *EnvironmentsClientGetOptions) (EnvironmentsClientGetResponse, error)` +- New function `*EnvironmentsClient.Head(context.Context, string, string, *EnvironmentsClientHeadOptions) (EnvironmentsClientHeadResponse, error)` +- New function `*EnvironmentsClient.NewListPager(string, string, *EnvironmentsClientListOptions) *runtime.Pager[EnvironmentsClientListResponse]` +- New function `NewMetadataSchemasClient(string, string, *string, azcore.TokenCredential, *arm.ClientOptions) (*MetadataSchemasClient, error)` +- New function `*MetadataSchemasClient.CreateOrUpdate(context.Context, string, string, MetadataSchema, *MetadataSchemasClientCreateOrUpdateOptions) (MetadataSchemasClientCreateOrUpdateResponse, error)` +- New function `*MetadataSchemasClient.Delete(context.Context, string, string, *MetadataSchemasClientDeleteOptions) (MetadataSchemasClientDeleteResponse, error)` +- New function `*MetadataSchemasClient.Get(context.Context, string, string, *MetadataSchemasClientGetOptions) (MetadataSchemasClientGetResponse, error)` +- New function `*MetadataSchemasClient.Head(context.Context, string, string, *MetadataSchemasClientHeadOptions) (MetadataSchemasClientHeadResponse, error)` +- New function `*MetadataSchemasClient.NewListPager(string, string, *MetadataSchemasClientListOptions) *runtime.Pager[MetadataSchemasClientListResponse]` +- New function `*ServicesClient.ExportMetadataSchema(context.Context, string, string, MetadataSchemaExportRequest, *ServicesClientExportMetadataSchemaOptions) (ServicesClientExportMetadataSchemaResponse, error)` +- New function `NewWorkspacesClient(string, string, *string, azcore.TokenCredential, *arm.ClientOptions) (*WorkspacesClient, error)` +- New function `*WorkspacesClient.CreateOrUpdate(context.Context, string, string, Workspace, *WorkspacesClientCreateOrUpdateOptions) (WorkspacesClientCreateOrUpdateResponse, error)` +- New function `*WorkspacesClient.Delete(context.Context, string, string, *WorkspacesClientDeleteOptions) (WorkspacesClientDeleteResponse, error)` +- New function `*WorkspacesClient.Get(context.Context, string, string, *WorkspacesClientGetOptions) (WorkspacesClientGetResponse, error)` +- New function `*WorkspacesClient.Head(context.Context, string, string, *WorkspacesClientHeadOptions) (WorkspacesClientHeadResponse, error)` +- New function `*WorkspacesClient.NewListPager(string, string, *WorkspacesClientListOptions) *runtime.Pager[WorkspacesClientListResponse]` +- New struct `API` +- New struct `APICollection` +- New struct `APIDefinition` +- New struct `APIDefinitionCollection` +- New struct `APIDefinitionProperties` +- New struct `APIDefinitionPropertiesSpecification` +- New struct `APIProperties` +- New struct `APISpecExportResult` +- New struct `APISpecImportRequest` +- New struct `APISpecImportRequestSpecification` +- New struct `APIVersion` +- New struct `APIVersionCollection` +- New struct `APIVersionProperties` +- New struct `Contact` +- New struct `Deployment` +- New struct `DeploymentCollection` +- New struct `DeploymentProperties` +- New struct `DeploymentServer` +- New struct `Environment` +- New struct `EnvironmentCollection` +- New struct `EnvironmentProperties` +- New struct `EnvironmentServer` +- New struct `ExternalDocumentation` +- New struct `License` +- New struct `MetadataAssignment` +- New struct `MetadataSchema` +- New struct `MetadataSchemaCollection` +- New struct `MetadataSchemaExportRequest` +- New struct `MetadataSchemaExportResult` +- New struct `MetadataSchemaProperties` +- New struct `Onboarding` +- New struct `TermsOfService` +- New struct `Workspace` +- New struct `WorkspaceCollection` +- New struct `WorkspaceProperties` + + ## 0.1.0 (2023-08-25) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apicenter/armapicenter` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). diff --git a/sdk/resourcemanager/apicenter/armapicenter/apidefinitions_client.go b/sdk/resourcemanager/apicenter/armapicenter/apidefinitions_client.go new file mode 100644 index 000000000000..1201346bbd90 --- /dev/null +++ b/sdk/resourcemanager/apicenter/armapicenter/apidefinitions_client.go @@ -0,0 +1,564 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapicenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// APIDefinitionsClient contains the methods for the APIDefinitions group. +// Don't use this type directly, use NewAPIDefinitionsClient() instead. +type APIDefinitionsClient struct { + internal *arm.Client + subscriptionID string + workspaceName string + apiName string + versionName string + filter *string + definitionName string +} + +// NewAPIDefinitionsClient creates a new instance of APIDefinitionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - workspaceName - The name of the workspace. +// - apiName - The name of the API. +// - versionName - The name of the API version. +// - definitionName - The name of the API definition. +// - filter - OData filter parameter. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAPIDefinitionsClient(subscriptionID string, workspaceName string, apiName string, versionName string, definitionName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIDefinitionsClient, error) { + cl, err := arm.NewClient(moduleName+".APIDefinitionsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &APIDefinitionsClient{ + subscriptionID: subscriptionID, + workspaceName: workspaceName, + apiName: apiName, + versionName: versionName, + definitionName: definitionName, + filter: filter, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates new or updates existing API definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - API definition entity. +// - options - APIDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the APIDefinitionsClient.CreateOrUpdate +// method. +func (client *APIDefinitionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload APIDefinition, options *APIDefinitionsClientCreateOrUpdateOptions) (APIDefinitionsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return APIDefinitionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIDefinitionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return APIDefinitionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload APIDefinition, options *APIDefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + if client.definitionName == "" { + return nil, errors.New("parameter client.definitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{definitionName}", url.PathEscape(client.definitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (APIDefinitionsClientCreateOrUpdateResponse, error) { + result := APIDefinitionsClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIDefinition); err != nil { + return APIDefinitionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specified API definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIDefinitionsClientDeleteOptions contains the optional parameters for the APIDefinitionsClient.Delete method. +func (client *APIDefinitionsClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientDeleteOptions) (APIDefinitionsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIDefinitionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIDefinitionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return APIDefinitionsClientDeleteResponse{}, err + } + return APIDefinitionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIDefinitionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + if client.definitionName == "" { + return nil, errors.New("parameter client.definitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{definitionName}", url.PathEscape(client.definitionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// ExportSpecification - Exports the API specification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIDefinitionsClientExportSpecificationOptions contains the optional parameters for the APIDefinitionsClient.ExportSpecification +// method. +func (client *APIDefinitionsClient) ExportSpecification(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientExportSpecificationOptions) (APIDefinitionsClientExportSpecificationResponse, error) { + var err error + req, err := client.exportSpecificationCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIDefinitionsClientExportSpecificationResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIDefinitionsClientExportSpecificationResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return APIDefinitionsClientExportSpecificationResponse{}, err + } + resp, err := client.exportSpecificationHandleResponse(httpResp) + return resp, err +} + +// exportSpecificationCreateRequest creates the ExportSpecification request. +func (client *APIDefinitionsClient) exportSpecificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientExportSpecificationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/exportSpecification" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + if client.definitionName == "" { + return nil, errors.New("parameter client.definitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{definitionName}", url.PathEscape(client.definitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// exportSpecificationHandleResponse handles the ExportSpecification response. +func (client *APIDefinitionsClient) exportSpecificationHandleResponse(resp *http.Response) (APIDefinitionsClientExportSpecificationResponse, error) { + result := APIDefinitionsClientExportSpecificationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APISpecExportResult); err != nil { + return APIDefinitionsClientExportSpecificationResponse{}, err + } + return result, nil +} + +// Get - Returns details of the API definition. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIDefinitionsClientGetOptions contains the optional parameters for the APIDefinitionsClient.Get method. +func (client *APIDefinitionsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientGetOptions) (APIDefinitionsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIDefinitionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIDefinitionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return APIDefinitionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *APIDefinitionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + if client.definitionName == "" { + return nil, errors.New("parameter client.definitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{definitionName}", url.PathEscape(client.definitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIDefinitionsClient) getHandleResponse(resp *http.Response) (APIDefinitionsClientGetResponse, error) { + result := APIDefinitionsClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIDefinition); err != nil { + return APIDefinitionsClientGetResponse{}, err + } + return result, nil +} + +// Head - Checks if specified API definition exists. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIDefinitionsClientHeadOptions contains the optional parameters for the APIDefinitionsClient.Head method. +func (client *APIDefinitionsClient) Head(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientHeadOptions) (APIDefinitionsClientHeadResponse, error) { + var err error + req, err := client.headCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIDefinitionsClientHeadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIDefinitionsClientHeadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return APIDefinitionsClientHeadResponse{}, err + } + return APIDefinitionsClientHeadResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// headCreateRequest creates the Head request. +func (client *APIDefinitionsClient) headCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientHeadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + if client.definitionName == "" { + return nil, errors.New("parameter client.definitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{definitionName}", url.PathEscape(client.definitionName)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// ImportSpecification - Imports the API specification. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - The API specification source entity. +// - options - APIDefinitionsClientImportSpecificationOptions contains the optional parameters for the APIDefinitionsClient.ImportSpecification +// method. +func (client *APIDefinitionsClient) ImportSpecification(ctx context.Context, resourceGroupName string, serviceName string, payload APISpecImportRequest, options *APIDefinitionsClientImportSpecificationOptions) (APIDefinitionsClientImportSpecificationResponse, error) { + var err error + req, err := client.importSpecificationCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return APIDefinitionsClientImportSpecificationResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIDefinitionsClientImportSpecificationResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return APIDefinitionsClientImportSpecificationResponse{}, err + } + return APIDefinitionsClientImportSpecificationResponse{}, nil +} + +// importSpecificationCreateRequest creates the ImportSpecification request. +func (client *APIDefinitionsClient) importSpecificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload APISpecImportRequest, options *APIDefinitionsClientImportSpecificationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}/importSpecification" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + if client.definitionName == "" { + return nil, errors.New("parameter client.definitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{definitionName}", url.PathEscape(client.definitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// NewListPager - Returns a collection of API definitions. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIDefinitionsClientListOptions contains the optional parameters for the APIDefinitionsClient.NewListPager method. +func (client *APIDefinitionsClient) NewListPager(resourceGroupName string, serviceName string, options *APIDefinitionsClientListOptions) *runtime.Pager[APIDefinitionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[APIDefinitionsClientListResponse]{ + More: func(page APIDefinitionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *APIDefinitionsClientListResponse) (APIDefinitionsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return APIDefinitionsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIDefinitionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return APIDefinitionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *APIDefinitionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIDefinitionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if client.filter != nil { + reqQP.Set("$filter", *client.filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *APIDefinitionsClient) listHandleResponse(resp *http.Response) (APIDefinitionsClientListResponse, error) { + result := APIDefinitionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APIDefinitionCollection); err != nil { + return APIDefinitionsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/apis_client.go b/sdk/resourcemanager/apicenter/armapicenter/apis_client.go new file mode 100644 index 000000000000..79ab741866d9 --- /dev/null +++ b/sdk/resourcemanager/apicenter/armapicenter/apis_client.go @@ -0,0 +1,375 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapicenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ApisClient contains the methods for the Apis group. +// Don't use this type directly, use NewApisClient() instead. +type ApisClient struct { + internal *arm.Client + subscriptionID string + workspaceName string + filter *string + apiName string +} + +// NewApisClient creates a new instance of ApisClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - workspaceName - The name of the workspace. +// - apiName - The name of the API. +// - filter - OData filter parameter. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewApisClient(subscriptionID string, workspaceName string, apiName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApisClient, error) { + cl, err := arm.NewClient(moduleName+".ApisClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ApisClient{ + subscriptionID: subscriptionID, + workspaceName: workspaceName, + apiName: apiName, + filter: filter, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates new or updates existing API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - API entity. +// - options - ApisClientCreateOrUpdateOptions contains the optional parameters for the ApisClient.CreateOrUpdate method. +func (client *ApisClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload API, options *ApisClientCreateOrUpdateOptions) (ApisClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return ApisClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApisClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ApisClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ApisClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload API, options *ApisClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ApisClient) createOrUpdateHandleResponse(resp *http.Response) (ApisClientCreateOrUpdateResponse, error) { + result := ApisClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.API); err != nil { + return ApisClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specified API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - ApisClientDeleteOptions contains the optional parameters for the ApisClient.Delete method. +func (client *ApisClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *ApisClientDeleteOptions) (ApisClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return ApisClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApisClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ApisClientDeleteResponse{}, err + } + return ApisClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ApisClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ApisClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns details of the API. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - ApisClientGetOptions contains the optional parameters for the ApisClient.Get method. +func (client *ApisClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *ApisClientGetOptions) (ApisClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return ApisClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApisClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApisClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ApisClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ApisClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ApisClient) getHandleResponse(resp *http.Response) (ApisClientGetResponse, error) { + result := ApisClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.API); err != nil { + return ApisClientGetResponse{}, err + } + return result, nil +} + +// Head - Checks if specified API exists. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - ApisClientHeadOptions contains the optional parameters for the ApisClient.Head method. +func (client *ApisClient) Head(ctx context.Context, resourceGroupName string, serviceName string, options *ApisClientHeadOptions) (ApisClientHeadResponse, error) { + var err error + req, err := client.headCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return ApisClientHeadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApisClientHeadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApisClientHeadResponse{}, err + } + return ApisClientHeadResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// headCreateRequest creates the Head request. +func (client *ApisClient) headCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ApisClientHeadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListPager - Returns a collection of APIs. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - ApisClientListOptions contains the optional parameters for the ApisClient.NewListPager method. +func (client *ApisClient) NewListPager(resourceGroupName string, serviceName string, options *ApisClientListOptions) *runtime.Pager[ApisClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ApisClientListResponse]{ + More: func(page ApisClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ApisClientListResponse) (ApisClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ApisClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApisClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ApisClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ApisClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ApisClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if client.filter != nil { + reqQP.Set("$filter", *client.filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ApisClient) listHandleResponse(resp *http.Response) (ApisClientListResponse, error) { + result := ApisClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APICollection); err != nil { + return ApisClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/apiversions_client.go b/sdk/resourcemanager/apicenter/armapicenter/apiversions_client.go new file mode 100644 index 000000000000..4d5a1ea8303f --- /dev/null +++ b/sdk/resourcemanager/apicenter/armapicenter/apiversions_client.go @@ -0,0 +1,399 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapicenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// APIVersionsClient contains the methods for the APIVersions group. +// Don't use this type directly, use NewAPIVersionsClient() instead. +type APIVersionsClient struct { + internal *arm.Client + subscriptionID string + workspaceName string + apiName string + filter *string + versionName string +} + +// NewAPIVersionsClient creates a new instance of APIVersionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - workspaceName - The name of the workspace. +// - apiName - The name of the API. +// - versionName - The name of the API version. +// - filter - OData filter parameter. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAPIVersionsClient(subscriptionID string, workspaceName string, apiName string, versionName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APIVersionsClient, error) { + cl, err := arm.NewClient(moduleName+".APIVersionsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &APIVersionsClient{ + subscriptionID: subscriptionID, + workspaceName: workspaceName, + apiName: apiName, + versionName: versionName, + filter: filter, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates new or updates existing API version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - API version entity. +// - options - APIVersionsClientCreateOrUpdateOptions contains the optional parameters for the APIVersionsClient.CreateOrUpdate +// method. +func (client *APIVersionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload APIVersion, options *APIVersionsClientCreateOrUpdateOptions) (APIVersionsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return APIVersionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIVersionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return APIVersionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIVersionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload APIVersion, options *APIVersionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (APIVersionsClientCreateOrUpdateResponse, error) { + result := APIVersionsClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIVersion); err != nil { + return APIVersionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specified API version +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIVersionsClientDeleteOptions contains the optional parameters for the APIVersionsClient.Delete method. +func (client *APIVersionsClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionsClientDeleteOptions) (APIVersionsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIVersionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIVersionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return APIVersionsClientDeleteResponse{}, err + } + return APIVersionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIVersionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns details of the API version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIVersionsClientGetOptions contains the optional parameters for the APIVersionsClient.Get method. +func (client *APIVersionsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionsClientGetOptions) (APIVersionsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return APIVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *APIVersionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIVersionsClient) getHandleResponse(resp *http.Response) (APIVersionsClientGetResponse, error) { + result := APIVersionsClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.APIVersion); err != nil { + return APIVersionsClientGetResponse{}, err + } + return result, nil +} + +// Head - Checks if specified API version exists. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIVersionsClientHeadOptions contains the optional parameters for the APIVersionsClient.Head method. +func (client *APIVersionsClient) Head(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionsClientHeadOptions) (APIVersionsClientHeadResponse, error) { + var err error + req, err := client.headCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIVersionsClientHeadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIVersionsClientHeadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return APIVersionsClientHeadResponse{}, err + } + return APIVersionsClientHeadResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// headCreateRequest creates the Head request. +func (client *APIVersionsClient) headCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionsClientHeadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.versionName == "" { + return nil, errors.New("parameter client.versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(client.versionName)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListPager - Returns a collection of API versions. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - APIVersionsClientListOptions contains the optional parameters for the APIVersionsClient.NewListPager method. +func (client *APIVersionsClient) NewListPager(resourceGroupName string, serviceName string, options *APIVersionsClientListOptions) *runtime.Pager[APIVersionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[APIVersionsClientListResponse]{ + More: func(page APIVersionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *APIVersionsClientListResponse) (APIVersionsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return APIVersionsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return APIVersionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return APIVersionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *APIVersionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if client.filter != nil { + reqQP.Set("$filter", *client.filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *APIVersionsClient) listHandleResponse(resp *http.Response) (APIVersionsClientListResponse, error) { + result := APIVersionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.APIVersionCollection); err != nil { + return APIVersionsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/autorest.md b/sdk/resourcemanager/apicenter/armapicenter/autorest.md index 8f268ce5a89e..eb182e320a8e 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/autorest.md +++ b/sdk/resourcemanager/apicenter/armapicenter/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/apicenter/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/apicenter/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 -tag: package-2023-07-01-preview +module-version: 1.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/apicenter/armapicenter/client_factory.go b/sdk/resourcemanager/apicenter/armapicenter/client_factory.go index 11a3668758e9..1edd31dfbe10 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/client_factory.go +++ b/sdk/resourcemanager/apicenter/armapicenter/client_factory.go @@ -16,35 +16,84 @@ import ( // ClientFactory is a client factory used to create any client in this module. // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { - subscriptionID string - serviceName string - credential azcore.TokenCredential - options *arm.ClientOptions + subscriptionID string + workspaceName string + apiName string + versionName string + definitionName string + deploymentName string + environmentName string + metadataSchemaName string + filter *string + credential azcore.TokenCredential + options *arm.ClientOptions } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. -// - serviceName - Service name +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - workspaceName - The name of the workspace. +// - apiName - The name of the API. +// - versionName - The name of the API version. +// - definitionName - The name of the API definition. +// - deploymentName - The name of the API deployment. +// - environmentName - The name of the environment. +// - metadataSchemaName - The name of the metadata schema. +// - filter - OData filter parameter. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewClientFactory(subscriptionID string, serviceName string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { +func NewClientFactory(subscriptionID string, workspaceName string, apiName string, versionName string, definitionName string, deploymentName string, environmentName string, metadataSchemaName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, serviceName: serviceName, credential: credential, + subscriptionID: subscriptionID, workspaceName: workspaceName, apiName: apiName, versionName: versionName, definitionName: definitionName, deploymentName: deploymentName, environmentName: environmentName, metadataSchemaName: metadataSchemaName, filter: filter, credential: credential, options: options.Clone(), }, nil } +func (c *ClientFactory) NewAPIDefinitionsClient() *APIDefinitionsClient { + subClient, _ := NewAPIDefinitionsClient(c.subscriptionID, c.workspaceName, c.apiName, c.versionName, c.definitionName, c.filter, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAPIVersionsClient() *APIVersionsClient { + subClient, _ := NewAPIVersionsClient(c.subscriptionID, c.workspaceName, c.apiName, c.versionName, c.filter, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewApisClient() *ApisClient { + subClient, _ := NewApisClient(c.subscriptionID, c.workspaceName, c.apiName, c.filter, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { + subClient, _ := NewDeploymentsClient(c.subscriptionID, c.workspaceName, c.apiName, c.deploymentName, c.filter, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEnvironmentsClient() *EnvironmentsClient { + subClient, _ := NewEnvironmentsClient(c.subscriptionID, c.workspaceName, c.environmentName, c.filter, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMetadataSchemasClient() *MetadataSchemasClient { + subClient, _ := NewMetadataSchemasClient(c.subscriptionID, c.metadataSchemaName, c.filter, c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewOperationsClient() *OperationsClient { subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } func (c *ClientFactory) NewServicesClient() *ServicesClient { - subClient, _ := NewServicesClient(c.subscriptionID, c.serviceName, c.credential, c.options) + subClient, _ := NewServicesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspacesClient() *WorkspacesClient { + subClient, _ := NewWorkspacesClient(c.subscriptionID, c.workspaceName, c.filter, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/apicenter/armapicenter/constants.go b/sdk/resourcemanager/apicenter/armapicenter/constants.go index 2db703998b55..76b8d1da68b4 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/constants.go +++ b/sdk/resourcemanager/apicenter/armapicenter/constants.go @@ -10,9 +10,68 @@ package armapicenter const ( moduleName = "armapicenter" - moduleVersion = "v0.1.0" + moduleVersion = "v1.0.0" ) +// APIKind - Kind of API. For example, REST or GraphQL. +type APIKind string + +const ( + APIKindGraphql APIKind = "graphql" + APIKindGrpc APIKind = "grpc" + APIKindRest APIKind = "rest" + APIKindSoap APIKind = "soap" + APIKindWebhook APIKind = "webhook" + APIKindWebsocket APIKind = "websocket" +) + +// PossibleAPIKindValues returns the possible values for the APIKind const type. +func PossibleAPIKindValues() []APIKind { + return []APIKind{ + APIKindGraphql, + APIKindGrpc, + APIKindRest, + APIKindSoap, + APIKindWebhook, + APIKindWebsocket, + } +} + +type APISpecExportResultFormat string + +const ( + // APISpecExportResultFormatInline - The inlined content of a specification document. + APISpecExportResultFormatInline APISpecExportResultFormat = "inline" + // APISpecExportResultFormatLink - The link to the result of the export operation. The URL is valid for 5 minutes. + APISpecExportResultFormatLink APISpecExportResultFormat = "link" +) + +// PossibleAPISpecExportResultFormatValues returns the possible values for the APISpecExportResultFormat const type. +func PossibleAPISpecExportResultFormatValues() []APISpecExportResultFormat { + return []APISpecExportResultFormat{ + APISpecExportResultFormatInline, + APISpecExportResultFormatLink, + } +} + +// APISpecImportSourceFormat - Format of the API specification source. +type APISpecImportSourceFormat string + +const ( + // APISpecImportSourceFormatInline - The inlined content of a specification document. + APISpecImportSourceFormatInline APISpecImportSourceFormat = "inline" + // APISpecImportSourceFormatLink - The link to a specification document hosted on a publicly accessible internet address. + APISpecImportSourceFormatLink APISpecImportSourceFormat = "link" +) + +// PossibleAPISpecImportSourceFormatValues returns the possible values for the APISpecImportSourceFormat const type. +func PossibleAPISpecImportSourceFormatValues() []APISpecImportSourceFormat { + return []APISpecImportSourceFormat{ + APISpecImportSourceFormatInline, + APISpecImportSourceFormatLink, + } +} + // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. type ActionType string @@ -47,6 +106,94 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// DeploymentState - State of API deployment. +type DeploymentState string + +const ( + DeploymentStateActive DeploymentState = "active" + DeploymentStateInactive DeploymentState = "inactive" +) + +// PossibleDeploymentStateValues returns the possible values for the DeploymentState const type. +func PossibleDeploymentStateValues() []DeploymentState { + return []DeploymentState{ + DeploymentStateActive, + DeploymentStateInactive, + } +} + +// EnvironmentKind - Environment kind. +type EnvironmentKind string + +const ( + EnvironmentKindDevelopment EnvironmentKind = "development" + EnvironmentKindProduction EnvironmentKind = "production" + EnvironmentKindStaging EnvironmentKind = "staging" + EnvironmentKindTesting EnvironmentKind = "testing" +) + +// PossibleEnvironmentKindValues returns the possible values for the EnvironmentKind const type. +func PossibleEnvironmentKindValues() []EnvironmentKind { + return []EnvironmentKind{ + EnvironmentKindDevelopment, + EnvironmentKindProduction, + EnvironmentKindStaging, + EnvironmentKindTesting, + } +} + +// EnvironmentServerType - Type of the server that represents the environment. +type EnvironmentServerType string + +const ( + EnvironmentServerTypeAWSAPIGateway EnvironmentServerType = "AWS API Gateway" + EnvironmentServerTypeApigeeAPIManagement EnvironmentServerType = "Apigee API Management" + EnvironmentServerTypeAzureAPIManagement EnvironmentServerType = "Azure API Management" + EnvironmentServerTypeAzureComputeService EnvironmentServerType = "Azure compute service" + EnvironmentServerTypeKongAPIGateway EnvironmentServerType = "Kong API Gateway" + EnvironmentServerTypeKubernetes EnvironmentServerType = "Kubernetes" + EnvironmentServerTypeMuleSoftAPIManagement EnvironmentServerType = "MuleSoft API Management" +) + +// PossibleEnvironmentServerTypeValues returns the possible values for the EnvironmentServerType const type. +func PossibleEnvironmentServerTypeValues() []EnvironmentServerType { + return []EnvironmentServerType{ + EnvironmentServerTypeAWSAPIGateway, + EnvironmentServerTypeApigeeAPIManagement, + EnvironmentServerTypeAzureAPIManagement, + EnvironmentServerTypeAzureComputeService, + EnvironmentServerTypeKongAPIGateway, + EnvironmentServerTypeKubernetes, + EnvironmentServerTypeMuleSoftAPIManagement, + } +} + +// LifecycleStage - Current lifecycle stage of the API. +type LifecycleStage string + +const ( + LifecycleStageDeprecated LifecycleStage = "deprecated" + LifecycleStageDesign LifecycleStage = "design" + LifecycleStageDevelopment LifecycleStage = "development" + LifecycleStagePreview LifecycleStage = "preview" + LifecycleStageProduction LifecycleStage = "production" + LifecycleStageRetired LifecycleStage = "retired" + LifecycleStageTesting LifecycleStage = "testing" +) + +// PossibleLifecycleStageValues returns the possible values for the LifecycleStage const type. +func PossibleLifecycleStageValues() []LifecycleStage { + return []LifecycleStage{ + LifecycleStageDeprecated, + LifecycleStageDesign, + LifecycleStageDevelopment, + LifecycleStagePreview, + LifecycleStageProduction, + LifecycleStageRetired, + LifecycleStageTesting, + } +} + // ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). type ManagedServiceIdentityType string @@ -67,6 +214,41 @@ func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { } } +// MetadataAssignmentEntity - An entity the metadata schema is requested for. +type MetadataAssignmentEntity string + +const ( + MetadataAssignmentEntityAPI MetadataAssignmentEntity = "api" + MetadataAssignmentEntityDeployment MetadataAssignmentEntity = "deployment" + MetadataAssignmentEntityEnvironment MetadataAssignmentEntity = "environment" +) + +// PossibleMetadataAssignmentEntityValues returns the possible values for the MetadataAssignmentEntity const type. +func PossibleMetadataAssignmentEntityValues() []MetadataAssignmentEntity { + return []MetadataAssignmentEntity{ + MetadataAssignmentEntityAPI, + MetadataAssignmentEntityDeployment, + MetadataAssignmentEntityEnvironment, + } +} + +type MetadataSchemaExportFormat string + +const ( + // MetadataSchemaExportFormatInline - The inlined content of a schema document. + MetadataSchemaExportFormatInline MetadataSchemaExportFormat = "inline" + // MetadataSchemaExportFormatLink - The link to a schema document. The URL is valid for 5 minutes. + MetadataSchemaExportFormatLink MetadataSchemaExportFormat = "link" +) + +// PossibleMetadataSchemaExportFormatValues returns the possible values for the MetadataSchemaExportFormat const type. +func PossibleMetadataSchemaExportFormatValues() []MetadataSchemaExportFormat { + return []MetadataSchemaExportFormat{ + MetadataSchemaExportFormatInline, + MetadataSchemaExportFormatLink, + } +} + // Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" type Origin string diff --git a/sdk/resourcemanager/apicenter/armapicenter/deployments_client.go b/sdk/resourcemanager/apicenter/armapicenter/deployments_client.go new file mode 100644 index 000000000000..23a6cf421245 --- /dev/null +++ b/sdk/resourcemanager/apicenter/armapicenter/deployments_client.go @@ -0,0 +1,399 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapicenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DeploymentsClient contains the methods for the Deployments group. +// Don't use this type directly, use NewDeploymentsClient() instead. +type DeploymentsClient struct { + internal *arm.Client + subscriptionID string + workspaceName string + apiName string + filter *string + deploymentName string +} + +// NewDeploymentsClient creates a new instance of DeploymentsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - workspaceName - The name of the workspace. +// - apiName - The name of the API. +// - deploymentName - The name of the API deployment. +// - filter - OData filter parameter. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDeploymentsClient(subscriptionID string, workspaceName string, apiName string, deploymentName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentsClient, error) { + cl, err := arm.NewClient(moduleName+".DeploymentsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DeploymentsClient{ + subscriptionID: subscriptionID, + workspaceName: workspaceName, + apiName: apiName, + deploymentName: deploymentName, + filter: filter, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates new or updates existing API deployment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - API deployment entity. +// - options - DeploymentsClientCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.CreateOrUpdate +// method. +func (client *DeploymentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload Deployment, options *DeploymentsClientCreateOrUpdateOptions) (DeploymentsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return DeploymentsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeploymentsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DeploymentsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload Deployment, options *DeploymentsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.deploymentName == "" { + return nil, errors.New("parameter client.deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(client.deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DeploymentsClient) createOrUpdateHandleResponse(resp *http.Response) (DeploymentsClientCreateOrUpdateResponse, error) { + result := DeploymentsClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.Deployment); err != nil { + return DeploymentsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes API deployment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - DeploymentsClientDeleteOptions contains the optional parameters for the DeploymentsClient.Delete method. +func (client *DeploymentsClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *DeploymentsClientDeleteOptions) (DeploymentsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return DeploymentsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeploymentsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DeploymentsClientDeleteResponse{}, err + } + return DeploymentsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DeploymentsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.deploymentName == "" { + return nil, errors.New("parameter client.deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(client.deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns details of the API deployment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. +func (client *DeploymentsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *DeploymentsClientGetOptions) (DeploymentsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return DeploymentsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeploymentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DeploymentsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DeploymentsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.deploymentName == "" { + return nil, errors.New("parameter client.deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(client.deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (DeploymentsClientGetResponse, error) { + result := DeploymentsClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.Deployment); err != nil { + return DeploymentsClientGetResponse{}, err + } + return result, nil +} + +// Head - Checks if specified API deployment exists. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - DeploymentsClientHeadOptions contains the optional parameters for the DeploymentsClient.Head method. +func (client *DeploymentsClient) Head(ctx context.Context, resourceGroupName string, serviceName string, options *DeploymentsClientHeadOptions) (DeploymentsClientHeadResponse, error) { + var err error + req, err := client.headCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return DeploymentsClientHeadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeploymentsClientHeadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DeploymentsClientHeadResponse{}, err + } + return DeploymentsClientHeadResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// headCreateRequest creates the Head request. +func (client *DeploymentsClient) headCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DeploymentsClientHeadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + if client.deploymentName == "" { + return nil, errors.New("parameter client.deploymentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentName}", url.PathEscape(client.deploymentName)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListPager - Returns a collection of API deployments. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.NewListPager method. +func (client *DeploymentsClient) NewListPager(resourceGroupName string, serviceName string, options *DeploymentsClientListOptions) *runtime.Pager[DeploymentsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DeploymentsClientListResponse]{ + More: func(page DeploymentsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DeploymentsClientListResponse) (DeploymentsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DeploymentsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DeploymentsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeploymentsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *DeploymentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DeploymentsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.apiName == "" { + return nil, errors.New("parameter client.apiName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiName}", url.PathEscape(client.apiName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if client.filter != nil { + reqQP.Set("$filter", *client.filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DeploymentsClient) listHandleResponse(resp *http.Response) (DeploymentsClientListResponse, error) { + result := DeploymentsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentCollection); err != nil { + return DeploymentsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/environments_client.go b/sdk/resourcemanager/apicenter/armapicenter/environments_client.go new file mode 100644 index 000000000000..fc15f8266a73 --- /dev/null +++ b/sdk/resourcemanager/apicenter/armapicenter/environments_client.go @@ -0,0 +1,376 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapicenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// EnvironmentsClient contains the methods for the Environments group. +// Don't use this type directly, use NewEnvironmentsClient() instead. +type EnvironmentsClient struct { + internal *arm.Client + subscriptionID string + workspaceName string + filter *string + environmentName string +} + +// NewEnvironmentsClient creates a new instance of EnvironmentsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - workspaceName - The name of the workspace. +// - environmentName - The name of the environment. +// - filter - OData filter parameter. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewEnvironmentsClient(subscriptionID string, workspaceName string, environmentName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EnvironmentsClient, error) { + cl, err := arm.NewClient(moduleName+".EnvironmentsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EnvironmentsClient{ + subscriptionID: subscriptionID, + workspaceName: workspaceName, + environmentName: environmentName, + filter: filter, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates new or updates existing environment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - Environment entity. +// - options - EnvironmentsClientCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.CreateOrUpdate +// method. +func (client *EnvironmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload Environment, options *EnvironmentsClientCreateOrUpdateOptions) (EnvironmentsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return EnvironmentsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnvironmentsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return EnvironmentsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload Environment, options *EnvironmentsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.environmentName == "" { + return nil, errors.New("parameter client.environmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(client.environmentName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EnvironmentsClient) createOrUpdateHandleResponse(resp *http.Response) (EnvironmentsClientCreateOrUpdateResponse, error) { + result := EnvironmentsClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.Environment); err != nil { + return EnvironmentsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes the environment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - EnvironmentsClientDeleteOptions contains the optional parameters for the EnvironmentsClient.Delete method. +func (client *EnvironmentsClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *EnvironmentsClientDeleteOptions) (EnvironmentsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return EnvironmentsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnvironmentsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return EnvironmentsClientDeleteResponse{}, err + } + return EnvironmentsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EnvironmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *EnvironmentsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.environmentName == "" { + return nil, errors.New("parameter client.environmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(client.environmentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns details of the environment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. +func (client *EnvironmentsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *EnvironmentsClientGetOptions) (EnvironmentsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return EnvironmentsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnvironmentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EnvironmentsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EnvironmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *EnvironmentsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.environmentName == "" { + return nil, errors.New("parameter client.environmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(client.environmentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EnvironmentsClient) getHandleResponse(resp *http.Response) (EnvironmentsClientGetResponse, error) { + result := EnvironmentsClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.Environment); err != nil { + return EnvironmentsClientGetResponse{}, err + } + return result, nil +} + +// Head - Checks if specified environment exists. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - EnvironmentsClientHeadOptions contains the optional parameters for the EnvironmentsClient.Head method. +func (client *EnvironmentsClient) Head(ctx context.Context, resourceGroupName string, serviceName string, options *EnvironmentsClientHeadOptions) (EnvironmentsClientHeadResponse, error) { + var err error + req, err := client.headCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return EnvironmentsClientHeadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnvironmentsClientHeadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EnvironmentsClientHeadResponse{}, err + } + return EnvironmentsClientHeadResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// headCreateRequest creates the Head request. +func (client *EnvironmentsClient) headCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *EnvironmentsClientHeadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + if client.environmentName == "" { + return nil, errors.New("parameter client.environmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(client.environmentName)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListPager - Returns a collection of environments. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - EnvironmentsClientListOptions contains the optional parameters for the EnvironmentsClient.NewListPager method. +func (client *EnvironmentsClient) NewListPager(resourceGroupName string, serviceName string, options *EnvironmentsClientListOptions) *runtime.Pager[EnvironmentsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[EnvironmentsClientListResponse]{ + More: func(page EnvironmentsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EnvironmentsClientListResponse) (EnvironmentsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EnvironmentsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnvironmentsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EnvironmentsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *EnvironmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *EnvironmentsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if client.filter != nil { + reqQP.Set("$filter", *client.filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EnvironmentsClient) listHandleResponse(resp *http.Response) (EnvironmentsClientListResponse, error) { + result := EnvironmentsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnvironmentCollection); err != nil { + return EnvironmentsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/go.mod b/sdk/resourcemanager/apicenter/armapicenter/go.mod index df77880424cb..7c7f047d2877 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/go.mod +++ b/sdk/resourcemanager/apicenter/armapicenter/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apicenter/armapicen go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.7.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/apicenter/armapicenter/go.sum b/sdk/resourcemanager/apicenter/armapicenter/go.sum index ee2bc4389c66..727ce838bdc8 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/go.sum +++ b/sdk/resourcemanager/apicenter/armapicenter/go.sum @@ -1,31 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +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.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/apicenter/armapicenter/metadataschemas_client.go b/sdk/resourcemanager/apicenter/armapicenter/metadataschemas_client.go new file mode 100644 index 000000000000..2cd064cfc0b2 --- /dev/null +++ b/sdk/resourcemanager/apicenter/armapicenter/metadataschemas_client.go @@ -0,0 +1,354 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapicenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// MetadataSchemasClient contains the methods for the MetadataSchemas group. +// Don't use this type directly, use NewMetadataSchemasClient() instead. +type MetadataSchemasClient struct { + internal *arm.Client + subscriptionID string + filter *string + metadataSchemaName string +} + +// NewMetadataSchemasClient creates a new instance of MetadataSchemasClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - metadataSchemaName - The name of the metadata schema. +// - filter - OData filter parameter. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewMetadataSchemasClient(subscriptionID string, metadataSchemaName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MetadataSchemasClient, error) { + cl, err := arm.NewClient(moduleName+".MetadataSchemasClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &MetadataSchemasClient{ + subscriptionID: subscriptionID, + metadataSchemaName: metadataSchemaName, + filter: filter, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates new or updates existing metadata schema. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - Metadata schema entity. +// - options - MetadataSchemasClientCreateOrUpdateOptions contains the optional parameters for the MetadataSchemasClient.CreateOrUpdate +// method. +func (client *MetadataSchemasClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload MetadataSchema, options *MetadataSchemasClientCreateOrUpdateOptions) (MetadataSchemasClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return MetadataSchemasClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return MetadataSchemasClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return MetadataSchemasClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *MetadataSchemasClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload MetadataSchema, options *MetadataSchemasClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.metadataSchemaName == "" { + return nil, errors.New("parameter client.metadataSchemaName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{metadataSchemaName}", url.PathEscape(client.metadataSchemaName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *MetadataSchemasClient) createOrUpdateHandleResponse(resp *http.Response) (MetadataSchemasClientCreateOrUpdateResponse, error) { + result := MetadataSchemasClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.MetadataSchema); err != nil { + return MetadataSchemasClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specified metadata schema. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - MetadataSchemasClientDeleteOptions contains the optional parameters for the MetadataSchemasClient.Delete method. +func (client *MetadataSchemasClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *MetadataSchemasClientDeleteOptions) (MetadataSchemasClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return MetadataSchemasClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return MetadataSchemasClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return MetadataSchemasClientDeleteResponse{}, err + } + return MetadataSchemasClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *MetadataSchemasClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *MetadataSchemasClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.metadataSchemaName == "" { + return nil, errors.New("parameter client.metadataSchemaName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{metadataSchemaName}", url.PathEscape(client.metadataSchemaName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns details of the metadata schema. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - MetadataSchemasClientGetOptions contains the optional parameters for the MetadataSchemasClient.Get method. +func (client *MetadataSchemasClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *MetadataSchemasClientGetOptions) (MetadataSchemasClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return MetadataSchemasClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return MetadataSchemasClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MetadataSchemasClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *MetadataSchemasClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *MetadataSchemasClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.metadataSchemaName == "" { + return nil, errors.New("parameter client.metadataSchemaName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{metadataSchemaName}", url.PathEscape(client.metadataSchemaName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *MetadataSchemasClient) getHandleResponse(resp *http.Response) (MetadataSchemasClientGetResponse, error) { + result := MetadataSchemasClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.MetadataSchema); err != nil { + return MetadataSchemasClientGetResponse{}, err + } + return result, nil +} + +// Head - Checks if specified metadata schema exists. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - MetadataSchemasClientHeadOptions contains the optional parameters for the MetadataSchemasClient.Head method. +func (client *MetadataSchemasClient) Head(ctx context.Context, resourceGroupName string, serviceName string, options *MetadataSchemasClientHeadOptions) (MetadataSchemasClientHeadResponse, error) { + var err error + req, err := client.headCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return MetadataSchemasClientHeadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return MetadataSchemasClientHeadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MetadataSchemasClientHeadResponse{}, err + } + return MetadataSchemasClientHeadResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// headCreateRequest creates the Head request. +func (client *MetadataSchemasClient) headCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *MetadataSchemasClientHeadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.metadataSchemaName == "" { + return nil, errors.New("parameter client.metadataSchemaName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{metadataSchemaName}", url.PathEscape(client.metadataSchemaName)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListPager - Returns a collection of metadata schemas. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - MetadataSchemasClientListOptions contains the optional parameters for the MetadataSchemasClient.NewListPager +// method. +func (client *MetadataSchemasClient) NewListPager(resourceGroupName string, serviceName string, options *MetadataSchemasClientListOptions) *runtime.Pager[MetadataSchemasClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[MetadataSchemasClientListResponse]{ + More: func(page MetadataSchemasClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *MetadataSchemasClientListResponse) (MetadataSchemasClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return MetadataSchemasClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return MetadataSchemasClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return MetadataSchemasClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *MetadataSchemasClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *MetadataSchemasClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/metadataSchemas" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if client.filter != nil { + reqQP.Set("$filter", *client.filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *MetadataSchemasClient) listHandleResponse(resp *http.Response) (MetadataSchemasClientListResponse, error) { + result := MetadataSchemasClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MetadataSchemaCollection); err != nil { + return MetadataSchemasClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/models.go b/sdk/resourcemanager/apicenter/armapicenter/models.go index c39003138623..d71d6c22fba9 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/models.go +++ b/sdk/resourcemanager/apicenter/armapicenter/models.go @@ -10,6 +10,321 @@ package armapicenter import "time" +// API entity. +type API struct { + // API properties. + Properties *APIProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// APICollection - Paginated collection of APIs. +type APICollection struct { + // READ-ONLY; The link to the next page of items + NextLink *string + + // READ-ONLY; Page items. + Value []*API +} + +// APIDefinition - API definition entity. +type APIDefinition struct { + // API definition properties entity. + Properties *APIDefinitionProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// APIDefinitionCollection - Paginated collection of API definitions. +type APIDefinitionCollection struct { + // READ-ONLY; The link to the next page of items + NextLink *string + + // READ-ONLY; Page items. + Value []*APIDefinition +} + +// APIDefinitionProperties - API definition properties entity. +type APIDefinitionProperties struct { + // REQUIRED; API definition title. + Title *string + + // API definition description. + Description *string + + // READ-ONLY; API specification details. + Specification *APIDefinitionPropertiesSpecification +} + +// APIDefinitionPropertiesSpecification - API specification details. +type APIDefinitionPropertiesSpecification struct { + // Specification name. + Name *string + + // Specification version. + Version *string +} + +// APIProperties - API properties. +type APIProperties struct { + // REQUIRED; Kind of API. For example, REST or GraphQL. + Kind *APIKind + + // REQUIRED; API title. + Title *string + Contacts []*Contact + + // The custom metadata defined for API catalog entities. + CustomProperties any + + // Description of the API. + Description *string + ExternalDocumentation []*ExternalDocumentation + + // The license information for the API. + License *License + + // Short description of the API. + Summary *string + + // Terms of service for the API. + TermsOfService *TermsOfService + + // READ-ONLY; Current lifecycle stage of the API. + LifecycleStage *LifecycleStage +} + +// APISpecExportResult - The API specification export result. +type APISpecExportResult struct { + Format *APISpecExportResultFormat + + // The result of the export operation. + Value *string +} + +// APISpecImportRequest - The API specification source entity properties. +type APISpecImportRequest struct { + // Format of the API specification source. + Format *APISpecImportSourceFormat + + // API specification details. + Specification *APISpecImportRequestSpecification + + // Value of the API specification source. + Value *string +} + +// APISpecImportRequestSpecification - API specification details. +type APISpecImportRequestSpecification struct { + // Specification name. + Name *string + + // Specification version. + Version *string +} + +// APIVersion - API version entity. +type APIVersion struct { + // API version properties entity. + Properties *APIVersionProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// APIVersionCollection - Paginated collection of API versions. +type APIVersionCollection struct { + // READ-ONLY; The link to the next page of items + NextLink *string + + // READ-ONLY; Page items. + Value []*APIVersion +} + +// APIVersionProperties - API version properties entity. +type APIVersionProperties struct { + // REQUIRED; Current lifecycle stage of the API. + LifecycleStage *LifecycleStage + + // REQUIRED; API version title. + Title *string +} + +type Contact struct { + // Email address of the contact. + Email *string + + // Name of the contact. + Name *string + + // URL for the contact. + URL *string +} + +// Deployment - API deployment entity. +type Deployment struct { + // API deployment entity properties. + Properties *DeploymentProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// DeploymentCollection - Paginated collection of API deployments. +type DeploymentCollection struct { + // READ-ONLY; The link to the next page of items + NextLink *string + + // READ-ONLY; Page items. + Value []*Deployment +} + +// DeploymentProperties - API deployment entity properties. +type DeploymentProperties struct { + // The custom metadata defined for API catalog entities. + CustomProperties any + + // API center-scoped definition resource ID. + DefinitionID *string + + // Description of the deployment. + Description *string + + // API center-scoped environment resource ID. + EnvironmentID *string + + // Server + Server *DeploymentServer + + // State of API deployment. + State *DeploymentState + + // API deployment title + Title *string +} + +// DeploymentServer - Server +type DeploymentServer struct { + // Base runtime URLs for this deployment. + RuntimeURI []*string +} + +// Environment entity. +type Environment struct { + // Environment properties entity. + Properties *EnvironmentProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// EnvironmentCollection - Paginated collection of environments. +type EnvironmentCollection struct { + // READ-ONLY; The link to the next page of items + NextLink *string + + // READ-ONLY; Page items. + Value []*Environment +} + +// EnvironmentProperties - Environment properties entity. +type EnvironmentProperties struct { + // REQUIRED; Environment kind. + Kind *EnvironmentKind + + // REQUIRED; Environment title. + Title *string + + // The custom metadata defined for API catalog entities. + CustomProperties any + + // Description. + Description *string + Onboarding *Onboarding + + // Server information of the environment. + Server *EnvironmentServer +} + +// EnvironmentServer - Server information of the environment. +type EnvironmentServer struct { + ManagementPortalURI []*string + + // Type of the server that represents the environment. + Type *EnvironmentServerType +} + +// ExternalDocumentation - Additional, external documentation for the API. +type ExternalDocumentation struct { + // REQUIRED; URL pointing to the documentation. + URL *string + + // Description of the documentation. + Description *string + + // Title of the documentation. + Title *string +} + +// License - The license information for the API. +type License struct { + // SPDX license information for the API. The identifier field is mutually exclusive of the URL field. + Identifier *string + + // Name of the license. + Name *string + + // URL pointing to the license details. The URL field is mutually exclusive of the identifier field. + URL *string +} + // ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) type ManagedServiceIdentity struct { // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). @@ -30,6 +345,69 @@ type ManagedServiceIdentity struct { TenantID *string } +type MetadataAssignment struct { + Deprecated *bool + + // The entities this metadata schema component gets applied to. + Entity *MetadataAssignmentEntity + Required *bool +} + +// MetadataSchema - Metadata schema entity. Used to define metadata for the entities in API catalog. +type MetadataSchema struct { + // Metadata schema properties. + Properties *MetadataSchemaProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// MetadataSchemaCollection - Paginated collection of metadata schemas. +type MetadataSchemaCollection struct { + // READ-ONLY; The link to the next page of items + NextLink *string + + // READ-ONLY; Page items. + Value []*MetadataSchema +} + +// MetadataSchemaExportRequest - The metadata schema export request. +type MetadataSchemaExportRequest struct { + // An entity the metadata schema is requested for. + AssignedTo *MetadataAssignmentEntity +} + +// MetadataSchemaExportResult - The metadata schema export result. +type MetadataSchemaExportResult struct { + Format *MetadataSchemaExportFormat + + // The result of the export operation. + Value *string +} + +// MetadataSchemaProperties - Metadata schema properties. +type MetadataSchemaProperties struct { + // REQUIRED; The schema defining the type. + Schema *string + AssignedTo []*MetadataAssignment +} + +type Onboarding struct { + DeveloperPortalURI []*string + + // Onboarding guide. + Instructions *string +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -84,7 +462,7 @@ type Service struct { // REQUIRED; The geo-location where the resource lives Location *string - // The identity of the service. + // Managed service identity (system assigned and/or user assigned identities) Identity *ManagedServiceIdentity // The properties of the service. @@ -117,7 +495,7 @@ type ServiceCollection struct { // ServiceProperties - The properties of the service. type ServiceProperties struct { - // READ-ONLY; The status of the last operation. + // READ-ONLY; Provisioning state of the service. ProvisioningState *ProvisioningState } @@ -148,6 +526,12 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// TermsOfService - Terms of service for the API. +type TermsOfService struct { + // REQUIRED; URL pointing to the terms of service. + URL *string +} + // UserAssignedIdentity - User assigned identity properties type UserAssignedIdentity struct { // READ-ONLY; The client ID of the assigned identity. @@ -156,3 +540,39 @@ type UserAssignedIdentity struct { // READ-ONLY; The principal ID of the assigned identity. PrincipalID *string } + +// Workspace entity. +type Workspace struct { + // Workspace properties. + Properties *WorkspaceProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// WorkspaceCollection - Paginated collection of workspaces. +type WorkspaceCollection struct { + // READ-ONLY; The link to the next page of items + NextLink *string + + // READ-ONLY; Page items. + Value []*Workspace +} + +// WorkspaceProperties - Workspace properties. +type WorkspaceProperties struct { + // REQUIRED; Workspace title. + Title *string + + // Workspace description. + Description *string +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/models_serde.go b/sdk/resourcemanager/apicenter/armapicenter/models_serde.go index 82c9f17518d8..8599bffb9ae8 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/models_serde.go +++ b/sdk/resourcemanager/apicenter/armapicenter/models_serde.go @@ -15,6 +15,894 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type API. +func (a API) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type API. +func (a *API) 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 "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + 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 APICollection. +func (a APICollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APICollection. +func (a *APICollection) 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 APIDefinition. +func (a APIDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIDefinition. +func (a *APIDefinition) 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 "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + 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 APIDefinitionCollection. +func (a APIDefinitionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIDefinitionCollection. +func (a *APIDefinitionCollection) 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 APIDefinitionProperties. +func (a APIDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "specification", a.Specification) + populate(objectMap, "title", a.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIDefinitionProperties. +func (a *APIDefinitionProperties) 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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "specification": + err = unpopulate(val, "Specification", &a.Specification) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &a.Title) + 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 APIDefinitionPropertiesSpecification. +func (a APIDefinitionPropertiesSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIDefinitionPropertiesSpecification. +func (a *APIDefinitionPropertiesSpecification) 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 "version": + err = unpopulate(val, "Version", &a.Version) + 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 APIProperties. +func (a APIProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contacts", a.Contacts) + populateAny(objectMap, "customProperties", a.CustomProperties) + populate(objectMap, "description", a.Description) + populate(objectMap, "externalDocumentation", a.ExternalDocumentation) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "license", a.License) + populate(objectMap, "lifecycleStage", a.LifecycleStage) + populate(objectMap, "summary", a.Summary) + populate(objectMap, "termsOfService", a.TermsOfService) + populate(objectMap, "title", a.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIProperties. +func (a *APIProperties) 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 "contacts": + err = unpopulate(val, "Contacts", &a.Contacts) + delete(rawMsg, key) + case "customProperties": + err = unpopulate(val, "CustomProperties", &a.CustomProperties) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "externalDocumentation": + err = unpopulate(val, "ExternalDocumentation", &a.ExternalDocumentation) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + case "license": + err = unpopulate(val, "License", &a.License) + delete(rawMsg, key) + case "lifecycleStage": + err = unpopulate(val, "LifecycleStage", &a.LifecycleStage) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &a.Summary) + delete(rawMsg, key) + case "termsOfService": + err = unpopulate(val, "TermsOfService", &a.TermsOfService) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &a.Title) + 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 APISpecExportResult. +func (a APISpecExportResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "format", a.Format) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APISpecExportResult. +func (a *APISpecExportResult) 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 "format": + err = unpopulate(val, "Format", &a.Format) + 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 APISpecImportRequest. +func (a APISpecImportRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "format", a.Format) + populate(objectMap, "specification", a.Specification) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APISpecImportRequest. +func (a *APISpecImportRequest) 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 "format": + err = unpopulate(val, "Format", &a.Format) + delete(rawMsg, key) + case "specification": + err = unpopulate(val, "Specification", &a.Specification) + 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 APISpecImportRequestSpecification. +func (a APISpecImportRequestSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + populate(objectMap, "version", a.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APISpecImportRequestSpecification. +func (a *APISpecImportRequestSpecification) 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 "version": + err = unpopulate(val, "Version", &a.Version) + 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 APIVersion. +func (a APIVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIVersion. +func (a *APIVersion) 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 "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + 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 APIVersionCollection. +func (a APIVersionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIVersionCollection. +func (a *APIVersionCollection) 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 APIVersionProperties. +func (a APIVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "lifecycleStage", a.LifecycleStage) + populate(objectMap, "title", a.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIVersionProperties. +func (a *APIVersionProperties) 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 "lifecycleStage": + err = unpopulate(val, "LifecycleStage", &a.LifecycleStage) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &a.Title) + 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 Contact. +func (c Contact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "email", c.Email) + populate(objectMap, "name", c.Name) + populate(objectMap, "url", c.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Contact. +func (c *Contact) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "email": + err = unpopulate(val, "Email", &c.Email) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &c.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Deployment. +func (d Deployment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Deployment. +func (d *Deployment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentCollection. +func (d DeploymentCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentCollection. +func (d *DeploymentCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentProperties. +func (d DeploymentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "customProperties", d.CustomProperties) + populate(objectMap, "definitionId", d.DefinitionID) + populate(objectMap, "description", d.Description) + populate(objectMap, "environmentId", d.EnvironmentID) + populate(objectMap, "server", d.Server) + populate(objectMap, "state", d.State) + populate(objectMap, "title", d.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentProperties. +func (d *DeploymentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customProperties": + err = unpopulate(val, "CustomProperties", &d.CustomProperties) + delete(rawMsg, key) + case "definitionId": + err = unpopulate(val, "DefinitionID", &d.DefinitionID) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "environmentId": + err = unpopulate(val, "EnvironmentID", &d.EnvironmentID) + delete(rawMsg, key) + case "server": + err = unpopulate(val, "Server", &d.Server) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &d.State) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &d.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentServer. +func (d DeploymentServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "runtimeUri", d.RuntimeURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentServer. +func (d *DeploymentServer) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "runtimeUri": + err = unpopulate(val, "RuntimeURI", &d.RuntimeURI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Environment. +func (e Environment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Environment. +func (e *Environment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + 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 EnvironmentCollection. +func (e EnvironmentCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentCollection. +func (e *EnvironmentCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EnvironmentProperties. +func (e EnvironmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "customProperties", e.CustomProperties) + populate(objectMap, "description", e.Description) + populate(objectMap, "kind", e.Kind) + populate(objectMap, "onboarding", e.Onboarding) + populate(objectMap, "server", e.Server) + populate(objectMap, "title", e.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentProperties. +func (e *EnvironmentProperties) 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 "customProperties": + err = unpopulate(val, "CustomProperties", &e.CustomProperties) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "onboarding": + err = unpopulate(val, "Onboarding", &e.Onboarding) + delete(rawMsg, key) + case "server": + err = unpopulate(val, "Server", &e.Server) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &e.Title) + 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 EnvironmentServer. +func (e EnvironmentServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managementPortalUri", e.ManagementPortalURI) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentServer. +func (e *EnvironmentServer) 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 "managementPortalUri": + err = unpopulate(val, "ManagementPortalURI", &e.ManagementPortalURI) + 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 ExternalDocumentation. +func (e ExternalDocumentation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", e.Description) + populate(objectMap, "title", e.Title) + populate(objectMap, "url", e.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalDocumentation. +func (e *ExternalDocumentation) 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 "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &e.Title) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &e.URL) + 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 License. +func (l License) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identifier", l.Identifier) + populate(objectMap, "name", l.Name) + populate(objectMap, "url", l.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type License. +func (l *License) 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 "identifier": + err = unpopulate(val, "Identifier", &l.Identifier) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &l.URL) + 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 ManagedServiceIdentity. func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -54,6 +942,235 @@ func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type MetadataAssignment. +func (m MetadataAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deprecated", m.Deprecated) + populate(objectMap, "entity", m.Entity) + populate(objectMap, "required", m.Required) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetadataAssignment. +func (m *MetadataAssignment) 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 "deprecated": + err = unpopulate(val, "Deprecated", &m.Deprecated) + delete(rawMsg, key) + case "entity": + err = unpopulate(val, "Entity", &m.Entity) + delete(rawMsg, key) + case "required": + err = unpopulate(val, "Required", &m.Required) + 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 MetadataSchema. +func (m MetadataSchema) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "systemData", m.SystemData) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetadataSchema. +func (m *MetadataSchema) 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 "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &m.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + 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 MetadataSchemaCollection. +func (m MetadataSchemaCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetadataSchemaCollection. +func (m *MetadataSchemaCollection) 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 "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, 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 MetadataSchemaExportRequest. +func (m MetadataSchemaExportRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignedTo", m.AssignedTo) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetadataSchemaExportRequest. +func (m *MetadataSchemaExportRequest) 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 "assignedTo": + err = unpopulate(val, "AssignedTo", &m.AssignedTo) + 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 MetadataSchemaExportResult. +func (m MetadataSchemaExportResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "format", m.Format) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetadataSchemaExportResult. +func (m *MetadataSchemaExportResult) 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 "format": + err = unpopulate(val, "Format", &m.Format) + delete(rawMsg, 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 MetadataSchemaProperties. +func (m MetadataSchemaProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignedTo", m.AssignedTo) + populate(objectMap, "schema", m.Schema) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetadataSchemaProperties. +func (m *MetadataSchemaProperties) 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 "assignedTo": + err = unpopulate(val, "AssignedTo", &m.AssignedTo) + delete(rawMsg, key) + case "schema": + err = unpopulate(val, "Schema", &m.Schema) + 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 Onboarding. +func (o Onboarding) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "developerPortalUri", o.DeveloperPortalURI) + populate(objectMap, "instructions", o.Instructions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Onboarding. +func (o *Onboarding) 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 "developerPortalUri": + err = unpopulate(val, "DeveloperPortalURI", &o.DeveloperPortalURI) + delete(rawMsg, key) + case "instructions": + err = unpopulate(val, "Instructions", &o.Instructions) + 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 Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -354,6 +1471,33 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TermsOfService. +func (t TermsOfService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "url", t.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TermsOfService. +func (t *TermsOfService) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "url": + err = unpopulate(val, "URL", &t.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -385,6 +1529,111 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Workspace. +func (w Workspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Workspace. +func (w *Workspace) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &w.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceCollection. +func (w WorkspaceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceCollection. +func (w *WorkspaceCollection) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceProperties. +func (w WorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", w.Description) + populate(objectMap, "title", w.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceProperties. +func (w *WorkspaceProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &w.Description) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &w.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + func populate(m map[string]any, k string, v any) { if v == nil { return @@ -395,6 +1644,16 @@ func populate(m map[string]any, k string, v any) { } } +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil diff --git a/sdk/resourcemanager/apicenter/armapicenter/operations_client.go b/sdk/resourcemanager/apicenter/armapicenter/operations_client.go index 331d94f940b1..00862cf7af46 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/operations_client.go +++ b/sdk/resourcemanager/apicenter/armapicenter/operations_client.go @@ -37,9 +37,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - List the operations for the provider +// NewListPager - Returns a collection of resource provider operations. // -// Generated from API version 2023-07-01-preview +// Generated from API version 2024-03-01 // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -77,7 +77,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-07-01-preview") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/apicenter/armapicenter/operations_client_example_test.go b/sdk/resourcemanager/apicenter/armapicenter/operations_client_example_test.go deleted file mode 100644 index 58e5c8ce6e5f..000000000000 --- a/sdk/resourcemanager/apicenter/armapicenter/operations_client_example_test.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapicenter_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apicenter/armapicenter" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapicenter.NewClientFactory("", "", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armapicenter.OperationListResult{ - // Value: []*armapicenter.Operation{ - // { - // Name: to.Ptr("Microsoft.ApiCenter/services/read"), - // Display: &armapicenter.OperationDisplay{ - // Description: to.Ptr("Lists registered services"), - // Operation: to.Ptr("Lists services"), - // Provider: to.Ptr("Microsoft.ApiCenter"), - // Resource: to.Ptr("services"), - // }, - // IsDataAction: to.Ptr(false), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/apicenter/armapicenter/options.go b/sdk/resourcemanager/apicenter/armapicenter/options.go index 1e69124a9330..7e949d2f7ee5 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/options.go +++ b/sdk/resourcemanager/apicenter/armapicenter/options.go @@ -8,6 +8,170 @@ package armapicenter +// APIDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the APIDefinitionsClient.CreateOrUpdate +// method. +type APIDefinitionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIDefinitionsClientDeleteOptions contains the optional parameters for the APIDefinitionsClient.Delete method. +type APIDefinitionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIDefinitionsClientExportSpecificationOptions contains the optional parameters for the APIDefinitionsClient.ExportSpecification +// method. +type APIDefinitionsClientExportSpecificationOptions struct { + // placeholder for future optional parameters +} + +// APIDefinitionsClientGetOptions contains the optional parameters for the APIDefinitionsClient.Get method. +type APIDefinitionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// APIDefinitionsClientHeadOptions contains the optional parameters for the APIDefinitionsClient.Head method. +type APIDefinitionsClientHeadOptions struct { + // placeholder for future optional parameters +} + +// APIDefinitionsClientImportSpecificationOptions contains the optional parameters for the APIDefinitionsClient.ImportSpecification +// method. +type APIDefinitionsClientImportSpecificationOptions struct { + // placeholder for future optional parameters +} + +// APIDefinitionsClientListOptions contains the optional parameters for the APIDefinitionsClient.NewListPager method. +type APIDefinitionsClientListOptions struct { + // placeholder for future optional parameters +} + +// APIVersionsClientCreateOrUpdateOptions contains the optional parameters for the APIVersionsClient.CreateOrUpdate method. +type APIVersionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIVersionsClientDeleteOptions contains the optional parameters for the APIVersionsClient.Delete method. +type APIVersionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIVersionsClientGetOptions contains the optional parameters for the APIVersionsClient.Get method. +type APIVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// APIVersionsClientHeadOptions contains the optional parameters for the APIVersionsClient.Head method. +type APIVersionsClientHeadOptions struct { + // placeholder for future optional parameters +} + +// APIVersionsClientListOptions contains the optional parameters for the APIVersionsClient.NewListPager method. +type APIVersionsClientListOptions struct { + // placeholder for future optional parameters +} + +// ApisClientCreateOrUpdateOptions contains the optional parameters for the ApisClient.CreateOrUpdate method. +type ApisClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ApisClientDeleteOptions contains the optional parameters for the ApisClient.Delete method. +type ApisClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ApisClientGetOptions contains the optional parameters for the ApisClient.Get method. +type ApisClientGetOptions struct { + // placeholder for future optional parameters +} + +// ApisClientHeadOptions contains the optional parameters for the ApisClient.Head method. +type ApisClientHeadOptions struct { + // placeholder for future optional parameters +} + +// ApisClientListOptions contains the optional parameters for the ApisClient.NewListPager method. +type ApisClientListOptions struct { + // placeholder for future optional parameters +} + +// DeploymentsClientCreateOrUpdateOptions contains the optional parameters for the DeploymentsClient.CreateOrUpdate method. +type DeploymentsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DeploymentsClientDeleteOptions contains the optional parameters for the DeploymentsClient.Delete method. +type DeploymentsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. +type DeploymentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DeploymentsClientHeadOptions contains the optional parameters for the DeploymentsClient.Head method. +type DeploymentsClientHeadOptions struct { + // placeholder for future optional parameters +} + +// DeploymentsClientListOptions contains the optional parameters for the DeploymentsClient.NewListPager method. +type DeploymentsClientListOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentsClientCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.CreateOrUpdate method. +type EnvironmentsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentsClientDeleteOptions contains the optional parameters for the EnvironmentsClient.Delete method. +type EnvironmentsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. +type EnvironmentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentsClientHeadOptions contains the optional parameters for the EnvironmentsClient.Head method. +type EnvironmentsClientHeadOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentsClientListOptions contains the optional parameters for the EnvironmentsClient.NewListPager method. +type EnvironmentsClientListOptions struct { + // placeholder for future optional parameters +} + +// MetadataSchemasClientCreateOrUpdateOptions contains the optional parameters for the MetadataSchemasClient.CreateOrUpdate +// method. +type MetadataSchemasClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// MetadataSchemasClientDeleteOptions contains the optional parameters for the MetadataSchemasClient.Delete method. +type MetadataSchemasClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// MetadataSchemasClientGetOptions contains the optional parameters for the MetadataSchemasClient.Get method. +type MetadataSchemasClientGetOptions struct { + // placeholder for future optional parameters +} + +// MetadataSchemasClientHeadOptions contains the optional parameters for the MetadataSchemasClient.Head method. +type MetadataSchemasClientHeadOptions struct { + // placeholder for future optional parameters +} + +// MetadataSchemasClientListOptions contains the optional parameters for the MetadataSchemasClient.NewListPager method. +type MetadataSchemasClientListOptions struct { + // placeholder for future optional parameters +} + // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters @@ -23,6 +187,12 @@ type ServicesClientDeleteOptions struct { // placeholder for future optional parameters } +// ServicesClientExportMetadataSchemaOptions contains the optional parameters for the ServicesClient.ExportMetadataSchema +// method. +type ServicesClientExportMetadataSchemaOptions struct { + // placeholder for future optional parameters +} + // ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. type ServicesClientGetOptions struct { // placeholder for future optional parameters @@ -44,3 +214,28 @@ type ServicesClientListBySubscriptionOptions struct { type ServicesClientUpdateOptions struct { // placeholder for future optional parameters } + +// WorkspacesClientCreateOrUpdateOptions contains the optional parameters for the WorkspacesClient.CreateOrUpdate method. +type WorkspacesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientDeleteOptions contains the optional parameters for the WorkspacesClient.Delete method. +type WorkspacesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientGetOptions contains the optional parameters for the WorkspacesClient.Get method. +type WorkspacesClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientHeadOptions contains the optional parameters for the WorkspacesClient.Head method. +type WorkspacesClientHeadOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientListOptions contains the optional parameters for the WorkspacesClient.NewListPager method. +type WorkspacesClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/response_types.go b/sdk/resourcemanager/apicenter/armapicenter/response_types.go index 0e2a0396b831..96ed678b3329 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/response_types.go +++ b/sdk/resourcemanager/apicenter/armapicenter/response_types.go @@ -8,6 +8,227 @@ package armapicenter +// APIDefinitionsClientCreateOrUpdateResponse contains the response from method APIDefinitionsClient.CreateOrUpdate. +type APIDefinitionsClientCreateOrUpdateResponse struct { + // API definition entity. + APIDefinition + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIDefinitionsClientDeleteResponse contains the response from method APIDefinitionsClient.Delete. +type APIDefinitionsClientDeleteResponse struct { + // placeholder for future response values +} + +// APIDefinitionsClientExportSpecificationResponse contains the response from method APIDefinitionsClient.ExportSpecification. +type APIDefinitionsClientExportSpecificationResponse struct { + // The API specification export result. + APISpecExportResult +} + +// APIDefinitionsClientGetResponse contains the response from method APIDefinitionsClient.Get. +type APIDefinitionsClientGetResponse struct { + // API definition entity. + APIDefinition + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIDefinitionsClientHeadResponse contains the response from method APIDefinitionsClient.Head. +type APIDefinitionsClientHeadResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIDefinitionsClientImportSpecificationResponse contains the response from method APIDefinitionsClient.ImportSpecification. +type APIDefinitionsClientImportSpecificationResponse struct { + // placeholder for future response values +} + +// APIDefinitionsClientListResponse contains the response from method APIDefinitionsClient.NewListPager. +type APIDefinitionsClientListResponse struct { + // Paginated collection of API definitions. + APIDefinitionCollection +} + +// APIVersionsClientCreateOrUpdateResponse contains the response from method APIVersionsClient.CreateOrUpdate. +type APIVersionsClientCreateOrUpdateResponse struct { + // API version entity. + APIVersion + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIVersionsClientDeleteResponse contains the response from method APIVersionsClient.Delete. +type APIVersionsClientDeleteResponse struct { + // placeholder for future response values +} + +// APIVersionsClientGetResponse contains the response from method APIVersionsClient.Get. +type APIVersionsClientGetResponse struct { + // API version entity. + APIVersion + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIVersionsClientHeadResponse contains the response from method APIVersionsClient.Head. +type APIVersionsClientHeadResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIVersionsClientListResponse contains the response from method APIVersionsClient.NewListPager. +type APIVersionsClientListResponse struct { + // Paginated collection of API versions. + APIVersionCollection +} + +// ApisClientCreateOrUpdateResponse contains the response from method ApisClient.CreateOrUpdate. +type ApisClientCreateOrUpdateResponse struct { + // API entity. + API + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ApisClientDeleteResponse contains the response from method ApisClient.Delete. +type ApisClientDeleteResponse struct { + // placeholder for future response values +} + +// ApisClientGetResponse contains the response from method ApisClient.Get. +type ApisClientGetResponse struct { + // API entity. + API + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ApisClientHeadResponse contains the response from method ApisClient.Head. +type ApisClientHeadResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ApisClientListResponse contains the response from method ApisClient.NewListPager. +type ApisClientListResponse struct { + // Paginated collection of APIs. + APICollection +} + +// DeploymentsClientCreateOrUpdateResponse contains the response from method DeploymentsClient.CreateOrUpdate. +type DeploymentsClientCreateOrUpdateResponse struct { + // API deployment entity. + Deployment + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// DeploymentsClientDeleteResponse contains the response from method DeploymentsClient.Delete. +type DeploymentsClientDeleteResponse struct { + // placeholder for future response values +} + +// DeploymentsClientGetResponse contains the response from method DeploymentsClient.Get. +type DeploymentsClientGetResponse struct { + // API deployment entity. + Deployment + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// DeploymentsClientHeadResponse contains the response from method DeploymentsClient.Head. +type DeploymentsClientHeadResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// DeploymentsClientListResponse contains the response from method DeploymentsClient.NewListPager. +type DeploymentsClientListResponse struct { + // Paginated collection of API deployments. + DeploymentCollection +} + +// EnvironmentsClientCreateOrUpdateResponse contains the response from method EnvironmentsClient.CreateOrUpdate. +type EnvironmentsClientCreateOrUpdateResponse struct { + // Environment entity. + Environment + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// EnvironmentsClientDeleteResponse contains the response from method EnvironmentsClient.Delete. +type EnvironmentsClientDeleteResponse struct { + // placeholder for future response values +} + +// EnvironmentsClientGetResponse contains the response from method EnvironmentsClient.Get. +type EnvironmentsClientGetResponse struct { + // Environment entity. + Environment + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// EnvironmentsClientHeadResponse contains the response from method EnvironmentsClient.Head. +type EnvironmentsClientHeadResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// EnvironmentsClientListResponse contains the response from method EnvironmentsClient.NewListPager. +type EnvironmentsClientListResponse struct { + // Paginated collection of environments. + EnvironmentCollection +} + +// MetadataSchemasClientCreateOrUpdateResponse contains the response from method MetadataSchemasClient.CreateOrUpdate. +type MetadataSchemasClientCreateOrUpdateResponse struct { + // Metadata schema entity. Used to define metadata for the entities in API catalog. + MetadataSchema + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// MetadataSchemasClientDeleteResponse contains the response from method MetadataSchemasClient.Delete. +type MetadataSchemasClientDeleteResponse struct { + // placeholder for future response values +} + +// MetadataSchemasClientGetResponse contains the response from method MetadataSchemasClient.Get. +type MetadataSchemasClientGetResponse struct { + // Metadata schema entity. Used to define metadata for the entities in API catalog. + MetadataSchema + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// MetadataSchemasClientHeadResponse contains the response from method MetadataSchemasClient.Head. +type MetadataSchemasClientHeadResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// MetadataSchemasClientListResponse contains the response from method MetadataSchemasClient.NewListPager. +type MetadataSchemasClientListResponse struct { + // Paginated collection of metadata schemas. + MetadataSchemaCollection +} + // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. @@ -25,6 +246,12 @@ type ServicesClientDeleteResponse struct { // placeholder for future response values } +// ServicesClientExportMetadataSchemaResponse contains the response from method ServicesClient.ExportMetadataSchema. +type ServicesClientExportMetadataSchemaResponse struct { + // The metadata schema export result. + MetadataSchemaExportResult +} + // ServicesClientGetResponse contains the response from method ServicesClient.Get. type ServicesClientGetResponse struct { // The service entity. @@ -48,3 +275,38 @@ type ServicesClientUpdateResponse struct { // The service entity. Service } + +// WorkspacesClientCreateOrUpdateResponse contains the response from method WorkspacesClient.CreateOrUpdate. +type WorkspacesClientCreateOrUpdateResponse struct { + // Workspace entity. + Workspace + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspacesClientDeleteResponse contains the response from method WorkspacesClient.Delete. +type WorkspacesClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspacesClientGetResponse contains the response from method WorkspacesClient.Get. +type WorkspacesClientGetResponse struct { + // Workspace entity. + Workspace + + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// WorkspacesClientHeadResponse contains the response from method WorkspacesClient.Head. +type WorkspacesClientHeadResponse struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// WorkspacesClientListResponse contains the response from method WorkspacesClient.NewListPager. +type WorkspacesClientListResponse struct { + // Paginated collection of workspaces. + WorkspaceCollection +} diff --git a/sdk/resourcemanager/apicenter/armapicenter/services_client.go b/sdk/resourcemanager/apicenter/armapicenter/services_client.go index b728e3ede9f7..5fc53785db76 100644 --- a/sdk/resourcemanager/apicenter/armapicenter/services_client.go +++ b/sdk/resourcemanager/apicenter/armapicenter/services_client.go @@ -25,37 +25,35 @@ import ( type ServicesClient struct { internal *arm.Client subscriptionID string - serviceName string } // NewServicesClient creates a new instance of ServicesClient with the specified values. -// - subscriptionID - The ID of the target subscription. -// - serviceName - Service name +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewServicesClient(subscriptionID string, serviceName string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServicesClient, error) { +func NewServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServicesClient, error) { cl, err := arm.NewClient(moduleName+".ServicesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServicesClient{ subscriptionID: subscriptionID, - serviceName: serviceName, internal: cl, } return client, nil } -// CreateOrUpdate - Create or update service +// CreateOrUpdate - Creates new or updates existing API. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-07-01-preview +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - resource - The service entity. +// - serviceName - The name of Azure API Center service. +// - payload - The service entity. // - options - ServicesClientCreateOrUpdateOptions contains the optional parameters for the ServicesClient.CreateOrUpdate method. -func (client *ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resource Service, options *ServicesClientCreateOrUpdateOptions) (ServicesClientCreateOrUpdateResponse, error) { +func (client *ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload Service, options *ServicesClientCreateOrUpdateOptions) (ServicesClientCreateOrUpdateResponse, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resource, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) if err != nil { return ServicesClientCreateOrUpdateResponse{}, err } @@ -72,29 +70,26 @@ func (client *ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupN } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resource Service, options *ServicesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload Service, options *ServicesClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - 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 client.serviceName == "" { - return nil, errors.New("parameter client.serviceName cannot be empty") + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(client.serviceName)) + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-07-01-preview") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, resource); err != nil { + if err := runtime.MarshalAsJSON(req, payload); err != nil { return nil, err } return req, nil @@ -109,15 +104,16 @@ func (client *ServicesClient) createOrUpdateHandleResponse(resp *http.Response) return result, nil } -// Delete - Delete service +// Delete - Deletes specified service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-07-01-preview +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. // - options - ServicesClientDeleteOptions contains the optional parameters for the ServicesClient.Delete method. -func (client *ServicesClient) Delete(ctx context.Context, resourceGroupName string, options *ServicesClientDeleteOptions) (ServicesClientDeleteResponse, error) { +func (client *ServicesClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *ServicesClientDeleteOptions) (ServicesClientDeleteResponse, error) { var err error - req, err := client.deleteCreateRequest(ctx, resourceGroupName, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) if err != nil { return ServicesClientDeleteResponse{}, err } @@ -133,40 +129,100 @@ func (client *ServicesClient) Delete(ctx context.Context, resourceGroupName stri } // deleteCreateRequest creates the Delete request. -func (client *ServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, options *ServicesClientDeleteOptions) (*policy.Request, error) { +func (client *ServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ServicesClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - 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 client.serviceName == "" { - return nil, errors.New("parameter client.serviceName cannot be empty") + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(client.serviceName)) + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-07-01-preview") + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// ExportMetadataSchema - Exports the effective metadata schema. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - The metadata schema request details. +// - options - ServicesClientExportMetadataSchemaOptions contains the optional parameters for the ServicesClient.ExportMetadataSchema +// method. +func (client *ServicesClient) ExportMetadataSchema(ctx context.Context, resourceGroupName string, serviceName string, payload MetadataSchemaExportRequest, options *ServicesClientExportMetadataSchemaOptions) (ServicesClientExportMetadataSchemaResponse, error) { + var err error + req, err := client.exportMetadataSchemaCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return ServicesClientExportMetadataSchemaResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ServicesClientExportMetadataSchemaResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ServicesClientExportMetadataSchemaResponse{}, err + } + resp, err := client.exportMetadataSchemaHandleResponse(httpResp) + return resp, err +} + +// exportMetadataSchemaCreateRequest creates the ExportMetadataSchema request. +func (client *ServicesClient) exportMetadataSchemaCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload MetadataSchemaExportRequest, options *ServicesClientExportMetadataSchemaOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/exportMetadataSchema" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } return req, nil } -// Get - Get service +// exportMetadataSchemaHandleResponse handles the ExportMetadataSchema response. +func (client *ServicesClient) exportMetadataSchemaHandleResponse(resp *http.Response) (ServicesClientExportMetadataSchemaResponse, error) { + result := ServicesClientExportMetadataSchemaResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.MetadataSchemaExportResult); err != nil { + return ServicesClientExportMetadataSchemaResponse{}, err + } + return result, nil +} + +// Get - Returns details of the service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-07-01-preview +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. // - options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. -func (client *ServicesClient) Get(ctx context.Context, resourceGroupName string, options *ServicesClientGetOptions) (ServicesClientGetResponse, error) { +func (client *ServicesClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *ServicesClientGetOptions) (ServicesClientGetResponse, error) { var err error - req, err := client.getCreateRequest(ctx, resourceGroupName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) if err != nil { return ServicesClientGetResponse{}, err } @@ -183,26 +239,23 @@ func (client *ServicesClient) Get(ctx context.Context, resourceGroupName string, } // getCreateRequest creates the Get request. -func (client *ServicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, options *ServicesClientGetOptions) (*policy.Request, error) { +func (client *ServicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ServicesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - 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 client.serviceName == "" { - return nil, errors.New("parameter client.serviceName cannot be empty") + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(client.serviceName)) + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-07-01-preview") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -217,9 +270,9 @@ func (client *ServicesClient) getHandleResponse(resp *http.Response) (ServicesCl return result, nil } -// NewListByResourceGroupPager - Lists services within a resource group +// NewListByResourceGroupPager - Returns a collection of services within the resource group. // -// Generated from API version 2023-07-01-preview +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ServicesClientListByResourceGroupOptions contains the optional parameters for the ServicesClient.NewListByResourceGroupPager // method. @@ -254,9 +307,6 @@ func (client *ServicesClient) NewListByResourceGroupPager(resourceGroupName stri // listByResourceGroupCreateRequest creates the ListByResourceGroup request. func (client *ServicesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ServicesClientListByResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services" - 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") @@ -267,7 +317,7 @@ func (client *ServicesClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-07-01-preview") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -284,7 +334,7 @@ func (client *ServicesClient) listByResourceGroupHandleResponse(resp *http.Respo // NewListBySubscriptionPager - Lists services within an Azure subscription. // -// Generated from API version 2023-07-01-preview +// Generated from API version 2024-03-01 // - options - ServicesClientListBySubscriptionOptions contains the optional parameters for the ServicesClient.NewListBySubscriptionPager // method. func (client *ServicesClient) NewListBySubscriptionPager(options *ServicesClientListBySubscriptionOptions) *runtime.Pager[ServicesClientListBySubscriptionResponse] { @@ -318,16 +368,13 @@ func (client *ServicesClient) NewListBySubscriptionPager(options *ServicesClient // listBySubscriptionCreateRequest creates the ListBySubscription request. func (client *ServicesClient) listBySubscriptionCreateRequest(ctx context.Context, options *ServicesClientListBySubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiCenter/services" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-07-01-preview") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -342,16 +389,17 @@ func (client *ServicesClient) listBySubscriptionHandleResponse(resp *http.Respon return result, nil } -// Update - Update service +// Update - Updates existing service. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-07-01-preview +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - parameters - The service properties to be updated. +// - serviceName - The name of Azure API Center service. +// - payload - The service properties to be updated. // - options - ServicesClientUpdateOptions contains the optional parameters for the ServicesClient.Update method. -func (client *ServicesClient) Update(ctx context.Context, resourceGroupName string, parameters ServiceUpdate, options *ServicesClientUpdateOptions) (ServicesClientUpdateResponse, error) { +func (client *ServicesClient) Update(ctx context.Context, resourceGroupName string, serviceName string, payload ServiceUpdate, options *ServicesClientUpdateOptions) (ServicesClientUpdateResponse, error) { var err error - req, err := client.updateCreateRequest(ctx, resourceGroupName, parameters, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) if err != nil { return ServicesClientUpdateResponse{}, err } @@ -368,29 +416,26 @@ func (client *ServicesClient) Update(ctx context.Context, resourceGroupName stri } // updateCreateRequest creates the Update request. -func (client *ServicesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, parameters ServiceUpdate, options *ServicesClientUpdateOptions) (*policy.Request, error) { +func (client *ServicesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload ServiceUpdate, options *ServicesClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}" - 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 client.serviceName == "" { - return nil, errors.New("parameter client.serviceName cannot be empty") + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(client.serviceName)) + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-07-01-preview") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, parameters); err != nil { + if err := runtime.MarshalAsJSON(req, payload); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/apicenter/armapicenter/services_client_example_test.go b/sdk/resourcemanager/apicenter/armapicenter/services_client_example_test.go deleted file mode 100644 index 7afeaa0f780a..000000000000 --- a/sdk/resourcemanager/apicenter/armapicenter/services_client_example_test.go +++ /dev/null @@ -1,261 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armapicenter_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apicenter/armapicenter" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListBySubscription.json -func ExampleServicesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapicenter.NewClientFactory("", "", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewServicesClient().NewListBySubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ServiceCollection = armapicenter.ServiceCollection{ - // Value: []*armapicenter.Service{ - // { - // Name: to.Ptr("contoso"), - // Type: to.Ptr("Microsoft.ApiCenter/services"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // }, - // Identity: &armapicenter.ManagedServiceIdentity{ - // Type: to.Ptr(armapicenter.ManagedServiceIdentityType("SystemAssigned, UserAssigned")), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Properties: &armapicenter.ServiceProperties{ - // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListByResourceGroup.json -func ExampleServicesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapicenter.NewClientFactory("", "", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewServicesClient().NewListByResourceGroupPager("contoso-resources", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ServiceCollection = armapicenter.ServiceCollection{ - // Value: []*armapicenter.Service{ - // { - // Name: to.Ptr("contoso"), - // Type: to.Ptr("Microsoft.ApiCenter/services"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // }, - // Identity: &armapicenter.ManagedServiceIdentity{ - // Type: to.Ptr(armapicenter.ManagedServiceIdentityType("SystemAssigned, UserAssigned")), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Properties: &armapicenter.ServiceProperties{ - // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Get.json -func ExampleServicesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapicenter.NewClientFactory("", "", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServicesClient().Get(ctx, "contoso-resources", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Service = armapicenter.Service{ - // Name: to.Ptr("contoso"), - // Type: to.Ptr("Microsoft.ApiCenter/services"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // }, - // Identity: &armapicenter.ManagedServiceIdentity{ - // Type: to.Ptr(armapicenter.ManagedServiceIdentityType("SystemAssigned, UserAssigned")), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Properties: &armapicenter.ServiceProperties{ - // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_CreateOrUpdate.json -func ExampleServicesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapicenter.NewClientFactory("", "", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServicesClient().CreateOrUpdate(ctx, "contoso-resources", armapicenter.Service{}, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Service = armapicenter.Service{ - // Name: to.Ptr("contoso"), - // Type: to.Ptr("Microsoft.ApiCenter/services"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // }, - // Identity: &armapicenter.ManagedServiceIdentity{ - // Type: to.Ptr(armapicenter.ManagedServiceIdentityType("SystemAssigned, UserAssigned")), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Properties: &armapicenter.ServiceProperties{ - // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Update.json -func ExampleServicesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapicenter.NewClientFactory("", "", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewServicesClient().Update(ctx, "contoso-resources", armapicenter.ServiceUpdate{}, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Service = armapicenter.Service{ - // Name: to.Ptr("contoso"), - // Type: to.Ptr("Microsoft.ApiCenter/services"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ApiCenter/services/contoso"), - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // }, - // Identity: &armapicenter.ManagedServiceIdentity{ - // Type: to.Ptr(armapicenter.ManagedServiceIdentityType("SystemAssigned, UserAssigned")), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // UserAssignedIdentities: map[string]*armapicenter.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/contoso-identity": &armapicenter.UserAssignedIdentity{ - // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // }, - // Properties: &armapicenter.ServiceProperties{ - // ProvisioningState: to.Ptr(armapicenter.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4cd95123fb961c68740565a1efcaa5e43bd35802/specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Delete.json -func ExampleServicesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armapicenter.NewClientFactory("", "", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewServicesClient().Delete(ctx, "contoso-resources", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/apicenter/armapicenter/workspaces_client.go b/sdk/resourcemanager/apicenter/armapicenter/workspaces_client.go new file mode 100644 index 000000000000..13dd325c0793 --- /dev/null +++ b/sdk/resourcemanager/apicenter/armapicenter/workspaces_client.go @@ -0,0 +1,353 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armapicenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// WorkspacesClient contains the methods for the Workspaces group. +// Don't use this type directly, use NewWorkspacesClient() instead. +type WorkspacesClient struct { + internal *arm.Client + subscriptionID string + filter *string + workspaceName string +} + +// NewWorkspacesClient creates a new instance of WorkspacesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - workspaceName - The name of the workspace. +// - filter - OData filter parameter. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspacesClient(subscriptionID string, workspaceName string, filter *string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspacesClient, error) { + cl, err := arm.NewClient(moduleName+".WorkspacesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspacesClient{ + subscriptionID: subscriptionID, + workspaceName: workspaceName, + filter: filter, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Creates new or updates existing workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - payload - Workspace entity. +// - options - WorkspacesClientCreateOrUpdateOptions contains the optional parameters for the WorkspacesClient.CreateOrUpdate +// method. +func (client *WorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, payload Workspace, options *WorkspacesClientCreateOrUpdateOptions) (WorkspacesClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, payload, options) + if err != nil { + return WorkspacesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkspacesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, payload Workspace, options *WorkspacesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, payload); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *WorkspacesClient) createOrUpdateHandleResponse(resp *http.Response) (WorkspacesClientCreateOrUpdateResponse, error) { + result := WorkspacesClientCreateOrUpdateResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes specified workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - WorkspacesClientDeleteOptions contains the optional parameters for the WorkspacesClient.Delete method. +func (client *WorkspacesClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspacesClientDeleteOptions) (WorkspacesClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return WorkspacesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkspacesClientDeleteResponse{}, err + } + return WorkspacesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspacesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns details of the workspace. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - WorkspacesClientGetOptions contains the optional parameters for the WorkspacesClient.Get method. +func (client *WorkspacesClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspacesClientGetOptions) (WorkspacesClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return WorkspacesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspacesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspacesClient) getHandleResponse(resp *http.Response) (WorkspacesClientGetResponse, error) { + result := WorkspacesClientGetResponse{} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesClientGetResponse{}, err + } + return result, nil +} + +// Head - Checks if specified workspace exists. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - WorkspacesClientHeadOptions contains the optional parameters for the WorkspacesClient.Head method. +func (client *WorkspacesClient) Head(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspacesClientHeadOptions) (WorkspacesClientHeadResponse, error) { + var err error + req, err := client.headCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return WorkspacesClientHeadResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientHeadResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacesClientHeadResponse{}, err + } + return WorkspacesClientHeadResponse{Success: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil +} + +// headCreateRequest creates the Head request. +func (client *WorkspacesClient) headCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspacesClientHeadOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces/{workspaceName}" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.workspaceName == "" { + return nil, errors.New("parameter client.workspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(client.workspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListPager - Returns a collection of workspaces. +// +// Generated from API version 2024-03-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serviceName - The name of Azure API Center service. +// - options - WorkspacesClientListOptions contains the optional parameters for the WorkspacesClient.NewListPager method. +func (client *WorkspacesClient) NewListPager(resourceGroupName string, serviceName string, options *WorkspacesClientListOptions) *runtime.Pager[WorkspacesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspacesClientListResponse]{ + More: func(page WorkspacesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspacesClientListResponse) (WorkspacesClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return WorkspacesClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkspacesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *WorkspacesClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *WorkspacesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}/workspaces" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") + if client.filter != nil { + reqQP.Set("$filter", *client.filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WorkspacesClient) listHandleResponse(resp *http.Response) (WorkspacesClientListResponse, error) { + result := WorkspacesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceCollection); err != nil { + return WorkspacesClientListResponse{}, err + } + return result, nil +}